Can you provide output of lineinfile ? Mine look like
changed: [localhost] => (item=a) => {"ansible_loop_var": "item", "backup":
"", "changed": true, "item": "a", "msg": "line added"}
changed: [localhost] => (item=b) => {"ansible_loop_var": "item", "backup":
"", "changed": true, "item": "b", "msg": "line added"}
On Wed, Mar 3, 2021 at 10:14 AM [email protected] <[email protected]>
wrote:
> Hi
>
> I have a playbook which create the vm in vCenter
> ---
> - hosts: localhost
> gather_facts: false
> connection: local
> vars_files:
> - ./vars/xxx.yml
>
> tasks:
>
>
> - name: Create VM using template
> vmware_guest:
> hostname: "{{ vcenter_server }}"
> username: "{{ vcenter_user }}"
> password: "{{ vcenter_pass }}"
> datacenter: "{{ vcenter_datacenter }}"
> cluster: "{{ vcenter_cluster }}"
> template: "{{ vcenter_template }}"
> ..
> hostname: "{{ item }}"
> with_items: "{{ servers }}"
>
>
>
>
> - name: Update the Inventory
> lineinfile:
> dest: /etc/ansible/hosts
> insertafter: '^\[MyServers\]'
> line: '{{ item }}'
> with_items: "{{ servers }}"
> run_once: true
>
>
>
> VM create works well, Any suggestions why the the hosts file is not
> getting updated .. above is the code
>
> Thanks
>
> --
> 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/542ded49-eab9-4fbf-8faa-2ba91bc3517en%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/542ded49-eab9-4fbf-8faa-2ba91bc3517en%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
Thanks,
Abhijeet Kasurde
--
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/CAFwWkHq7XXavfZyH5PPzvfeSp2NntJuGkwbgusn_3scFA8tEwQ%40mail.gmail.com.