Esteemed Collegues, I have created a Playbook to replcae the Entry in a 
file using a lineinfile module, while i tried running it run and replace in 
entry on the one host while not on the another host, i don't understand 
why? as it doesn't report any error even on the debug mode. Do i need to 
have some another regex pattern.

---
- name: Playbook to replace the line in file
  hosts: all
  remote_user: root
  gather_facts: False
  serial: 4
  tasks:
    - name: replace line
      lineinfile:
        dest: /tmp/test_master
        state: present
        regexp: '^passwd: files ldap' #  line to be replaced
        line: 'passwd_compat: ldap'   #  new line which is replace existing , 
the one above
        backrefs: yes
        backup: yes
      register: nss

    - name: replace line
      debug: var=nss



My Hostvar Inventory File:

# test_regex_hosts
[hosts]
Dev-mauj
Dev-pranjala
[hosts:vars]
ansible_ssh_user=root
ansible_ssh_private_key_file=/Dev/ansibleSpotin

Destination File contents:

$ cat /tmp/test_master
#
# nsswitch.conf
#
passwd: files ldap
shadow:     files ldap
group:      files ldap
hosts:      files dns
bootparams: files
ethers:     files
netmasks:   files ldap
networks:   files ldap
protocols:  files ldap
rpc:        files ldap
services:   files ldap
netgroup:   files ldap
publickey:  files ldap
automount:  files ldap
printers:   user files ldap
sudoers:    ldap
aliases:    files ldap

Note: ansible 2.4

-- 
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/6ab8d218-03d0-4fc5-bef4-98153772252b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to