From: Best way to launch aws ec2 instances with ansible
- name: Add the newly created EC2 instance(s) to the local host group (located inside the directory)
local_action: lineinfile
dest="/etc/ansibles/aws/hosts"
regexp={{ item.private_ip }}
insertafter="[webserver]" line={{ item.private_ip }}
with_items: "{{ ec2.instances }}"
creates this error:
fatal: [localhost]: FAILED! => { "failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'ansible.vars.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'private_ip'\n\n
I have defined variable private_ip: under vars , with a value