1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

Merge branch 'master' into dnsmasq-initial-cleanup

This commit is contained in:
A Holt 2018-10-08 19:32:08 -04:00 committed by GitHub
commit 2f3fb69e01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 908 additions and 74 deletions

View file

@ -1,47 +1,107 @@
- name: Create directory for Captive Portal script
- name: Download & install python-dateutil, sqlite3
package:
name: "{{ item }}"
state: present
with_items:
- python-dateutil
- sqlite3 # @georgehunt hopes to move this to 2-common (or more like stage 3-base-server, alongside MySQL) in October 2018
- name: Create directory /opt/iiab/captive-portal for scripts & templates
file:
path: /opt/iiab/captive-portal
state: directory
when: py_captive_portal_install
- name: Copy Captive Portal script
- name: 'Copy scripts: checkurls, capture-wsgi.py'
template:
src: roles/network/templates/captive_portal/captive_portal.py.j2
dest: /opt/iiab/captive-portal/captive_portal.py
src: "{{ item.src }}"
dest: /opt/iiab/captive-portal/
mode: "{{ item.mode }}"
with_items:
- { src: roles/network/templates/captive-portal/checkurls, mode: '0644' }
- { src: roles/network/templates/captive-portal/capture-wsgi.py, mode: '0755' }
- name: 'Copy templates: simple.template, mac.template'
copy:
src: "{{ item }}"
dest: /opt/iiab/captive-portal/
with_items:
- roles/network/files/simple.template
- roles/network/files/mac.template
- name: Copy iiab-catch & iiab-uncatch into /usr/bin/
template:
src: "{{ item }}"
dest: /usr/bin/
owner: root
group: root
mode: 0740
when: py_captive_portal_install
mode: 0755
with_items:
- roles/network/templates/captive-portal/iiab-catch
- roles/network/templates/captive-portal/iiab-uncatch
- name: Copy Captive Portal service file
- name: Run iiab-uncatch to generate diversion lists for dnsmasq and apache2
shell: /usr/bin/iiab-uncatch
- name: Install systemd unit file py-captive-portal.service from template
template:
src: roles/network/templates/captive_portal/captive_portal.service.j2
dest: /etc/systemd/system/captive_portal.service
src: roles/network/templates/captive-portal/py-captive-portal.service.j2
dest: /etc/systemd/system/py-captive-portal.service
owner: root
group: root
mode: 0644
when: py_captive_portal_install
- name: Enable captive_portal after copying files
service:
name: captive_portal.service
- name: Install Apache's captive-portal.conf from template if py_captive_portal_enabled
template:
src: roles/network/templates/captive-portal/captive-portal.conf
dest: /etc/{{ apache_config_dir }}/captive-portal.conf
owner: root
group: root
mode: 0740
when: py_captive_portal_enabled
- name: Enable Apache's captive-portal.conf if py_captive_portal_enabled (debuntu)
file:
src: /etc/apache2/sites-available/captive-portal.conf
path: /etc/apache2/sites-enabled/captive-portal.conf
state: link
when: py_captive_portal_enabled and is_debuntu
- name: Enable Apache's default-ssl.conf if py_captive_portal_enabled (debuntu)
file:
src: /etc/apache2/sites-available/default-ssl.conf
path: /etc/apache2/sites-enabled/default-ssl.conf
state: link
when: py_captive_portal_enabled and is_debuntu
- name: Enable & Start systemd service py-captive-portal.service if py_captive_portal_enabled
systemd:
name: py-captive-portal.service
daemon-reload: yes
enabled: yes
when: py_captive_portal_install and py_captive_portal_enabled
- name: Start captive_portal after copying files
service:
name: captive_portal.service
state: started
when: py_captive_portal_install and py_captive_portal_enabled
when: py_captive_portal_enabled
- name: Disable captive_portal after copying files
service:
name: captive_portal.service
- name: Disable & Stop py-captive-portal.service if not py_captive_portal_enabled
systemd:
name: py-captive-portal.service
enabled: no
when: py_captive_portal_install and py_captive_portal_enabled
state: stopped
when: not py_captive_portal_enabled
- name: Stop captive_portal after copying files
service:
name: captive_portal.service
state: started
when: py_captive_portal_install and py_captive_portal_enabled
- name: Disable Apache's captive-portal.conf if not py_captive_portal_enabled (debuntu)
file:
path: /etc/apache2/sites-enabled/captive-portal.conf
state: absent
when: not py_captive_portal_enabled and is_debuntu
- name: Disable Apache's default-ssl.conf if not py_captive_portal_enabled (debuntu)
file:
path: /etc/apache2/sites-enabled/default-ssl.conf
state: absent
when: not py_captive_portal_enabled and is_debuntu
- name: Make sure dnsmasq is not diverting if not py_captive_portal_enabled
file:
path: /etc/dnsmasq.d/capture
state: absent
when: not py_captive_portal_enabled

View file

@ -1,24 +1,24 @@
#TODO: Use vars instead of hardcoded values
- name: Remove FQDN with 172.18.96.1 in /etc/hosts without LAN (if iiab_lan_iface == "none" and not installing)
lineinfile:
dest: /etc/hosts
path: /etc/hosts
regexp: '^172\.18\.96\.1'
state: absent
when: iiab_lan_iface == "none" and not installing
- name: Configure FQDN with 172.18.96.1 in /etc/hosts with LAN (if iiab_lan_iface != "none" and not installing)
lineinfile:
dest: /etc/hosts
path: /etc/hosts
regexp: '^172\.18\.96\.1'
line: '172.18.96.1 {{ iiab_hostname }}.{{ iiab_domain }} {{ iiab_hostname }} box'
line: '172.18.96.1 {{ iiab_hostname }}.{{ iiab_domain }} {{ iiab_hostname }} box'
state: present
when: iiab_lan_iface != "none" and not installing
- name: Configure FQDN with 127.0.0.1 in /etc/hosts appliance mode (if iiab_lan_iface == "none" and not installing)
lineinfile:
dest: /etc/hosts
path: /etc/hosts
regexp: '^127\.0\.0\.1'
line: '127.0.0.1 localhost.localdomain localhost {{ iiab_hostname }}.{{ iiab_domain }} {{ iiab_hostname }} box '
line: '127.0.0.1 localhost.localdomain localhost {{ iiab_hostname }}.{{ iiab_domain }} {{ iiab_hostname }} box'
owner: root
group: root
mode: 0644