-
Notifications
You must be signed in to change notification settings - Fork 137
/
freeradius.yml
210 lines (189 loc) · 6.66 KB
/
freeradius.yml
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
---
- name: Add freeradius repository into Ubuntu jammy sources list
# NOTE: The older version of openwisp.openwisp2 used to install
# FreeRADIUS 3.0.x on Ubuntu 22.04. After the release of
# Ubuntu 22.04.1, FreeRADIUS 3.0.x can no longer be installed.
# This block contains tasks that configures FreeRADIUS server
# on Ubuntu 22.04 in a backward compatible manner, i.e. if
# FreeRADIUS 3.0.x is installed on the VM, then the role will continue
# using FreeRADIUS 3.0.x. On new installations, FreeRADIUS 3.2.x
# will be used.
block:
- name: Check installed FreeRADIUS version
shell: >
which freeradius > /dev/null &&
freeradius -v | sed -n 2p | awk {'print $3'} |
awk -F '.' {'printf("%1s.%s", $1, $2)'}
ignore_errors: true
register: openwisp2_installed_freeradius_version
- name: Add FreeRADIUS 3.0.x repository to sources list
shell: >
echo "deb http://packages.networkradius.com/freeradius-3.0/ubuntu/focal focal main" |
tee /etc/apt/sources.list.d/networkradius.list > /dev/null
when: openwisp2_installed_freeradius_version.stdout == '3.0'
- name: Add FreeRADIUS 3.2.x repository to sources list
shell: >
echo "deb http://packages.networkradius.com/freeradius-3.2/ubuntu/jammy jammy main" |
tee /etc/apt/sources.list.d/networkradius.list > /dev/null
when: openwisp2_installed_freeradius_version.stdout != '3.0'
- name: Update freeradius_dir variable
set_fact:
freeradius_dir: '/etc/freeradius/3.0'
when: openwisp2_installed_freeradius_version.stdout == '3.0'
when:
- ansible_distribution|string == 'Ubuntu'
- ansible_distribution_release|string == 'jammy'
tags:
- molecule-idempotence-notest
- name: Add freeradius repository into Ubuntu focal sources list
shell: |
echo "deb http://packages.networkradius.com/freeradius-3.0/ubuntu/focal focal main" | \
tee /etc/apt/sources.list.d/networkradius.list > /dev/null
become: true
when:
- ansible_distribution|string == 'Ubuntu'
- ansible_distribution_release|string == 'focal'
tags:
- molecule-idempotence-notest
- name: Add freeradius repository into Ubuntu xenial sources list and Network RADIUS PGP public key
shell: |
echo "deb http://packages.networkradius.com/freeradius-3.0/ubuntu/xenial xenial main" | \
tee /etc/apt/sources.list.d/networkradius.list > /dev/null
curl -s 'https://packages.networkradius.com/pgp/packages%40networkradius.com' | \
sudo apt-key add -
become: true
when:
- ansible_distribution|string == 'Ubuntu'
- ansible_distribution_release|string == 'xenial'
tags:
- molecule-idempotence-notest
- name: Add freeradius repository into Debian bullseye sources list
shell: |
echo "deb http://packages.networkradius.com/freeradius-3.0/debian/bullseye bullseye main" | \
sudo tee /etc/apt/sources.list.d/networkradius.list > /dev/null
become: true
when:
- ansible_distribution|string == 'Debian'
- ansible_distribution_release|string == 'bullseye'
tags:
- molecule-idempotence-notest
- name: Add freeradius repository into Debian stretch sources list
shell: |
echo "deb http://packages.networkradius.com/freeradius-3.0/debian/stretch stretch main" | \
sudo tee /etc/apt/sources.list.d/networkradius.list > /dev/null
become: true
when:
- ansible_distribution|string == 'Debian'
- ansible_distribution_release|string == 'stretch'
tags:
- molecule-idempotence-notest
- name: Add Network RADIUS PGP public key
become: true
shell: |
curl -s 'https://packages.networkradius.com/pgp/packages%40networkradius.com' | \
tee /etc/apt/trusted.gpg.d/packages.networkradius.com.asc > /dev/null
when:
- ansible_distribution|string == 'Ubuntu' or ansible_distribution|string == 'Debian'
- ansible_distribution_release|string != 'xenial'
tags:
- molecule-idempotence-notest
- name: Update and upgrade apt packages
apt:
upgrade: true
update_cache: true
- name: Freeradius system packages
apt:
name:
- freeradius-rest
state: latest
notify: Restart freeradius
- name: Freeradius postgres packages
when: freeradius_sql.dialect == "postgresql"
apt:
name: freeradius-postgresql
state: latest
notify: Restart freeradius
- name: Freeradius mysql packages
when: freeradius_sql.dialect == "mysql"
apt:
name: freeradius-mysql
state: latest
notify: Restart freeradius
- name: SQL configuration
template:
src: freeradius/sql.j2
dest: "{{ freeradius_mods_available_dir }}/sql"
mode: 0640
owner: freerad
group: freerad
notify: Restart freeradius
- name: Enable SQL module
file:
src: "{{ freeradius_mods_available_dir }}/sql"
dest: "{{ freeradius_mods_enabled_dir }}/sql"
state: link
mode: 0640
owner: freerad
group: freerad
- name: Add plus sign to safe characters
lineinfile:
path: "{{ freeradius_mods_config_dir }}/sql/main/{{ freeradius_sql.dialect }}/queries.conf"
regexp: "^(.*)safe_characters =(.*)$"
line: 'safe_characters = "{{ freeradius_safe_characters }}"'
state: present
notify: Restart freeradius
- name: Adding user 'freerad' to www-data group for database access
when: freeradius_sql.dialect == "sqlite"
user:
name: freerad
groups: www-data
append: true
- name: Add Attributes to freeradius dictionary
lineinfile:
path: "{{ freeradius_dir }}/dictionary"
line: "ATTRIBUTE Expire-After {{ freeradius_expire_attr_after_seconds }} integer"
- name: REST configuration
template:
src: freeradius/rest.j2
dest: "{{ freeradius_mods_available_dir }}/rest"
mode: 0640
owner: freerad
group: freerad
notify: Restart freeradius
- name: Enable REST module
file:
src: "{{ freeradius_mods_available_dir }}/rest"
dest: "{{ freeradius_mods_enabled_dir }}/rest"
state: link
mode: 0640
owner: freerad
group: freerad
- name: Remove default site
file:
dest: "{{ item }}"
state: absent
with_items:
- "{{ freeradius_sites_enabled_dir }}/default"
- name: Site configuration
template:
src: "{{ freeradius_openwisp_site_template_src }}"
dest: "{{ freeradius_sites_enabled_dir }}/openwisp_site"
mode: 0640
owner: freerad
group: freerad
notify: Restart freeradius
- name: Inner tunnel
template:
src: freeradius/inner_tunnel.j2
dest: "{{ freeradius_sites_enabled_dir }}/inner-tunnel"
mode: 0640
owner: freerad
group: freerad
notify: Restart freeradius
- name: Copy configuration for WPA Enterprise TTLS
include_tasks: tasks/freeradius_eap.yml
loop: "{{ freeradius_eap_orgs }}"
loop_control:
loop_var: org
when: freeradius_eap_orgs
tags: [freeradius_eap]