mirror of
				https://github.com/iiab/iiab.git
				synced 2025-03-09 15:40:17 +00:00 
			
		
		
		
	
						commit
						c898fa55b2
					
				
					 9 changed files with 52 additions and 48 deletions
				
			
		| 
						 | 
				
			
			@ -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/<OS>.yml
 | 
			
		||||
    - "{{ nginx_log_dir }}"     # /var/log/nginx
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 }}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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" }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue