I have been working on this for days.  I don't mind because I am learning a 
ton of stuff (as I am new to ansible), but the only way I can get this to 
work properly is to use a shell: module (utilizing sed).  I would prefer to 
avoid that if I can.

Tasks:
  Gather list of ifcfg-* files (except ifcfg-lo)
  *Add DNS entries if missing; otherwise replace DNS entries if they don't 
match <string1> or <string2>*

- name: Gather list of ifcfg-* files
  shell: ls "{{ net_path }}" | grep ^ifcfg- | grep -ve ifcfg-lo -e \@ # \@ 
excludes ansible backup files
  register: ifcfg_list
  changed_when: false

The above works fine... it is the second task that is getting me.

Using the above I have tried all sorts of things.  I have learned that 
lineinfile regexp only matches the last found match, replace matches all.  
blockinfile also appears to only to affect the last found match.

Anyway, how would you approach this without shell:?

As an example:
I wish to use the following vars as my dns entries:
dns1=10.10.10.10
dns2=20.20.20.20

ifcfg-eth0 contains:
DNS1=1.2.3.4
DNS2=2.3.4.5

ifcfg-eth1 doesn't contain any dns entries


-- 
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/9c639ee9-ce16-44b7-8e3f-8f98d23f2eac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to