Ansible script to stop iptables and disable during boot
Step 1.
[root@cluster playbooks]# pwd
/root/playbooks
[root@cluster playbooks]# cat hosts
[webservers]
169.254.41.221
169.254.41.222
Step2.
[root@cluster playbooks]# cat iptables.yml
---
- name: stop ipatbles and disable
hosts: webservers
tasks:
- name: stop iptables
service: name=iptables state=stopped
- name: disbale on iptable on boot
service: name=iptables enabled=no
Step3:
[root@cluster playbooks]# ansible-playbook iptables.yml
PLAY [stop ipatbles and disable] ***********************************************
TASK [setup] *******************************************************************
ok: [169.254.41.222]
ok: [169.254.41.221]
ok: [localhost]
TASK [stop iptables] ***********************************************************
changed: [localhost]
ok: [169.254.41.221]
ok: [169.254.41.222]
TASK [disbale on iptable on boot] **********************************************
ok: [169.254.41.222]
changed: [localhost]
ok: [169.254.41.221]
PLAY RECAP *********************************************************************
169.254.41.221 : ok=3 changed=0 unreachable=0 failed=0
169.254.41.222 : ok=3 changed=0 unreachable=0 failed=0
localhost : ok=3 changed=2 unreachable=0 failed=0
Step 1.
[root@cluster playbooks]# pwd
/root/playbooks
[root@cluster playbooks]# cat hosts
[webservers]
169.254.41.221
169.254.41.222
Step2.
[root@cluster playbooks]# cat iptables.yml
---
- name: stop ipatbles and disable
hosts: webservers
tasks:
- name: stop iptables
service: name=iptables state=stopped
- name: disbale on iptable on boot
service: name=iptables enabled=no
Step3:
[root@cluster playbooks]# ansible-playbook iptables.yml
PLAY [stop ipatbles and disable] ***********************************************
TASK [setup] *******************************************************************
ok: [169.254.41.222]
ok: [169.254.41.221]
ok: [localhost]
TASK [stop iptables] ***********************************************************
changed: [localhost]
ok: [169.254.41.221]
ok: [169.254.41.222]
TASK [disbale on iptable on boot] **********************************************
ok: [169.254.41.222]
changed: [localhost]
ok: [169.254.41.221]
PLAY RECAP *********************************************************************
169.254.41.221 : ok=3 changed=0 unreachable=0 failed=0
169.254.41.222 : ok=3 changed=0 unreachable=0 failed=0
localhost : ok=3 changed=2 unreachable=0 failed=0
Comments
Post a Comment