1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-15 04:32:11 +00:00

rework - split to file

This commit is contained in:
Jerry Vonau 2019-10-22 06:05:06 -05:00
parent 3e9ffb8987
commit 2b411efa3f

View file

@ -1,10 +1,3 @@
- name: Insure that apache2 is not running -- we may need port swap
service:
name: apache2
enabled: False
state: stopped
ignore_errors: True
- name: Install nginx required and helper packages - name: Install nginx required and helper packages
package: name={{ item }} state=present package: name={{ item }} state=present
with_items: with_items:
@ -13,63 +6,82 @@
- uwsgi-plugin-python - uwsgi-plugin-python
- php-fpm - php-fpm
- libnginx-mod-http-subs-filter - libnginx-mod-http-subs-filter
when: nginx_install | bool
- name: Put the config file in place - name: Put the config file in place
template: template:
src: '{{ item.src}}' src: '{{ item.src}}'
dest: '{{ item.dest }}' dest: '{{ item.dest }}'
with_items: with_items:
- { src: "server.conf",dest: "/etc/nginx/" } - { src: "server.conf",dest: "/etc/nginx/" }
- { src: "nginx.conf",dest: "/etc/nginx/" } - { src: "nginx.conf",dest: "/etc/nginx/" }
- { src: "usb-lib.conf",dest: "/etc/nginx/conf.d/" } - { src: "usb-lib.conf",dest: "/etc/nginx/conf.d/" }
- { src: "admin-console.ini",dest: "/etc/uwsgi/apps-enabled/" } - { src: "admin-console.ini",dest: "/etc/uwsgi/apps-enabled/" }
- { src: "uwsgi.unit",dest: "/etc/systemd/system/" } - { src: "uwsgi.unit",dest: "/etc/systemd/system/" }
# optional services - { src: 'ports.conf' , dest: '/etc/{{ apache_service }}/' , mode: '0644' }
- { src: "kiwix.conf",dest: "/etc/nginx/conf.d/" } when: nginx_enabled | bool
- name: Add http server user to shadow group, so it can authenticate Admin Console - name: Add http server user to shadow group, so it can authenticate Admin Console
user: user:
name: "{{ apache_user }}" name: "{{ apache_user }}"
groups: shadow groups: shadow
when: nginx_install | bool
- name: Remove the nginx default config - name: Remove the nginx default config
file: path=/etc/nginx/sites-enabled/default state=absent file:
path: /etc/nginx/sites-enabled/default
state: absent
when: nginx_install | bool
- name: Insure that apache2 is not running -- we may need port swap
systemd:
name: apache2
enabled: False
state: stopped
# optional services
- name: Install config for Admin Console - name: Install config for Admin Console
template: template:
src: admin-console-nginx.conf src: admin-console-nginx.conf
# Comment one or the other to revert from nginx back to apache2, if required # Comment one or the other to revert from nginx back to apache2, if required
# src: admin-console-apache.conf # src: admin-console-apache.conf
dest: /etc/nginx/conf.d/admin-console.conf dest: /etc/nginx/conf.d/admin-console.conf
when: admin_console_enabled | bool when: admin_console_enabled | bool and nginx_enabled | bool
- name: Enable the uwsgi systemd service - name: Enable the uwsgi systemd service
service: systemd:
name: uwsgi name: uwsgi
state: started state: started
enabled: True enabled: True
- name: Install ports.conf when nginx_enabled, from templates when: admin_console_enabled | bool and nginx_enabled | bool
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: root
group: root
mode: 0644
with_items:
- { src: 'ports.conf' , dest: '/etc/{{ apache_service }}/' , mode: '0644' }
when: is_debuntu | bool and nginx_enabled | bool
- name: Install proxpass to apache running on localhost - name: Disable apache port {{ apache_port }} localhost only
file:
path: /etc/{{ apache_service }}/ports.conf
state: absent
when: not nginx_enabled | bool
# the below slides in nginx's proxypass config files for apache on localhost
# via the ports.conf file installed above
- name: Install proxpass to apache running on localhost port {{ apache_port }}
include_tasks: uses_apache.yml include_tasks: uses_apache.yml
- name: Make sure nginx picks up the config # the below task contains the same logic contained in the playbooks to enable
service: # 'runrole nginx' to do the right thing.
name: nginx - name: Install proxpass to apache running on localhost
state: restarted include_tasks: only_nginx.yml
when: nginx_enabled | bool
# it might not be installed yet, so ignore errors
- name: Since we stopped apache2, start it again - name: Since we stopped apache2, start it again
service: name=apache2 state=started enabled=True systemd:
name: apache2
state: restarted
daemon_reload: yes
when: apache_enabled | bool when: apache_enabled | bool
ignore_errors: True
- name: Restart nginx to pick up the config files installed
systemd:
name: nginx
state: restarted
enabled: true
daemon_reload: yes
when: nginx_enabled | bool