I'm finally home
Sorry the previous regexp was completely incorrect. Now I fixed it with a 
couple of tests.. 
And here it is

fusillator@catorcio:~/Code/ansible/test$ cat blockinfile.yml 
- hosts: localhost
  tasks:
  - name: sort out blank discrepancy
    replace:
      path: resolv.conf
      regexp: '^nameserver\s+([^ ]+)\s+#(.*)'
      replace: 'nameserver \1 #\2'
      backup: yes
  - name: remove block regexps
    blockinfile:
      path: "./resolv.conf"
      marker: "{mark}"
      marker_begin: "nameserver 13.2.7.8 # dns1"
      marker_end: "search eu.ro.net mrtools.ro.com mit.gbr.ro.com"
      state: absent
fusillator@catorcio:~/Code/ansible/test$ cat resolv.conf 
nameserver 8.8.8.8
nameserver 13.2.7.8     # dns1
nameserver 13.2.7.9     # dns2
nameserver 13.2.7.10    # dns3
search eu.ro.net mrtools.ro.com mit.gbr.ro.com
fusillator@catorcio:~/Code/ansible/test$ ansible-playbook blockinfile.yml 

PLAY [localhost] 
**************************************************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] 
********************************************************************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [sort out blank discrepancy] 
*********************************************************************************************************************************************************************************************************************************************
changed: [localhost]

TASK [remove block regexps] 
***************************************************************************************************************************************************************************************************************************************************
changed: [localhost]

PLAY RECAP 
********************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=3    changed=2    unreachable=0    
failed=0   

fusillator@catorcio:~/Code/ansible/test$ cat resolv.conf 
nameserver 8.8.8.8

Regards 

Luca

-- 
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/4644f599-b354-4e88-a5a7-67af8b3eff94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to