Skip to content

Ansible task to query and output Oracle DBID after creation #284

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

sahsagar-google
Copy link
Collaborator

@sahsagar-google sahsagar-google commented Jul 7, 2025

The change involves modifying the config-db.yml Ansible playbook to capture and log the Oracle DBID after a database is created. This information can help in Day 2 operations such as backup and patching. SQLPlus is used here for the query and PR #280 helps push playbook events to Google Cloud Logging.

Buganizer: b/424254827

Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sahsagar-google
Once this PR has been reviewed and has the lgtm label, please assign alexbasinov for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

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

@AlexBasinov
Copy link
Collaborator

FYI The single-instance-on-bms presubmit test failed with the following error:

TASK [Gathering Facts] *********************************************************
fatal: [g322234287-s002]: FAILED! => {"msg": "The field 'environment' has an invalid value, which includes an undefined variable. The error was: 'oracle_home' is undefined"}

DBID reporting is needed only for WLM-triggered deployments on GCE. Could you please update the Ansible task to skip BMS?

@AlexBasinov
Copy link
Collaborator

could you please provide a sample log entry with the JSON structure that contains the extracted DBID?

@sahsagar-google
Copy link
Collaborator Author

could you please provide a sample log entry with the JSON structure that contains the extracted DBID?

Here is the output from the oracle-toolkit-install-single-instance-on-bms job

PLAY [Get and Log Oracle DBID for All Databases] *******************************
TASK [Gathering Facts] *********************************************************
ok: [g322234287-s002]
TASK [Execute SQL query to get DBID] *******************************************
ok: [g322234287-s002]
TASK [Extract DBID from query result] ******************************************
ok: [g322234287-s002]
TASK [Output DBID for Cloud Logging pipeline (example for stdout)] *************
ok: [g322234287-s002] => {
"msg": "ORACLE_DBID: 1734014694"
}

@@ -16,10 +16,7 @@
# Variables used by more than one role
pkg_mgr_lock_timeout: 180

oracle_ver_dir: "{% if free_edition %}{% if oracle_ver[:4] == '23.2' or oracle_ver[:4] == '23.3' %}23c{% else %}{{ oracle_ver[:2] }}ai{% endif %}{% else %}{{ oracle_ver[:6] }}{% endif %}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to change this? It gets confusing as we, say, define oracleHome in one file and grid_home in another.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vars defined here are lower in precedence from group_vars/all.yml which are applied to all tasks and hosts. So, without moving these variables the tasks are failing citing that the env variables are not available yet.
That could also be because the dependent variables (mentioned here) are not available.
If it is confusing, I could move all related variables to group_vars/all.yml. Please let me know your thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if they're lower in precedence, I think they should be available; can you check how we're referencing this in other playbooks? Having removed the environment references from the top-level playbooks, we may not even need to move these references at all.

@sahsagar-google sahsagar-google marked this pull request as draft July 17, 2025 20:28
@sahsagar-google sahsagar-google marked this pull request as ready for review July 17, 2025 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants