-
Notifications
You must be signed in to change notification settings - Fork 1
/
playbook_test.yaml
56 lines (50 loc) · 1.17 KB
/
playbook_test.yaml
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
- name: Configure line in file
hosts: server
remote_user: centos
become: true
become_method: sudo
tasks:
- name: Security | Check if firewalld is installed
command: rpm -q firewalld
register: rpm_check
args:
warn: false
failed_when: no
changed_when: no
- name: Security | Execute command if firewalld is installed
service:
name: firewalld
state: started
enabled: yes
when: rpm_check.rc == 0
- name: Security | Add port to firewalld
become: yes
firewalld:
port: "{{ item }}"
permanent: yes
state: enabled
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
loop:
- 2048/tcp
- 2049/tcp
- 111/tcp
- name: Security | Make sure basic services can pass through firewall
become: yes
firewalld:
service: "{{ item }}"
permanent: true
state: enabled
with_items:
- nfs
- mountd
- rpc-bind
notify:
- restart firewalld
tags:
- nfs
- security
- name: Security | reload service firewalld
become: yes
systemd:
name: firewalld
state: reloaded