aboutsummaryrefslogtreecommitdiffstats
path: root/tasks/network.yml
blob: f0b545b936bcf9be55d053dfc22e75b984529a2a (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
- 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: Install nginx
  package:
    name: nginx
    state: present

- 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: 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