-
Notifications
You must be signed in to change notification settings - Fork 1
/
CentOS7x_Convert-to-IPTables-playbook.yml
87 lines (65 loc) · 2.39 KB
/
CentOS7x_Convert-to-IPTables-playbook.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
################################################################################
# description: Converts CentOS7x from firewalld to iptables
# usage: ansible-playbook CentOS7x_Convert-to-IPTables-playbook.yml --extra-vars 'HostOrGroup=YourServerOrGroupNameGoesHere'
# author: Ernest G. Wilson II <ErnestGWilsonII@gmail.com> (https://github.com/ernestgwilsonii)
# license: MIT
################################################################################
# Ansible Playbook options
# REF: http://docs.ansible.com/ansible/playbooks.html
#####################################################
- name: Converts CentOS7x from firewalld to iptables
hosts: "{{ HostOrGroup|default ('FATAL ERROR --> HostOrGroup NOT SET! You must specify either a Host or a Group name!') }}"
serial: "100%"
gather_facts: False
tasks:
# Configure OS Services
# REF: http://docs.ansible.com/ansible/service_module.html
##########################################################
- name: Stop and disable firewalld
service:
name: firewalld
enabled: no
#state: stopped
# Install yum packages
# REF: http://docs.ansible.com/ansible/yum_module.html
######################################################
- name: Install iptables
yum:
name: iptables
state: latest
- name: Install iptables-services
yum:
name: iptables-services
state: latest
- name: Install bridge-utils
yum:
name: bridge-utils
state: latest
# brctl show
# Configure OS Services
# REF: http://docs.ansible.com/ansible/service_module.html
##########################################################
- name: Enable and start iptables
service:
name: iptables
enabled: yes
#state: started
# shell - Execute commands in nodes
# REF: http://docs.ansible.com/ansible/latest/shell_module.html
###############################################################
- name: Reboot
shell: sleep 2 && /usr/sbin/shutdown -r now "Rebooting for Ansible"
async: 1
poll: 0
ignore_errors: true
- name: Waiting for reboot to complete
wait_for_connection:
delay: 30
timeout: 300
# Execute command(s)
# REF: http://docs.ansible.com/ansible/command_module.html
##########################################################
- name: /usr/libexec/iptables/iptables.init save
command: /usr/libexec/iptables/iptables.init save
# cat /etc/sysconfig/iptables