2020-01-16 15:16:25 +00:00
- name : "Download & install packages: python3-dateutil, python3-jinja2"
2019-12-04 21:30:27 +00:00
package :
name : "{{ item }}"
state : present
with_items :
- python3-dateutil
- python3-jinja2
2020-01-16 15:16:25 +00:00
- name : Create directory /opt/iiab/captiveportal for scripts & templates; set owner to {{ apache_user }}
2019-12-04 21:30:27 +00:00
file :
path : /opt/iiab/captiveportal
state : directory
owner : "{{ apache_user }}"
2020-01-16 15:16:25 +00:00
- name : "Install 3 scripts from template: /opt/iiab/captiveportal/checkurls, /usr/sbin/iiab-make-cp-servers.py, /usr/sbin/iiab-divert-to-nginx"
2019-12-04 21:30:27 +00:00
template :
src : "{{ item.src }}"
dest : "{{ item.dest }}"
mode : "{{ item.mode }}"
with_items :
2020-01-16 15:16:25 +00:00
- { src: roles/captiveportal/templates/checkurls, dest: /opt/iiab/captiveportal/, mode : '0644' }
- { src: roles/captiveportal/templates/iiab-make-cp-servers.py, dest: /usr/sbin/, mode : '0755' }
- { src: roles/captiveportal/templates/iiab-divert-to-nginx, dest: /usr/sbin/, mode : '0755' }
2019-12-06 03:57:00 +00:00
2020-01-16 15:16:25 +00:00
- name : Install /opt/iiab/captiveportal/capture-wsgi.py from template (creates the server)
2019-12-18 16:36:38 +00:00
template :
2020-01-16 15:16:25 +00:00
src : capture-wsgi.py.j2
#src: roles/captiveportal/templates/capture-wsgi.py.j2
dest : /opt/iiab/captiveportal/
mode : '0755'
2019-12-06 03:57:00 +00:00
2020-01-16 15:16:25 +00:00
- name : Copy files {simple.template, mac.template} into /opt/iiab/captiveportal/
2019-12-04 21:30:27 +00:00
copy :
src : "{{ item }}"
dest : /opt/iiab/captiveportal/
with_items :
2020-01-16 15:16:25 +00:00
- simple.template
#- roles/captiveportal/files/simple.template
- mac.template
#- roles/captiveportal/files/mac.template
2019-12-04 21:30:27 +00:00
2020-01-16 15:16:25 +00:00
- name : Install uWSGI config file /opt/iiab/captiveportal/captiveportal.ini from template
2019-12-04 21:30:27 +00:00
template :
2020-01-16 15:16:25 +00:00
src : captiveportal.ini.j2
#src: roles/captiveportal/templates/captiveportal.ini.j2
2019-12-19 14:32:18 +00:00
dest : /opt/iiab/captiveportal/captiveportal.ini
2019-12-04 21:30:27 +00:00
2020-01-16 15:16:25 +00:00
- name : Install /etc/systemd/system/uwsgi-captiveportal.service from template
2019-12-04 21:30:27 +00:00
template :
2020-01-16 15:16:25 +00:00
src : uwsgi-captiveportal.service
#src: roles/captiveportal/templates/uwsgi-captiveportal.service
2019-12-04 21:30:27 +00:00
dest : /etc/systemd/system/
- name : Start or restart server which responds to browsers trying to detect a captive portal
systemd :
name : uwsgi-captiveportal.service
state : restarted
2019-12-05 20:54:00 +00:00
enabled : True
2019-12-04 21:30:27 +00:00
when : captiveportal_enabled | bool
2020-01-16 15:16:25 +00:00
- name : Stop uWSGI server if Captive Portal has been disabled
2019-12-04 21:30:27 +00:00
systemd :
name : uwsgi-captiveportal.service
state : stopped
2019-12-05 20:54:00 +00:00
enabled : False
2020-01-16 15:16:25 +00:00
when : not captiveportal_enabled
2019-12-04 21:30:27 +00:00
2020-01-16 15:16:25 +00:00
- name : Run iiab-divert-to-nginx to generate diversion lists for NGINX
2019-12-05 02:20:08 +00:00
shell : /usr/sbin/iiab-divert-to-nginx
2020-01-16 15:16:25 +00:00
- name : Run iiab-make-cp-servers.py to generate NGINX servers from checkurls input list (creates /etc/nginx/sites-available/capture.conf)
2019-12-05 19:23:46 +00:00
command : /usr/sbin/iiab-make-cp-servers.py
args :
2020-01-16 15:16:25 +00:00
creates : /etc/nginx/sites-available/capture.conf
2019-12-05 19:23:46 +00:00
2020-01-16 15:16:25 +00:00
- name : Symlink /etc/nginx/sites-enabled/capture.conf -> /etc/nginx/sites-available/capture.conf, to enable NGINX to service the sites in checkurls list
2019-12-05 19:23:46 +00:00
file :
src : /etc/nginx/sites-available/capture.conf
path : /etc/nginx/sites-enabled/capture.conf
state : link
when : captiveportal_enabled | bool
2020-01-16 15:16:25 +00:00
- name : Delete symlink /etc/nginx/sites-enabled/capture.conf, to disable NGINX to location definitions for checkurls
2019-12-19 14:32:18 +00:00
file :
2020-01-16 15:16:25 +00:00
#src: /etc/nginx/sites-available/capture.conf
2019-12-19 14:32:18 +00:00
path : /etc/nginx/sites-enabled/capture.conf
state : absent
2020-01-16 15:16:25 +00:00
when : not captiveportal_enabled
2019-12-19 14:32:18 +00:00
2019-12-04 21:30:27 +00:00
- name : Make sure dnsmasq is not diverting if not captiveportal_enabled
file :
path : /etc/dnsmasq.d/capture
state : absent
when : not captiveportal_enabled
2020-01-12 23:15:33 +00:00
- name : "Add 'captiveportal_installed: True' to {{ iiab_state_file }}"
2019-12-04 21:30:27 +00:00
lineinfile :
2020-01-12 23:15:33 +00:00
dest : "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
2019-12-04 21:30:27 +00:00
regexp : '^captiveportal_installed'
line: 'captiveportal_installed : True '
#- name: Restart dnsmasq
# systemd:
# name: dnsmasq
# state: restarted
# when: dnsmasq_enabled | bool
# ABOVE DOES NOT WORK ON UBUNTU 16.04 -- what follows is a crude hack (seems to work!)
2020-01-16 15:16:25 +00:00
- name : Stop 'dnsmasq' systemd service
2019-12-04 21:30:27 +00:00
systemd :
name : dnsmasq
state : stopped
when : dnsmasq_enabled | bool
2020-01-16 15:16:25 +00:00
- name : Start 'dnsmasq' systemd service
2019-12-04 21:30:27 +00:00
systemd :
name : dnsmasq
state : started
when : dnsmasq_enabled | bool