-
Notifications
You must be signed in to change notification settings - Fork 34
Refactor inventory management with a custom Ansible plugin #380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
696b2db to
3edbdd7
Compare
|
Converting this to a draft while I fix the failing presubmit tests |
|
/test all |
4 similar comments
|
/test all |
|
/test all |
|
/test all |
|
/test all |
group_vars/all.yml
Outdated
| ################################################################################ | ||
|
|
||
| free_edition: "{{ oracle_edition == 'FREE' }}" | ||
| free_edition_name: "{% if free_edition %}{% if oracle_ver[:5] == '23.26' %}26ai{% elif oracle_ver[:4] == '23.2' or oracle_ver[:4] == '23.3' %}23c{% else %}{{ oracle_ver[:2] }}ai{% endif %}{% endif %}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When version 23.27 comes out, it will also be 26ai.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed free_edition_name and free_edition variables from group_vars/all.yml file as they were recently moved to roles/common/defaults/main/base_variables.yml.
I think it'd be better to address this comment in a separate PR to keep this one focused.
|
/test all |
2 similar comments
|
/test all |
|
/test all |
6adda22 to
9549165
Compare
|
/test all |
10 similar comments
|
/test all |
|
/test all |
|
/test all |
|
/test all |
|
/test all |
|
/test all |
|
/test all |
|
/test all |
|
/test all |
|
/test all |
|
/test all |
1 similar comment
|
/test all |
a1f1075 to
067b782
Compare
688d136 to
681559a
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: AlexBasinov The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…ed in roles/common/defaults/main/base_variables.yml
30db0a4 to
35b3c21
Compare
Refactor
install-oracle.shby replacing the complex inventory generation logic with a custom Ansible inventory plugin. The original script was becoming difficult to manage as it handled both input validation and the creation of an Ansible inventory file. This PR separates these 2 concerns resulting in a cleaner and more simpleinstall-oracle.shscript.I recommend starting review by examining inventory_plugins/README.md, as it provides an overview of how the new plugin works.
The core of the change is the new custom inventory plugin -
inventory_plugins/gcp_oracle_inventory.py. The plugin reads the auto-generatedgcp_oracle.ymlto dynamically construct the Ansible inventory in memory.Input validation has been moved into a separate
validate-config.ymlplaybook. This playbook runs first in the execution sequence and provides a "fail-fast" mechanism that verifies the configuration is correct before the installation begins.The toolkit's default values and derived variables remain in
group_vars/all.yml. When Ansible runs, it first calls the plugin to build the inventory object and then merges variables fromgroup_vars/all.yml(which may contain Jinja2 templates) with variables fromgcp_oracle.yml.The final, merged inventory object can be inspected by running
ansible-inventory -i gcp_oracle.yml.<random_suffix> --listVariable naming for default value assignment:
To make sure that default values are correctly applied in
group_vars/all.ymland to prevent Ansible errors, a leading underscore has been added to the following input variables:_db_password_secret
_backup_dest
_nfs_backup_config
_nfs_backup_mount
_install_workload_agent
_oracle_metrics_secret.
This is necessary because when
group_vars/all.ymldefines a variable with a default (e.g.,my_variable: "{{ my_variable | default('some_default_value') }}"), Ansible needs the input variable (on the right side ofmy_variable: {{) to have a different name than the final variable being set (on the left side). If the names were identical, Ansible would get confused and report an error. For other variables, the existingora_prefix already provides this necessary distinction, and allowing defaults to be set without issue.Testing the inventory plugin:
To run the inventory plugin tests, install the pytest
pip install pytestnavigate to the project's root directory and execute:
pytest inventory_plugins/Test Results:
Please refer to the presubmit tests for this PR.