diff --git a/roles/2-common/tasks/fl.yml b/roles/2-common/tasks/fl.yml index 21038dd3d..2676d9b3a 100644 --- a/roles/2-common/tasks/fl.yml +++ b/roles/2-common/tasks/fl.yml @@ -37,14 +37,3 @@ src: "{{ doc_root }}/common/fonts" # /library/www/html path: "{{ doc_root }}/common/webfonts" state: link - -- name: File Layout - Create log file directories {{ apache_log_dir }} & {{ nginx_log_dir }} - file: - path: "{{ item }}" - owner: "{{ apache_user }}" # www-data - group: "{{ apache_user }}" # www-data - mode: '0770' - state: directory - with_items: - - "{{ apache_log_dir }}" # /var/log/apache2 typically, as set in /opt/iiab/iiab/vars/.yml - - "{{ nginx_log_dir }}" # /var/log/nginx diff --git a/roles/captiveportal/tasks/main.yml b/roles/captiveportal/tasks/main.yml index 27c0a1760..87e03de23 100644 --- a/roles/captiveportal/tasks/main.yml +++ b/roles/captiveportal/tasks/main.yml @@ -14,6 +14,14 @@ state: directory owner: "{{ apache_user }}" +- name: Create directory /var/log/captiveportal for logs; set owner to {{ apache_user }} + 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-make-cp-servers.py, /usr/sbin/iiab-divert-to-nginx" template: src: "{{ item.src }}" @@ -41,11 +49,11 @@ - mac.template #- roles/captiveportal/files/mac.template -- name: Install uWSGI config file /opt/iiab/captiveportal/captiveportal.ini from template - template: - src: captiveportal.ini.j2 - #src: roles/captiveportal/templates/captiveportal.ini.j2 - dest: /opt/iiab/captiveportal/captiveportal.ini +#- name: Install /etc/systemd/system/uwsgi-captiveportal.service from template +# template: +# src: uwsgi-captiveportal.service +# #src: roles/captiveportal/templates/uwsgi-captiveportal.service +# dest: /etc/systemd/system/ - name: "Add 'captiveportal_installed: True' to {{ iiab_state_file }}" lineinfile: @@ -55,25 +63,38 @@ # TO DO: move most/all 7-10 stanzas below into enable-or-disable.yml -- name: Install /etc/systemd/system/uwsgi-captiveportal.service from template - template: - src: uwsgi-captiveportal.service - #src: roles/captiveportal/templates/uwsgi-captiveportal.service - dest: /etc/systemd/system/ +#- name: Restart & Enable 'uwsgi-captiveportal' systemd service (uWSGI server) that responds to browsers trying to detect a Captive Portal +# systemd: +# name: uwsgi-captiveportal +# daemon_reload: yes +# state: restarted +# enabled: True +# when: captiveportal_enabled | bool -- name: Restart & Enable 'uwsgi-captiveportal' systemd service (uWSGI server) that responds to browsers trying to detect a Captive Portal +#- name: Stop & Disable 'uwsgi-captiveportal' systemd service (uWSGI server) if Captive Portal has been disabled +# systemd: +# name: uwsgi-captiveportal +# state: stopped +# enabled: False +# when: not captiveportal_enabled + +- name: Stop uwsgi systemd: - name: uwsgi-captiveportal - daemon_reload: yes - state: restarted - enabled: True + name: uwsgi + state: stopped + +- name: Install uWSGI config file /etc/uwsgi/apps-enabled/captiveportal.ini from template + template: + src: captiveportal.ini.j2 + #src: roles/captiveportal/templates/captiveportal.ini.j2 + dest: /etc/uwsgi/apps-enabled/captiveportal.ini when: captiveportal_enabled | bool -- name: Stop & Disable 'uwsgi-captiveportal' systemd service (uWSGI server) if Captive Portal has been disabled - systemd: - name: uwsgi-captiveportal - state: stopped - enabled: False +- name: Delete uWSGI config file /etc/uwsgi/apps-enabled/captiveportal.ini when disabled + file: + #src: /etc/nginx/sites-available/capture.conf + path: /etc/uwsgi/apps-enabled/captiveportal.ini + state: absent when: not captiveportal_enabled - name: Run iiab-divert-to-nginx to generate diversion lists for NGINX @@ -104,13 +125,13 @@ state: absent when: not captiveportal_enabled -#- 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!) +# lets assume admin-console was/will be installed anyway +- name: Start uwsgi + systemd: + name: uwsgi + daemon_reload: yes + state: started + enabled: true - name: Stop 'dnsmasq' systemd service systemd: diff --git a/roles/captiveportal/templates/capture-wsgi.py.j2 b/roles/captiveportal/templates/capture-wsgi.py.j2 index 944ee556e..e240b827a 100755 --- a/roles/captiveportal/templates/capture-wsgi.py.j2 +++ b/roles/captiveportal/templates/capture-wsgi.py.j2 @@ -46,9 +46,9 @@ if len(sys.argv) > 1: loggingLevel = "DEBUG" # set up some logging -- selectable for diagnostics -logging.basicConfig(filename='{{ nginx_log_dir }}/portal.log',format='%(asctime)s.%(msecs)03d:%(name)s:%(message)s', datefmt='%M:%S',level=loggingLevel) -logger = logging.getLogger('{{ nginx_log_dir }}/portal.log') -handler = RotatingFileHandler("{{ nginx_log_dir }}/portal.log", maxBytes=100000, backupCount=2) +logging.basicConfig(filename='/var/log/captiveportal/captiveportal.log',format='%(asctime)s.%(msecs)03d:%(name)s:%(message)s', datefmt='%M:%S',level=loggingLevel) +logger = logging.getLogger('/var/log/captiveportal/captiveportal.log') +handler = RotatingFileHandler("/var/log/captiveportal/captiveportal.log", maxBytes=100000, backupCount=2) logger.addHandler(handler) PORT={{ captiveportal_port }} diff --git a/roles/nginx/tasks/install.yml b/roles/nginx/tasks/install.yml index 301120a65..d59224e0f 100644 --- a/roles/nginx/tasks/install.yml +++ b/roles/nginx/tasks/install.yml @@ -27,13 +27,6 @@ - { src: 'roles/nginx/templates/server.conf.j2', dest: '/etc/nginx/server.conf' } - { src: 'roles/nginx/templates/nginx.conf.j2', dest: '/etc/nginx/nginx.conf' } - { src: 'roles/nginx/templates/ports.conf.j2', dest: '/etc/{{ apache_service }}/ports.conf' } - - { src: 'roles/nginx/templates/uwsgi.service', dest: '/etc/systemd/system/' } - -- name: Let uwsgi (running as {{ apache_user }}) write log files - file: - path: /var/log/uwsgi/app - state: directory - owner: "{{ apache_user }}" - name: "Add 'nginx_installed: True' to {{ iiab_state_file }}" lineinfile: diff --git a/roles/nginx/tasks/main.yml b/roles/nginx/tasks/main.yml index e5c4c6a18..d2f57ffe3 100644 --- a/roles/nginx/tasks/main.yml +++ b/roles/nginx/tasks/main.yml @@ -3,6 +3,7 @@ path: "{{ item.path }}" state: absent with_items: + - { path: "/etc/systemd/system/uwsgi.service" } - { path: "{{ nginx_config_dir }}/usb-lib.conf" } - { path: "{{ nginx_config_dir }}/modules.conf" } diff --git a/roles/nginx/templates/admin-console-apache.conf b/roles/nginx/templates/admin-console-apache.conf.unused similarity index 100% rename from roles/nginx/templates/admin-console-apache.conf rename to roles/nginx/templates/admin-console-apache.conf.unused diff --git a/roles/nginx/templates/admin-console-nginx.conf b/roles/nginx/templates/admin-console-nginx.conf.unused similarity index 100% rename from roles/nginx/templates/admin-console-nginx.conf rename to roles/nginx/templates/admin-console-nginx.conf.unused diff --git a/roles/nginx/templates/admin-console.ini b/roles/nginx/templates/admin-console.ini.unused similarity index 100% rename from roles/nginx/templates/admin-console.ini rename to roles/nginx/templates/admin-console.ini.unused diff --git a/roles/nginx/templates/uwsgi.service b/roles/nginx/templates/uwsgi.service.unused similarity index 100% rename from roles/nginx/templates/uwsgi.service rename to roles/nginx/templates/uwsgi.service.unused