From 76e79f5c415fe9a6aba84e9c60177d81365dc3fd Mon Sep 17 00:00:00 2001 From: George Hunt Date: Thu, 5 Dec 2019 19:23:46 +0000 Subject: [PATCH] link to config that exists, py3 in capture-wsgi.py, get systemd unit file for admin-console in place --- roles/captiveportal/tasks/main.yml | 20 ++++++++++--------- roles/captiveportal/templates/capture-wsgi.py | 6 +++--- roles/nginx/tasks/install.yml | 9 +-------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/roles/captiveportal/tasks/main.yml b/roles/captiveportal/tasks/main.yml index 1fa51841f..9978f3624 100644 --- a/roles/captiveportal/tasks/main.yml +++ b/roles/captiveportal/tasks/main.yml @@ -43,13 +43,6 @@ state: link when: captiveportal_enabled | bool -- name: Enable nginx to service the sites in checkurls list - file: - src: /etc/nginx/sites-available/capture.conf - path: /etc/nginx/sites-enabled/capture.conf - state: link - when: captiveportal_enabled | bool - - name: Copy unit file for uWSGI service template: src: roles/captiveportal/templates/uwsgi-captiveportal.service @@ -71,8 +64,17 @@ shell: /usr/sbin/iiab-divert-to-nginx - name: Run script to generate nginx servers from checkurls input list - shell: /usr/sbin/iiab-make-cp-servers.py - + command: /usr/sbin/iiab-make-cp-servers.py + args: + creates: /etc/nginx/sites-available/capture.conf + +- name: Enable nginx to service the sites in checkurls list + file: + src: /etc/nginx/sites-available/capture.conf + path: /etc/nginx/sites-enabled/capture.conf + state: link + when: captiveportal_enabled | bool + - name: Install nginx's captiveportal.conf from template if captiveportal_enabled template: src: roles/captiveportal/templates/captiveportal-nginx.conf diff --git a/roles/captiveportal/templates/capture-wsgi.py b/roles/captiveportal/templates/capture-wsgi.py index e1ab9dcb4..27727aa61 100755 --- a/roles/captiveportal/templates/capture-wsgi.py +++ b/roles/captiveportal/templates/capture-wsgi.py @@ -123,7 +123,7 @@ def is_after204_timeout(ip): ts=tstamp(datetime.datetime.now(tzutc())) current_ts, last_ts, send204after = timeout_info(ip) if send204after == 0: return False - logger.debug("function: is_after204_timeout send204after:{} current: {}".format(send204after,ts,)) + logger.debug("function: is_after204_timeout send204after:{} current: {}".format((send204after,ts,))) if not send204after: return False if ts - int(send204after) > 0: @@ -390,7 +390,7 @@ def application (environ, start_response): data = ['{}: {}\n'.format(key, value) for key, value in sorted(environ.items()) ] #logger.debug("need the correct ip:{}".format(data)) ip = environ['REMOTE_ADDR'].strip() - cmd="arp -an %s|gawk \'{print $4}\'"%(ip) + cmd="arp -an {}|gawk \'{print $4}\'".format(ip) mac = subprocess.check_output(cmd, shell=True) data = [] data.append("host: {}\n".format(environ['HTTP_HOST'])) @@ -484,7 +484,7 @@ def application (environ, start_response): environ['PATH_INFO'] == "/gen_204" or\ environ['HTTP_HOST'] == "connectivitycheck.gstatic.com": current_ts, last_ts, send204after = timeout_info(ip) - logger.debug("current_ts: {} last_ts: {} send204after: {}".format(current_ts, last_ts, send204after,)) + logger.debug("current_ts: {} last_ts: {} send204after: {}".formmat(current_ts, last_ts, send204after,)) if not last_ts or (ts - int(last_ts) > INACTIVITY_TO): return android(environ, start_response) elif is_after204_timeout(ip): diff --git a/roles/nginx/tasks/install.yml b/roles/nginx/tasks/install.yml index 7271ed86e..8053d961e 100644 --- a/roles/nginx/tasks/install.yml +++ b/roles/nginx/tasks/install.yml @@ -25,11 +25,4 @@ - { src: "roles/nginx/templates/server.conf", dest: "/etc/nginx/" } - { src: "roles/nginx/templates/nginx.conf", dest: "/etc/nginx/" } - { src: 'roles/nginx/templates/ports.conf', dest: '/etc/{{ apache_service }}/' , mode: '0644' } - - { src: 'roles/nginx/templates/uwsgi.service', dest: '/etc/systemd/system/' , mode: '0644' } - -- name: Let uwsgi running as {{ apache_user }} write log files - file: - path: /var/log/uwsgi/app - state: directory - owner: "{{ apache_user }}" - + - { src: 'roles/nginx/templates/uwsgi.unit', dest: '/etc/systemd/system/' , mode: '0644' }