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
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
---
- 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
Post a Comment