Skip to content

Conversation

@AlexBasinov
Copy link
Collaborator

@AlexBasinov AlexBasinov commented Nov 4, 2025

Refactor install-oracle.sh by 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 simple install-oracle.sh script.

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-generated gcp_oracle.yml to dynamically construct the Ansible inventory in memory.

Input validation has been moved into a separate validate-config.yml playbook. 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 from group_vars/all.yml (which may contain Jinja2 templates) with variables from gcp_oracle.yml.

The final, merged inventory object can be inspected by running

ansible-inventory -i gcp_oracle.yml.<random_suffix> --list

Variable naming for default value assignment:

To make sure that default values are correctly applied in group_vars/all.yml and 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.yml defines a variable with a default (e.g., my_variable: "{{ my_variable | default('some_default_value') }}"), Ansible needs the input variable (on the right side of my_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 existing ora_ prefix already provides this necessary distinction, and allowing defaults to be set without issue.

Testing the inventory plugin:

  1. To run the inventory plugin tests, install the pytest
    pip install pytest

  2. navigate to the project's root directory and execute:
    pytest inventory_plugins/

Test Results:

Please refer to the presubmit tests for this PR.

@AlexBasinov AlexBasinov requested a review from mfielding November 4, 2025 02:40
@AlexBasinov AlexBasinov force-pushed the inventory-plugin branch 3 times, most recently from 696b2db to 3edbdd7 Compare November 4, 2025 03:24
@AlexBasinov
Copy link
Collaborator Author

Converting this to a draft while I fix the failing presubmit tests

@AlexBasinov
Copy link
Collaborator Author

/test all

4 similar comments
@AlexBasinov
Copy link
Collaborator Author

/test all

@AlexBasinov
Copy link
Collaborator Author

/test all

@AlexBasinov
Copy link
Collaborator Author

/test all

@AlexBasinov
Copy link
Collaborator Author

/test all

################################################################################

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 %}"
Copy link
Member

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.

Copy link
Collaborator Author

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.

@AlexBasinov
Copy link
Collaborator Author

/test all

2 similar comments
@AlexBasinov
Copy link
Collaborator Author

/test all

@AlexBasinov
Copy link
Collaborator Author

/test all

@AlexBasinov
Copy link
Collaborator Author

/test all

10 similar comments
@AlexBasinov
Copy link
Collaborator Author

/test all

@AlexBasinov
Copy link
Collaborator Author

/test all

@AlexBasinov
Copy link
Collaborator Author

/test all

@AlexBasinov
Copy link
Collaborator Author

/test all

@AlexBasinov
Copy link
Collaborator Author

/test all

@AlexBasinov
Copy link
Collaborator Author

/test all

@AlexBasinov
Copy link
Collaborator Author

/test all

@AlexBasinov
Copy link
Collaborator Author

/test all

@AlexBasinov
Copy link
Collaborator Author

/test all

@AlexBasinov
Copy link
Collaborator Author

/test all

@AlexBasinov
Copy link
Collaborator Author

/test all

1 similar comment
@AlexBasinov
Copy link
Collaborator Author

/test all

@AlexBasinov AlexBasinov marked this pull request as ready for review November 8, 2025 18:17
@AlexBasinov AlexBasinov force-pushed the inventory-plugin branch 2 times, most recently from a1f1075 to 067b782 Compare November 11, 2025 19:04
@AlexBasinov AlexBasinov changed the base branch from inventory-plugin to master December 15, 2025 23:10
@google-oss-prow
Copy link

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants