Hi. New to Ansible.
I have two playbooks in this Gihub repo https://github.com/symianarmy/oracle_database_refresh_itsm
-
itsm_oracle_refresh_wrapper.yml - this is the wrapper playbook that uses the Ansible Control Node to connect to a ServiceNow ticketing system, opens an Oracle database refresh task. The wrapper then calls an included second playbook:
-
itsm_oracle_refresh_actual.yml - this is the actual playbook that refreshes any or many lower environment databases (a UAT database in this demo) at the same time.
Both playbooks have to work in tandem, entirely unattended. The DBAs only are notified when something breaks. That is the intent.
My problem is this. The playbooks work just fine by themselves. But since I am an Ansible beginner (not an Oracle one!), I cannot make them work together.
The reason is this. The “wrapper” playbook only operates as localhost (it doesnt need to connect to the multiple oracle servers to open a ticket).
- name: RFRSH2025Q2 Omni-Client PROD_2_UAT | announce oracle_schema_refresh
hosts: localhost
gather_facts: true
vars_files:
- vars/main.yml
But the “actual” playbook, the one that is doing the multiple refreshes, has a different setup . It uses a “hosts” group and gathers facts on multiple servers to refresh ones content to many.
- hosts: db_servers
become: yes
gather_facts: True
SO, when the wrapper calls the actual playbook:
- name: Execute Included Oracle Refresh Playbook | execute oracle_schema_refresh
include: itsm_oracle_refresh_actual.yml
I get this error of the incompatibility:
[ansible_admin@ctrl ansible]$ ansible-playbook ./playbooks/itsm_oracle_refresh_wrapper.yml -v
Using /etc/ansible/ansible.cfg as config file
[WARNING]: Collection servicenow.itsm does not support Ansible version 2.14.17
[DEPRECATION WARNING]: "include" is deprecated, use include_tasks/import_tasks instead. See https://docs.ansible.com/ansible-core/2.14/user_guide/playbooks_reuse_includes.html for details. This feature will be removed in
version 2.16. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
ERROR! conflicting action statements: hosts, gather_facts
The error appears to be in '/etc/ansible/playbooks/itsm_oracle_refresh_actual.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- hosts: db_servers
^ here
[ansible_admin@ctrl ansible]$
The only way to make this work is to either run them separately (work fine by themselves) or commenting out the include, which is the same thing.
SO, how do I make this work with the include, together? I need to have the ticketing playbook, the “wrapper”, and the “actual” refresh playbooks separate. We will use the wrapper for closed-loop (without a DBA) automation of not only the refreshes, but most of the other provisioning and maintenance Oracle database tasks. The “actual” tasks will be different - a Dataguard build, an Oracle GOldenGAte refresh or Oracle opatch . All of those I have already as the actual playbooks, but I need to make them work together. That is the challenge I am facing. Please help. Thanks and god bless.
Here is a demo of the wrapper: https://www.youtube.com/watch?v=NJt84IN6bl0
Here is a demo of the wrapper: https://www.youtube.com/watch?v=2KOs__snm7k
Let me know if you need the actual playbooks seen in the demos, but all you need is already here.
Thanks.
A run log:
[ansible_admin@ctrl ansible]$ ansible-playbook ./playbooks/itsm_oracle_refresh_wrapper.yml
PLAY [RFRSH2025Q2 Omni-Client PROD_2_UAT | announce oracle_schema_refresh] *************************************************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************************************************************************************** ok: [localhost]
TASK [Auto-Create “RFRSH2025Q2 Omni-Client PROD_2_UAT” Task in ServiceNow | prepare oracle_schema_refresh] ***************************************************************************************************************************** [WARNING]: Encountered unknown value open while mapping field state. [WARNING]: Encountered unknown value 3 while mapping field close_code. [WARNING]: Encountered unknown value while mapping field close_code. changed: [localhost]
TASK [debug] *************************************************************************************************************************************************************************************************************************** ok: [localhost] => { “msg”: “Ansible Starting the Quarterly RFRSH2025Q2 Omni-Client PROD_2_UAT | prepare oracle_schema_refresh” }
TASK [Change ServiceNow Refresh Task State to In-Progress | prepare oracle_schema_refresh] ********************************************************************************************************************************************* changed: [localhost]
TASK [debug] *************************************************************************************************************************************************************************************************************************** ok: [localhost] => { “msg”: “Ansible Verified & Opened an Oracle RFRSH2025Q2 Omni-Client PROD_2_UAT Task INC0010116 in ServiceNow | execute oracle_schema_refresh” }
TASK [Prepare Oracle Refresh Process | execute oracle_schema_refresh] ****************************************************************************************************************************************************************** ok: [localhost]
TASK [debug] *************************************************************************************************************************************************************************************************************************** ok: [localhost] => { “msg”: “Ansible Executing RFRSH2025Q2 Omni-Client PROD_2_UAT Task INC0010116” }
TASK [debug] *************************************************************************************************************************************************************************************************************************** ok: [localhost] => { “msg”: “Ansible Closing the RFRSH2025Q2 Omni-Client PROD_2_UAT Task INC0010116” }
TASK [Close ServiceNow Refresh Task as Completed | cleanup oracle_schema_refresh] ****************************************************************************************************************************************************** [WARNING]: Encountered unknown value 2025Q5 Refreshed (Omni-CLient UAT) while mapping field close_code. changed: [localhost]
TASK [debug] *************************************************************************************************************************************************************************************************************************** ok: [localhost] => { “msg”: "Ansible Has Now Completed the Quarterly RFRSH2025Q2 Omni-Client PROD_2_UAT Task by Executing INC0010116, Refresh ServiceNow SYS_ID “6cbcc12a83512250a6565929feaad313"” }
PLAY RECAP ***************************************************************************************************************************************************************************************************************************** localhost : ok=10 changed=3 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
[ansible_admin@ctrl ansible]$
+++++++++++++++++++
[ansible_admin@ctrl ansible]$ ansible-playbook ./playbooks/itsm_oracle_refresh_actual.yml
PLAY [db_servers] **********************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************************************************************************************** [WARNING]: Platform linux on host 192.168.1.64 is using the discovered Python interpreter at /usr/libexec/platform-python, but future installation of another Python interpreter could change the meaning of that path. See Interpreter Discovery — Ansible Core Documentation for more information. ok: [192.168.1.64] [WARNING]: Platform linux on host 192.168.1.108 is using the discovered Python interpreter at /usr/libexec/platform-python, but future installation of another Python interpreter could change the meaning of that path. See Interpreter Discovery — Ansible Core Documentation for more information. ok: [192.168.1.108]
TASK [debug] *************************************************************************************************************************************************************************************************************************** ok: [192.168.1.64] => { “ansible_distribution”: “OracleLinux” } ok: [192.168.1.108] => { “ansible_distribution”: “OracleLinux” }
TASK [Confirm Local Facts for Each RDS Oracle Instance being Refreshed from a PROD Schema | prepare oracle_database_refresh of the “source” schema in the “SRCPROD” Database on “lnx072”] ********************************************** ok: [192.168.1.64] => { “ansible_local”: { “export”: { “localfacts”: { “export_fact_ansible_env_path”: “/home/ansible/admin”, “export_fact_container_database_type”: “legacy”, “export_fact_export_flag”: “on”, “export_fact_oracle_database_environment_purpose”: “PROD”, “export_fact_oracle_database_environment_readonly”: “true”, “export_fact_oracle_export_datapump_dir”: “DATA_PUMP_DIR”, “export_fact_oracle_export_user_name”: “source”, “export_fact_oracle_export_user_password”: , “export_fact_oracle_listener_port_number”: “1521”, “export_fact_oracle_local_hostname”: “lnx072”, “export_fact_oracle_rdbms_version”: “19.0.0”, “export_fact_oracle_sid_name”: “SRCPROD”, “export_fact_oracle_tns_admin”: “/u01/app/oracle/product/19c/dbhome_1/network/admin”, “export_fact_rdbms_home”: “/u01/app/oracle/product/19c/dbhome_1”, “export_fact_schema”: “source”, “export_fact_shared_scratchpad_s3_bucket”: “/mnt/hgfs/Linux_share/scratchpad/”, “import_fact_oracle_local_hostname”: “”, “import_fact_oracle_sid_name”: “”, “import_fact_schema”: “” } } } } ok: [192.168.1.108] => { “ansible_local”: { “export”: { “localfacts”: { “export_fact_ansible_env_path”: “/home/ansible_admin”, “export_fact_container_database_type”: “legacy”, “export_fact_export_flag”: “on”, “export_fact_oracle_database_environment_purpose”: “UAT”, “export_fact_oracle_database_environment_readonly”: “false”, “export_fact_oracle_export_datapump_dir”: “DATA_PUMP_DIR”, “export_fact_oracle_export_user_name”: “source”, “export_fact_oracle_export_user_password”: , “export_fact_oracle_listener_port_number”: “1521”, “export_fact_oracle_local_hostname”: “lnx073”, “export_fact_oracle_rdbms_version”: “19.0.0”, “export_fact_oracle_sid_name”: “SRCUAT”, “export_fact_oracle_tns_admin”: “/u01/app/oracle/product/19c/dbhome_1/network/admin”, “export_fact_rdbms_home”: “/u01/app/oracle/product/19c/dbhome_1”, “export_fact_schema”: “source”, “export_fact_shared_scratchpad_s3_bucket”: “/mnt/hgfs/Linux_share/scratchpad/”, “import_fact_oracle_local_hostname”: “lnx072”, “import_fact_oracle_sid_name”: “SRCPROD”, “import_fact_schema”: “source” } } } }
TASK [Check if Lockfile Exists or an Earlier Refresh Still Running | prepare oracle_database_refresh of the “source” schema in the “SRCPROD” Database on “lnx072”] ********************************************************************* ok: [192.168.1.64] ok: [192.168.1.108]
TASK [Create Lockfile if Doesnt Exist | prepare oracle_database_refresh of the “source” schema in the “SRCPROD” Database on “lnx072”] ************************************************************************************************** changed: [192.168.1.64] changed: [192.168.1.108]
TASK [Generate Local SOURCE Db Export ParFile from a Centralized JINJA Refresh Template | prepare oracle_database_refresh of the “source” schema in the “SRCPROD” Database on “lnx072”] ************************************************ changed: [192.168.1.64] changed: [192.168.1.108]
TASK [Export Source Schema to Scratchpad Usng the Custom Parfile | prepare oracle_database_refresh of the “source” schema in the “SRCPROD” Database on “lnx072”] *********************************************************************** skipping: [192.168.1.108] changed: [192.168.1.64]
TASK [Generate One or More Target Schema Refresh ParFiles from a Centralized JINJA Refresh Template | prepare oracle_database_refresh of the “source” schema in the “SRCPROD” Database on “lnx072”] ************************************ skipping: [192.168.1.64] changed: [192.168.1.108]
TASK [Import into the Destination Db Usng the Custom Import ParFile | execute oracle_database_refresh of the “source” schema in the “SRCPROD” Database on “lnx072”] ******************************************************************** skipping: [192.168.1.64] changed: [192.168.1.108]
PLAY RECAP ***************************************************************************************************************************************************************************************************************************** 192.168.1.108 : ok=8 changed=4 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
192.168.1.64 : ok=7 changed=3 unreachable=0 failed=0 skipped=2 rescued=0 ignored=0
[ansible_admin@ctrl ansible]$