Hello Ansible Gurus,
I have a CSV file as below.
"DB_SCHEMA","SYSTEM_USER","SYSTEM_PASSWORD","TNS_NAME","TNS_DESCRIPTION"
"Client_Schema1","user","password","TNSNAME","(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SANDBOX1)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)))"
"Client_Schema2","user","password","TNSNAME","(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SANDBOX1)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)))"
"Client_Schema3","user","password","TNSNAME","(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SANDBOX1)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)))"
I need to read each line of this CSV file and execute a SQL statement
against a Remote Database.
This is the play book, which logs in to shared DB and get the CSV file to
Local Ansible Master and execute Client Schema on Remote DB upgrade by
using the entries from Shared DB.
- name: Run sqlplus command on {{ Shared DB }}
shell: source ~/.bash_profile && sqlplus -S '{{ SharedDB_username }}/{{
SharedDB_password }}@{{ SharedDB_database_host }}:1521/{{
SharedDB_service_name }}'
@"/etc/ansible/playbooks/database/roles/oracle-sql/files/final_query.sql"
delegate_to: localhost
tags: clientSchema
- name: Run powershell script
script: files/DecryptCsv.ps1 -InputFilePath '{{ input_csv_path }}' \
-OutputFilePath '{{ output_csv_path }}' \
-PassPhrase '{{ pass_phrase }}' \
-SaltValue '{{ salt_value }}' \
-PasswordIterations {{ password_iterations }} \
-InitVector '{{ init_vector }}'
delegate_to: localhost
tags: clientSchema
- name: get CSV File Content
shell: source ~/.bash_profile && awk -F',' '!/^#/ && !/^$/ { print }'
"{{ output_csv_path }}"
register: groups_out
delegate_to: localhost
- debug: var=groups_out.stdout_lines
- name: Update the Client Schema
shell: source ~/.bash_profile && sqlplus -S '{{ item.1.groups_out }}/{{
item.2.groups_out }}@{{ item.4.groups_out }}'
@"roles/oracle-sql/files/Scripts/client_hotfix.sql" {{ item.0.groups_out }}
sudo: no
with_items: "{{ groups_out.stdout_lines }}"
Failing with below error message
fatal: [10.202.98.198]: FAILED! => {"failed": true, "msg": "The task
includes an option with an undefined variable. The error was: 'unicode
object' has no attribute 'groups_out'\n\nThe error appears to have been in
'/etc/ansible/playbooks/database/roles/oracle-sql/tasks/main.yml': line 57,
column 5, but may\nbe elsewhere in the file depending on the exact syntax
problem.\n\nThe offending line appears to be:\n\n\n - name: Update the
Schema info\n ^ here\n\nexception type: <class
'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'unicode object' has
no attribute 'groups_out'"}
And also I might need to use When condition to check particular client
schema and shared schema version on remote DB then only apply this hotfix.
it would be helpful if you guide me here to fix this issue. I tried
different options nothing is working for me :(
Thanks and Regards
Shekar
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/0951450a-93d6-4fd0-ba88-438599730a66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.