ansible lineinfile selinux changes to /etc/hosts file

vi /etc/selinux/config

SELINUX=disabled
---
- hosts: localhost
  tasks:
  - lineinfile:
      path: /etc/selinux/config
      regexp: '^SELINUX='
      line: 'SELINUX=enforcing'

~                           


[root@localhost ~]# ansible-playbook hosts.yml

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

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

TASK [lineinfile] **************************************************************
changed: [localhost]

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


[root@localhost ~]# cat /etc/selinux/config


SELINUX=enforcing

[root@localhost ~]# cat /etc/hosts
192.168.0.105 checkmk

[root@localhost ~]# cat hosts.yml
---
- hosts: localhost
  tasks:
  - lineinfile:
      path: /etc/selinux/config
      regexp: '^SELINUX='
      line: 'SELINUX=enforcing'
  - lineinfile:
      path: /etc/hosts
      regexp: '^192\.168\.0\.105'
      line: '192.168.0.105 localhost'
      owner: root
      group: root
      mode: 0644
[root@localhost ~]# ansible-playbook hosts.yml

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

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

TASK [lineinfile] **************************************************************
ok: [localhost]

TASK [lineinfile] **************************************************************
changed: [localhost]

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


Comments

Popular posts from this blog

ansible redhat cluster qorum qdevice

PE 3.9.0 on centos 6

gfs2 cluster