2023-05-27 07:26:04 +00:00
- name : Record (initial) available disk space
shell : df -PB1 $(findmnt / -o SOURCE -n) | awk 'NR==2 {print $4}'
register : df1
2021-05-28 07:18:05 +00:00
- name : "Install packages: python3-dateutil, python3-jinja2"
2020-01-22 22:46:22 +00:00
package :
2021-05-28 07:18:05 +00:00
name :
- python3-dateutil
- python3-jinja2
2020-01-22 22:46:22 +00:00
state : present
- name : mkdir /opt/iiab/captiveportal for scripts & templates, set owner to {{ apache_user }}
file :
path : /opt/iiab/captiveportal
state : directory
owner : "{{ apache_user }}"
- name : mkdir /var/log/captiveportal for logs, set ownership {{ apache_user }}:{{ apache_user }}, set mode '0750'
file :
path : /var/log/captiveportal
state : directory
owner : "{{ apache_user }}"
group : "{{ apache_user }}"
mode : '0750' # Same as /var/log/apache2
- name : "Install 3 scripts from template: /opt/iiab/captiveportal/checkurls, /usr/sbin/iiab-divert-to-nginx, /usr/sbin/iiab-make-cp-servers.py"
template :
src : "{{ item.src }}"
dest : "{{ item.dest }}"
mode : "{{ item.mode }}"
with_items :
- { src: roles/captiveportal/templates/checkurls, dest: /opt/iiab/captiveportal/, mode : '0644' }
2022-07-09 02:00:03 +00:00
- { src: roles/captiveportal/templates/iiab-divert-to-nginx.j2, dest: /usr/sbin/iiab-divert-to-nginx, mode : '0755' }
2020-01-22 22:46:22 +00:00
- { src: roles/captiveportal/templates/iiab-make-cp-servers.py, dest: /usr/sbin/, mode : '0755' }
- name : Install /opt/iiab/captiveportal/capture-wsgi.py from template, mode '0755' (creates the server)
template :
src : capture-wsgi.py.j2
dest : /opt/iiab/captiveportal/capture-wsgi.py
mode : '0755'
- name : Copy files {simple.template, mac.template} into /opt/iiab/captiveportal/
copy :
src : "{{ item }}"
dest : /opt/iiab/captiveportal/
with_items :
- simple.template
- mac.template
2021-07-28 02:36:07 +00:00
- name : Run /usr/sbin/iiab-make-cp-servers.py to generate NGINX servers from /opt/iiab/captiveportal/checkurls input list (creates /etc/nginx/sites-available/capture.conf)
2020-01-22 22:46:22 +00:00
command : /usr/sbin/iiab-make-cp-servers.py
args :
creates : /etc/nginx/sites-available/capture.conf
2020-01-30 09:00:00 +00:00
# RECORD Captive Portal AS INSTALLED
2023-05-27 07:26:04 +00:00
- name : Record (final) available disk space
shell : df -PB1 $(findmnt / -o SOURCE -n) | awk 'NR==2 {print $4}'
register : df2
- name : Add 'captiveportal_disk_usage = {{ df1.stdout|int - df2.stdout|int }}' to {{ iiab_ini_file }}
ini_file :
path : "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section : captiveportal
option : captiveportal_disk_usage
value : "{{ df1.stdout|int - df2.stdout|int }}"
2020-01-30 09:00:00 +00:00
- name : "Set 'captiveportal_installed: True'"
set_fact :
captiveportal_installed : True
2020-01-22 22:46:22 +00:00
- name : "Add 'captiveportal_installed: True' to {{ iiab_state_file }}"
lineinfile :
2020-02-04 00:54:04 +00:00
path : "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
2020-01-22 22:46:22 +00:00
regexp : '^captiveportal_installed'
line: 'captiveportal_installed : True '