aboutsummaryrefslogtreecommitdiffstats
path: root/roles/space_server/tasks/radius.yml
blob: 614d1b76de77ab8a3e0cd9566c7b6745ba062bb2 (plain) (blame)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
---
#
# configuration
#
- name: Configure radiusd
  copy:
    dest: '/etc/raddb/{{ item }}'
    src: 'radius/{{ item }}'
    owner: root
    group: radiusd
    mode: 0640
  with_items:
  - radiusd.conf
  - mods-available/eap
  - mods-available/python3-assha
  - sites-available/labitat
  - sites-available/labitat-inner
  notify:
  - restart radiusd

- name: Create assha python script
  copy:
    dest: '/etc/raddb/mods-config/python3/assha.py'
    src: 'radius/assha.py'
    owner: root
    group: root
    mode: 0755
  notify:
  - restart radiusd

- name: Configure radius clients
  template:
    dest: '/etc/raddb/clients.conf'
    src: radius/clients.conf.j2
    owner: root
    group: radiusd
    mode: 0640
  notify:
  - restart radiusd

- name: Configure radius sites
  file:
    path: '/etc/raddb/sites-enabled/{{ item.name }}'
    src: "{{ (item.state == 'link')|ternary('../sites-available/' + item.name,omit) }}"
    state: '{{ item.state }}'
    owner: root
    group: radiusd
    follow: no
    force: yes
  with_items:
  - { name: default,       state: absent }
  - { name: inner-tunnel,  state: absent }
  - { name: labitat,       state: link }
  - { name: labitat-inner, state: link }
  notify:
  - restart radiusd

- name: Configure radius modules
  file:
    path: '/etc/raddb/mods-enabled/{{ item.name }}'
    src: "{{ (item.state == 'link')|ternary('../mods-available/' + item.name,omit) }}"
    state: '{{ item.state }}'
    owner: root
    group: radiusd
    follow: no
    force: yes
  with_items:
  - { name: files,         state: absent }
  - { name: python3-assha, state: link }
  notify:
  - restart radiusd

#
# getusers.sh
#
- name: Create getusers script
  template:
    dest: '/etc/raddb/getusers.sh'
    src: radius/getusers.sh.j2
    owner: root
    group: radiusd
    mode: 0750

- name: Create getusers service and timer
  copy:
    dest: '/etc/systemd/system/{{ item }}'
    src: 'radius/{{ item }}'
    owner: root
    group: root
    mode: 0644
  with_items:
  - getusers.service
  - getusers.timer
  notify:
  - restart getusers

- name: Enable getusers timer
  systemd:
    name: getusers.timer
    enabled: yes
    masked: no
    state: started
  when: not chroot
- name: '- when in chroot'
  command: systemctl enable getusers.timer
  args:
    creates: '/etc/systemd/system/timers.target.wants/getusers.timer'
  when: chroot

#
# certificates
#
- name: Configure /etc/raddb/certs/passwords.mk
  replace:
    path: '/etc/raddb/certs/passwords.mk'
    regexp: '^CA_DEFAULT_DAYS( *= *).*$'
    replace: "CA_DEFAULT_DAYS\\1'3652'"
  tags: radius-certs

- name: Configure /etc/raddb/certs/ca.cnf
  ini_file:
    path: '/etc/raddb/certs/ca.cnf'
    section: "{{ item.key.split('.',1)[0] }}"
    option:  "{{ item.key.split('.',1)[1] }}"
    value:   "{{ (item.value is string)|ternary(item.value,omit) }}"
    state:   "{{ (item.value is string)|ternary('present','absent') }}"
  with_dict:
    ' CA_default .default_days': '3652'
    'certificate_authority.countryName': 'DK'
    'certificate_authority.stateOrProvinceName': 'Copenhagen'
    'certificate_authority.localityName': 'Frederiksberg'
    'certificate_authority.organizationName': 'Labitat'
    'certificate_authority.emailAddress': 'noc@labitat.dk'
    'certificate_authority.commonName': '"Labitat Network Infrastructure CA"'
  tags: radius-certs

- name: Configure /etc/raddb/certs/server.cnf
  ini_file:
    path: '/etc/raddb/certs/server.cnf'
    section: "{{ item.key.split('.',1)[0] }}"
    option:  "{{ item.key.split('.',1)[1] }}"
    value:   "{{ (item.value is string)|ternary(item.value,omit) }}"
    state:   "{{ (item.value is string)|ternary('present','absent') }}"
  with_dict:
    ' CA_default .default_days': '731'
    'server.countryName': 'DK'
    'server.stateOrProvinceName': 'Copenhagen'
    'server.localityName': 'Frederiksberg'
    'server.organizationName': 'Labitat'
    'server.emailAddress': 'noc@labitat.dk'
    'server.commonName': '"Labitat Radius Authentication 2020"'
  tags: radius-certs

- name: Configure /etc/raddb/certs/inner-server.cnf
  ini_file:
    path: '/etc/raddb/certs/inner-server.cnf'
    section: "{{ item.key.split('.',1)[0] }}"
    option:  "{{ item.key.split('.',1)[1] }}"
    value:   "{{ (item.value is string)|ternary(item.value,omit) }}"
    state:   "{{ (item.value is string)|ternary('present','absent') }}"
  with_dict:
    ' CA_default .default_days': '731'
    'server.countryName': 'DK'
    'server.stateOrProvinceName': 'Copenhagen'
    'server.localityName': 'Frederiksberg'
    'server.organizationName': 'Labitat'
    'server.emailAddress': 'noc@labitat.dk'
    'server.commonName': '"Labitat Radius Inner Server Certificate 2020"'
  tags: radius-certs

- name: Configure /etc/raddb/certs/client.cnf
  ini_file:
    path: '/etc/raddb/certs/client.cnf'
    section: "{{ item.key.split('.',1)[0] }}"
    option:  "{{ item.key.split('.',1)[1] }}"
    value:   "{{ (item.value is string)|ternary(item.value,omit) }}"
    state:   "{{ (item.value is string)|ternary('present','absent') }}"
  with_dict:
    ' CA_default .default_days': '365'
    'client.countryName': 'DK'
    'client.stateOrProvinceName': 'Copenhagen'
    'client.localityName': 'Frederiksberg'
    'client.organizationName': 'Labitat'
  tags: radius-certs

#
# radiusd.service
#
- name: Create service drop-in directory
  file:
    dest: '/etc/systemd/system/radiusd.service.d'
    state: directory
    owner: root
    group: root
    mode: 0755

- name: Start radiusd after networks are configured
  copy:
    dest: '/etc/systemd/system/radiusd.service.d/wait-online.conf'
    src: wait-online.conf
    owner: root
    group: root
    mode: 0644

- name: Set PYTHONPATH for radiusd
  copy:
    dest: '/etc/systemd/system/radiusd.service.d/pythonpath.conf'
    src: 'radius/pythonpath.conf'
    owner: root
    group: root
    mode: 0644

- name: Enable radiusd service
  systemd:
    name: radiusd.service
    enabled: yes
    masked: no
    state: started
  when: not chroot
- name: '- when in chroot'
  command: systemctl enable radiusd.service
  args:
    creates: '/etc/systemd/system/multi-user.target.wants/radiusd.service'
  when: chroot

# vim: set ts=2 sw=2 et: