Repository navigation
Expand file tree
/
Copy pathapplyFirewall.yml
More file actions
71 lines (61 loc) · 1.56 KB
/
Copy pathapplyFirewall.yml
File metadata and controls
71 lines (61 loc) · 1.56 KB
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
# Setup firewall on all services
#
# This playbook can be used to refresh all the firewall rules on all the (non-jumphost)
# servers. It will only allow HTTPS traffic from Myra to port 443, and SSH traffic from
# the jump hosts.
- hosts:
- service
- rsync
become: yes
become_user: root
gather_facts: true
tasks:
- name: Gather facts for service hosts
setup:
gather_subset:
- default_ipv4
delegate_to: "{{ item }}"
delegate_facts: true
loop: "{{ groups['service'] }}"
- name: Gather facts for jumphosts
setup:
gather_subset:
- default_ipv4
delegate_to: "{{ item }}"
delegate_facts: true
loop: "{{ groups['jumphost'] }}"
- name: Install ufw and tools
apt:
name:
- ufw
- jq
- curl
- xxd
- cron
state: present
update_cache: yes
- name: Create box dir to store firewall script's downloaded data
file:
state: directory
dest: "{{ box_dir }}"
mode: 0755
owner: "root"
- name: Create firewall script
template:
dest: /local/systems/firewall.sh
src: roles/firewall/templates/update-firewall.sh
mode: '755'
- name: Add /usr/sbin to PATH so that UFW can be found
cron:
name: PATH
env: yes
job: /usr/sbin:/usr/bin:/bin
- name: Set up daily cron to refresh the firewall rules
cron:
name: "Daily firewall refresh"
job: /local/systems/firewall.sh
special_time: daily
state: present
- name: Run firewall refresh script
command:
cmd: /local/systems/firewall.sh