1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 03:32:12 +00:00
iiab/roles/captiveportal/tasks/install.yml

79 lines
2.7 KiB
YAML
Raw Normal View History

- name: Record (initial) disk space used
shell: df -B1 --output=used / | tail -1
register: df1
- name: "Install packages: python3-dateutil, python3-jinja2"
2020-01-22 22:46:22 +00:00
package:
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' }
- { 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
- 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
- name: Record (final) disk space used
shell: df -B1 --output=used / | tail -1
register: df2
- name: Add 'captiveportal_disk_usage = {{ df2.stdout|int - df1.stdout|int }}' to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section: captiveportal
option: captiveportal_disk_usage
value: "{{ df2.stdout|int - df1.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:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
2020-01-22 22:46:22 +00:00
regexp: '^captiveportal_installed'
line: 'captiveportal_installed: True'