On lørdag 26. august 2017 00.45.07 CEST John Harmon wrote:
> - name: Removing existing DNS entries from ifcfg-* files
>   lineinfile:
>     path: "{{ net_path }}{{ item }}"
>     backup: yes
>     state: absent
>     regexp: '^DNS'
>   with_items: "{{ ifcfg_list.stdout_lines }}"

<snip />

> - name: Update DNS in ifcfg files
>   blockinfile:
>     path: "{{ net_path }}{{ item }}"
>     marker: '# {mark} ANSIBLE MANAGED BLOCK -- Manual changes will be
> overwritten'
>     insertafter: EOF
>     block: |
>       DNS1="{{ dns1 }}"
>       DNS2="{{ dns2 }}"
>     with_items: "{{ ifcfg_list.stdout_lines }}"

Your indentation is wrong, with_items should be at the same level as 
blockinfile, just as you have in your with_items in the lineinfile.

When you fix that I still thing it will fail. Since the maker: is the same on 
every loop it will just replace the same section.
You would need to implement some kind of unique marker to make it work, one 
way is to incorporate the {{ item }}.

-- 
Kai Stian Olstad

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3361468.de5AWTZZ8t%40x1.
For more options, visit https://groups.google.com/d/optout.

Reply via email to