Ugh the one place I missed checking…thank you sir!
From: [email protected] <[email protected]> On Behalf Of Todd Lewis Sent: Sunday, March 5, 2023 8:41 PM To: [email protected] Subject: Re: [ansible-project] Template Module with_nested ? Your template file is apparently referencing "item.ORA_SID" instead of "item[0].ora_sid". -- Todd On Sun, Mar 5, 2023, 8:12 PM <[email protected] <mailto:[email protected]> > wrote: 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 <http://dmcinrfkdk17v.dmci-isf.com> ] (item=[{'file_name': 'DBcreate.j2', 'ext': 'sh'}, {'host': 'dmcinrfkdk17v.dmci-isf.com <http://dmcinrfkdk17v.dmci-isf.com> ', 'specific_ip': '192.168.1.46', 'specific_host': 'dmcinrfkdk17v.dmci-isf.com <http://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 <http://dmcinrfkdk17v.dmci-isf.com> ", "ora_sid": "Ansible", "specific_host": "dmcinrfkdk17v.dmci-isf.com <http://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 [email protected] <mailto:[email protected]> . To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/08eb01d94fc8%24b2d04f30%241870ed90%24%40gmail.com <https://groups.google.com/d/msgid/ansible-project/08eb01d94fc8%24b2d04f30%241870ed90%24%40gmail.com?utm_medium=email&utm_source=footer> . -- 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] <mailto:[email protected]> . To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAB6P987YEuRXwcKz7fqQixuPPnMjJqodk46vWOB90WdHsgA3ZA%40mail.gmail.com <https://groups.google.com/d/msgid/ansible-project/CAB6P987YEuRXwcKz7fqQixuPPnMjJqodk46vWOB90WdHsgA3ZA%40mail.gmail.com?utm_medium=email&utm_source=footer> . -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/08fa01d94fd3%249f750380%24de5f0a80%24%40gmail.com.
