-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] Added openwisp_radius installation
- Loading branch information
Showing
11 changed files
with
374 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
|
||
# TODO: I want to use mysql! | ||
- name: Freeradius system packages | ||
when: openwisp2_radius | ||
apt: | ||
name: | ||
- freeradius | ||
- freeradius-postgresql | ||
- freeradius-rest | ||
state: latest | ||
notify: restart freeradius | ||
|
||
- name: SQL Configuration | ||
when: openwisp2_radius | ||
template: | ||
src: freeradius/sql.j2 | ||
dest: "{{ freeradius_mods_available_dir }}/sql" | ||
mode: 0640 | ||
owner: freerad | ||
group: freerad | ||
notify: restart freeradius | ||
|
||
- name: Enable SQL module | ||
when: openwisp2_radius | ||
file: | ||
src: "{{ freeradius_mods_available_dir }}/sql" | ||
dest: "{{ freeradius_mods_enabled_dir }}/sql" | ||
state: link | ||
mode: 0640 | ||
owner: freerad | ||
group: freerad | ||
|
||
- name: SQL Counter module | ||
when: openwisp2_radius | ||
template: | ||
src: freeradius/sqlcounter.j2 | ||
dest: "{{ freeradius_mods_available_dir }}/sqlcounter" | ||
mode: 0640 | ||
owner: freerad | ||
group: freerad | ||
notify: restart freeradius | ||
|
||
- name: Enable SQL Counter module | ||
when: openwisp2_radius | ||
file: | ||
src: "{{ freeradius_mods_available_dir }}/sqlcounter" | ||
dest: "{{ freeradius_mods_enabled_dir }}/sqlcounter" | ||
state: link | ||
mode: 0640 | ||
owner: freerad | ||
group: freerad | ||
|
||
- name: Fix dailycounter.conf | ||
when: openwisp2_radius | ||
copy: | ||
src: freeradius/dailycounter.conf | ||
dest: "{{ freeradius_dir }}/mods-config/sql/counter/postgresql/dailycounter.conf" | ||
mode: 0640 | ||
owner: freerad | ||
group: freerad | ||
notify: restart freeradius | ||
|
||
- name: REST Configuration | ||
when: openwisp2_radius | ||
template: | ||
src: freeradius/rest.j2 | ||
dest: "{{ freeradius_mods_available_dir }}/rest" | ||
mode: 0640 | ||
owner: freerad | ||
group: freerad | ||
notify: restart freeradius | ||
|
||
- name: Enable REST module | ||
when: openwisp2_radius | ||
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 | ||
when: openwisp2_radius | ||
file: | ||
dest: "{{ freeradius_sites_enabled_dir }}/default" | ||
state: absent | ||
|
||
- name: Ensure inner-tunnel site is present | ||
when: openwisp2_radius | ||
file: | ||
src: "{{ freeradius_sites_available_dir }}/inner-tunnel" | ||
dest: "{{ freeradius_sites_enabled_dir }}/inner-tunnel" | ||
state: link | ||
mode: 0640 | ||
owner: freerad | ||
group: freerad | ||
|
||
- name: Captive portal configuration | ||
when: openwisp2_radius | ||
template: | ||
src: freeradius/captiveportal.j2 | ||
dest: "{{ freeradius_sites_available_dir }}/captiveportal" | ||
mode: 0640 | ||
owner: freerad | ||
group: freerad | ||
notify: restart freeradius | ||
|
||
- name: Captive portal to sites_enabled | ||
when: openwisp2_radius | ||
file: | ||
src: "{{ freeradius_sites_available_dir }}/captiveportal" | ||
dest: "{{ freeradius_sites_enabled_dir }}/captiveportal" | ||
state: link | ||
mode: 0640 | ||
owner: freerad | ||
group: freerad | ||
notify: restart freeradius | ||
tags: [radius] | ||
|
||
# openwisp-radius cron jobs | ||
- name: delete_old_radacct | ||
when: openwisp2_radius | ||
cron: | ||
name: delete_old_radacct | ||
day: "*" | ||
hour: 05 | ||
minute: 30 | ||
job: "/opt/openwisp2/env/bin/python /opt/openwisp2/manage.py delete_old_radacct 730" | ||
tags: [openwisp2, radius] | ||
|
||
- name: delete_old_postauth | ||
when: openwisp2_radius | ||
cron: | ||
name: delete_old_postauth | ||
day: "*" | ||
hour: 05 | ||
minute: 0 | ||
job: "/opt/openwisp2/env/bin/python /opt/openwisp2/manage.py delete_old_postauth 365" | ||
tags: [openwisp2, radius] | ||
|
||
- name: cleanup_stale_radacct | ||
when: openwisp2_radius | ||
cron: | ||
name: cleanup_stale_radacct | ||
day: "*" | ||
hour: 04 | ||
minute: 0 | ||
job: "/opt/openwisp2/env/bin/python /opt/openwisp2/manage.py cleanup_stale_radacct 1" | ||
tags: [openwisp2, radius] | ||
|
||
- name: deactivate_expired_users | ||
when: openwisp2_radius | ||
cron: | ||
name: deactivate_expired_users | ||
day: "*" | ||
hour: "*" | ||
minute: "*/5" | ||
job: "/opt/openwisp2/env/bin/python /opt/openwisp2/manage.py deactivate_expired_users" | ||
tags: [openwisp2, radius] | ||
|
||
- name: delete_old_users | ||
when: openwisp2_radius | ||
cron: | ||
name: delete_old_users | ||
day: "*" | ||
hour: "03" | ||
minute: "30" | ||
job: "/opt/openwisp2/env/bin/python /opt/openwisp2/manage.py delete_old_users" | ||
tags: [openwisp2, radius] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
rest { | ||
tls = {} | ||
connect_uri = "{{ inventory_hostname }}" | ||
authorize { | ||
uri = "${..connect_uri}/api/v1/authorize/" | ||
method = 'post' | ||
body = 'json' | ||
data = '{"username": "%{User-Name}", "password": "%{User-Password}"}' | ||
tls = ${..tls} | ||
} | ||
|
||
# this section can be left empty | ||
authenticate {} | ||
|
||
post-auth { | ||
uri = "${..connect_uri}/api/v1/postauth/" | ||
method = 'post' | ||
body = 'json' | ||
data = '{"username": "%{User-Name}", "password": "%{User-Password}", "reply": "%{reply:Packet-Type}", "called_station_id": "%{Called-Station-ID}", "calling_station_id": "%{Calling-Station-ID}"}' | ||
tls = ${..tls} | ||
} | ||
|
||
accounting { | ||
uri = "${..connect_uri}/api/v1/accounting/" | ||
method = 'post' | ||
body = 'json' | ||
data = '{"status_type": "%{Acct-Status-Type}", "session_id": "%{Acct-Session-Id}", "unique_id": "%{Acct-Unique-Session-Id}", "username": "%{User-Name}", "realm": "%{Realm}", "nas_ip_address": "%{NAS-IP-Address}", "nas_port_id": "%{NAS-Port}", "nas_port_type": "%{NAS-Port-Type}", "session_time": "%{Acct-Session-Time}", "authentication": "%{Acct-Authentic}", "input_octets": "%{Acct-Input-Octets}", "output_octets": "%{Acct-Output-Octets}", "called_station_id": "%{Called-Station-Id}", "calling_station_id": "%{Calling-Station-Id}", "terminate_cause": "%{Acct-Terminate-Cause}", "service_type": "%{Service-Type}", "framed_protocol": "%{Framed-Protocol}", "framed_ip_address": "%{Framed-IP-Address}"}' | ||
tls = ${..tls} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
sql { | ||
driver = "{{ freeradius_sql.driver }}" | ||
dialect = "{{ freeradius_sql.dialect }}" | ||
radius_db = "host={{ freeradius_sql.host }} port={{ freeradius_sql.port }} dbname={{ freeradius_sql.dbname }} user={{ freeradius_sql.user }} password={{ freeradius_sql.password }}" | ||
acct_table1 = "radacct" | ||
acct_table2 = "radacct" | ||
postauth_table = "radpostauth" | ||
authcheck_table = "radcheck" | ||
groupcheck_table = "radgroupcheck" | ||
authreply_table = "radreply" | ||
groupreply_table = "radgroupreply" | ||
usergroup_table = "radusergroup" | ||
delete_stale_sessions = yes | ||
client_table = "nas" | ||
group_attribute = "SQL-Group" | ||
$INCLUDE ${modconfdir}/${.:name}/main/${dialect}/queries.conf | ||
pool { | ||
start = ${thread[pool].start_servers} | ||
min = ${thread[pool].min_spare_servers} | ||
max = ${thread[pool].max_servers} | ||
spare = ${thread[pool].max_spare_servers} | ||
uses = 0 | ||
retry_delay = 30 | ||
lifetime = 0 | ||
idle_timeout = 60 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# The dailycounter is included by default in the freeradius conf | ||
|
||
sqlcounter dailycounter { | ||
sql_module_instance = sql | ||
dialect = ${modules.sql.dialect} | ||
|
||
counter_name = Daily-Session-Time | ||
check_name = Max-Daily-Session | ||
reply_name = Session-Timeout | ||
|
||
key = User-Name | ||
reset = daily | ||
|
||
$INCLUDE ${modconfdir}/sql/counter/${dialect}/${.:instance}.conf | ||
} | ||
|
||
# The noresetcounter is included by default in the freeradius conf | ||
sqlcounter noresetcounter { | ||
sql_module_instance = sql | ||
dialect = ${modules.sql.dialect} | ||
|
||
counter_name = Max-All-Session-Time | ||
check_name = Max-All-Session | ||
key = User-Name | ||
reset = never | ||
|
||
$INCLUDE ${modconfdir}/sql/counter/${dialect}/${.:instance}.conf | ||
} | ||
|
||
# The dailybandwidthcounter is added for django-freeradius | ||
sqlcounter dailybandwidthcounter { | ||
counter_name = Max-Daily-Session-Traffic | ||
check_name = Max-Daily-Session-Traffic | ||
sql_module_instance = sql | ||
key = 'User-Name' | ||
reset = daily | ||
query = "SELECT SUM(acctinputoctets + acctoutputoctets) \ | ||
FROM radacct \ | ||
WHERE UserName='%{${key}}' \ | ||
AND UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '%%b'" | ||
} |
Oops, something went wrong.