I have no clue why the template module fails and the shell works with the nested items. I don’t have 'ORA_SID' any place but it keeps saying its ansible.errors.AnsibleUndefinedVariable, any ideas on this one would be welcome. Thanks
Plays:
- name: test running the shell - Works
ansible.builtin.shell: touch /tmp/{{ item.0.file_name | replace('.j2', '') }}_{{ item.1.ora_sid }}.{{ item.0.ext }}
with_nested:
- "{{ db_create_files }}"
- "{{ specific_hosts_conf }}"
when: inventory_hostname == item.1.host
- name: test with template with nested item – DOES NOT WORK
template:
src: "{{ item.0.file_name }}"
dest: "/tmp/{{ item.0.file_name | replace('.j2', '') }}_{{ item.1.ora_sid }}.{{ item.0.ext }}"
with_nested:
- "{{ db_create_files }}"
- "{{ specific_hosts_conf }}"
when: inventory_hostname == item.1.host
Vars file:
specific_hosts_conf:
- { host: 'nrfkdk17v.test.local', specific_ip: '192.168.1.46', specific_host: 'nrfkdk17v.test.local nrfkdk17v', ora_sid: 'Ansible'}
db_create_files:
- { file_name: 'DBcreate.j2', ext: 'sh'}
Error:
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: 'list object' has no attribute 'ORA_SID'. 'list object' has no attribute 'ORA_SID'
failed: [dmcinrfkdk17v.dmci-isf.com] (item=[{'file_name': 'DBcreate.j2', 'ext': 'sh'}, {'host': 'dmcinrfkdk17v.dmci-isf.com', 'specific_ip': '192.168.1.46', 'specific_host': 'dmcinrfkdk17v.dmci-isf.com nrfkdk17v', 'ora_sid': 'Ansible'}]) => {
"ansible_loop_var": "item",
"changed": false,
"item": [
{
"ext": "sh",
"file_name": "DBcreate.j2"
},
{
"host": "dmcinrfkdk17v.dmci-isf.com",
"ora_sid": "Ansible",
"specific_host": "dmcinrfkdk17v.dmci-isf.com nrfkdk17v",
"specific_ip": "192.168.1.46"
}
]
}
MSG:
AnsibleUndefinedVariable: 'list object' has no attribute 'ORA_SID'. 'list object' has no attribute 'ORA_SID'
--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/08eb01d94fc8%24b2d04f30%241870ed90%24%40gmail.com.
Ugh the one place I missed checking…thank you sir!
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAB6P987YEuRXwcKz7fqQixuPPnMjJqodk46vWOB90WdHsgA3ZA%40mail.gmail.com.