On Thursday, 25 January 2018 18.38.36 CET John Harmon wrote:
> How do I incorporate: 
> "{{ ifcfg_list.stdout_lines }}"
> 
> That allows me to loop through all ifcfg-* files (except ifcfg-lo)
> 
> - name: Add DNS to ifcfg-* files if missing
>   lineinfile:
>     path: "{{ net_path }}{{ item.nic }}" #<--- This item is no longer 
> reference by ifcfg_list.stdout_lines
>     state: present
>     regexp: "{{ item.regexp }}"
>     line: "{{ item.line }}"
>   with_items:
>     - {regexp: "^DNS1", line: "DNS1={{ dns1 }}", nic: 
> "ifcfg_list.stdout_lines"} #<--- The nic section of these looks incorrect 
> to me, and I doubt it would work
>     - {regexp: "^DNS2", line: "DNS2={{ dns2 }}", nic: 
> "ifcfg_list.stdout_lines"}
>   ignore_errors: yes
>   notify:
>     - Networking

Use the find module to search for the files and exclude the ifcfg-lo and 
register the result.

Then you can use the with_nested in the lineinfile.


-- 
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/1754647.NzOEYWReNb%40x1.
For more options, visit https://groups.google.com/d/optout.

Reply via email to