Hello Guys,

 Can someone please help me to resolve this issue.

below playbook i have created to remove dns entries from resolv.conf and 
its working perfect on rhel 6 but not in rhel 7.6, is there any bug or i 
need to add any parameters ?




*Playbook :- blockinfile*
---
- hosts: TC2
  become: yes
  tasks:
 - name: remove block regexps
    blockinfile:
      path: /etc/resolv.conf
      marker: "{mark}"
      marker_begin: "nameserver 13.2.7.8 "
      block: |
         nameserver 13.2.7.9  
         nameserver 13.2.7.10
      marker_end: "search eu.ro.net mrtools.ro.com mit.gbr.ro.com"
      state: absent
      backup: yes

*Playbook :- lineinfile*
---
- hosts: TC2
  become: yes
  tasks:
  - name: copy the file
    shell: cp -p /etc/resolv.conf /tmp/resolv.conf.$(date +%F_%R)
  - name: remove block lines
    lineinfile:
      dest: /etc/resolv.conf
      regexp: "{{ item.line }}"
      state: absent
    with_items:
      - { line: 'nameserver 13.2.7.8' }
      - { line: 'nameserver 13.2.7.9' }
      - { line: 'nameserver 13.2.7.10' }
      - { line: 'search eu.ro.net mrtools.ro.com mit.gbr.ro.com' }



*Client server:-*

Hostname: testmachine
 Distro:   [redhat-release] Red Hat Enterprise Linux Server release 7.6 
(Maipo)
           [os-release] Red Hat Enterprise Linux 7.6 (Maipo)
Booted kernel:  3.10.0-957.1.3.el7.x86_64

*ansible control node:-*
ansible 2.7.7
  config file = /etc/ansible/ansible.cfg
  configured module search path = 
[u'/home/q5c9nf32/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Sep 12 2018, 05:31:16) [GCC 4.8.5 
20150623 (Red Hat 4.8.5-36)]



Thanks,
Deepan M

-- 
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/22307c24-d481-48ad-9208-472f2f1a114f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to