[ansible-project] update hots file - the default inventory file

2021-03-02 Thread esxi...@gmail.com
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

Re: [ansible-project] update hots file - the default inventory file

2021-03-02 Thread Abhijeet Kasurde
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"

Re: [ansible-project] update hots file - the default inventory file

2021-03-02 Thread esxi...@gmail.com
Thanks for the reply Abhi What i noticed is it does update the file if there is no entry like blow is the o/p TASK [Update the Inventory] *

Re: [ansible-project] update hots file - the default inventory file

2021-03-02 Thread esxi...@gmail.com
for eg [group1] server1 server2 [group2] server1 server2 if you remove from group one & run does not update So lineinfile should have someway to say the position exactly below [group1] add is missing ... On Tuesday, March 2, 2021 at 11:08:50 PM UTC-8 esxi...@gmail.com wrote: > Than

Re: [ansible-project] update hots file - the default inventory file

2021-03-03 Thread Vladimir Botka
On Tue, 2 Mar 2021 23:08:50 -0800 (PST) "esxi...@gmail.com" wrote: > but if the entry already present in more than 1 group say .. then it does > not update the file Try "ini_file", e.g. https://docs.ansible.com/ansible/latest/collections/community/general/ini_file_module.html - ini_file:

Re: [ansible-project] update hots file - the default inventory file

2021-03-03 Thread esxi...@gmail.com
Thanks Vladimir Botka On Wednesday, March 3, 2021 at 1:01:59 AM UTC-8 vbo...@gmail.com wrote: > On Tue, 2 Mar 2021 23:08:50 -0800 (PST) > "esxi...@gmail.com" wrote: > > > but if the entry already present in more than 1 group say .. then it > does > > not update the file > > Try "ini_file", e