aboutsummaryrefslogtreecommitdiffstats
path: root/tasks/network.yml
blob: d68344d4b86091c70321f862b441b828eeef8b8c (plain)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
- name: Set up resolv.conf
  template:
    src: etc_resolv.conf.j2
    dest: /etc/resolv.conf
    owner: root
    group: wheel
    mode: "0644"
  register: resolv_conf

- name: Restart networking if interface configuration changed
  shell: service netif restart && service routing restart
  when: rc_conf.changed or resolv_conf.changed

- name: Set up sshd
  template:
    src: etc_ssh_sshd_config.j2
    dest: /etc/ssh/sshd_config
    owner: root
    group: wheel
    mode: "0644"
  register: etc_sshd_config

- name: Start sshd
  service:
    name: sshd
    state: started
  register: started_sshd

- name: Restart sshd
  service:
    name: sshd
    state: restarted
  when: not started_sshd.changed and etc_sshd_config.changed

- name: Start syslogd
  service:
    name: syslogd
    state: started
  register: started_syslogd

- name: Restart syslogd
  service:
    name: syslogd
    state: restarted
  when: not started_syslogd.changed and rc_conf.changed

- name: Configure pf
  template:
    src: etc_pf.conf.j2
    dest: /etc/pf.conf
    owner: root
    group: wheel
    mode: "0644"
    backup: yes
  register: pf_conf

- name: Start pf
  service:
    name: pf
    state: started

- name: Reload pf rules
  shell: pfctl -f /etc/pf.conf
  when: pf_conf.changed

- name: Configure nginx.conf
  template:
    src: usr_local_etc_nginx_nginx.conf.j2
    dest: /usr/local/etc/nginx/nginx.conf
    owner: root
    group: wheel
    mode: "0644"
  register: nginx_conf

- name: Copy over jan.systems HTML
  ansible.posix.synchronize:
    src: "{{ jan_systems_html_dir.rstrip('/') + '/' }}"
    dest: /usr/local/www/jan.systems

- name: Start nginx
  service:
    name: nginx
    state: started
  register: started_nginx

- name: Restart nginx
  service:
    name: nginx
    state: restarted
  when: not started_nginx.changed and nginx_conf.changed

- name: Set up restore_jail_aliases.sh
  template:
    src: usr_local_bin_restore_jail_aliases.sh.j2
    dest: /usr/local/bin/restore_jail_aliases.sh
    owner: root
    group: wheel
    mode: "0755"

- name: Set up devd lan0_jail_restore.conf
  template:
    src: etc_devd_lan0_jail_restore.conf.j2
    dest: /etc/devd/lan0_jail_restore.conf
    owner: root
    group: wheel
    mode: "0644"