From 0ae30131d13d34846fec915b37c1709d559798f3 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 29 Jun 2021 23:37:54 -0500 Subject: [PATCH] link to packaged files - move restart --- roles/nginx/tasks/enable-or-disable.yml | 6 ++++ roles/nginx/tasks/install.yml | 45 ++++++++++++++----------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/roles/nginx/tasks/enable-or-disable.yml b/roles/nginx/tasks/enable-or-disable.yml index 0ef223866..e519f330d 100644 --- a/roles/nginx/tasks/enable-or-disable.yml +++ b/roles/nginx/tasks/enable-or-disable.yml @@ -25,6 +25,12 @@ # enabled: true # when: apache_installed is defined and apache_enabled # or not nginx_enabled +- name: Start iiab-nginx on port {{ nginx_port }} + systemd: + daemon_reload: yes + name: iiab-nginx.service + state: restarted + when: nginx_port|int != 80 or nginx_dir != "/etc/nginx" - name: Enable & (Re)Start 'nginx' systemd service, if nginx_enabled systemd: diff --git a/roles/nginx/tasks/install.yml b/roles/nginx/tasks/install.yml index 8266cb3b8..98ac48e96 100644 --- a/roles/nginx/tasks/install.yml +++ b/roles/nginx/tasks/install.yml @@ -44,17 +44,6 @@ state: absent when: not is_guest -- name: 'Install 3 (of 5) files from template: /etc/nginx/server.conf, /etc/nginx/nginx.conf, /etc/nginx/mime.types' - template: - src: "{{ item.src }}" - dest: "{{ item.dest }}" - with_items: - - { src: 'server.conf.j2', dest: '{{ nginx_dir }}/server.conf' } - - { src: 'nginx.conf.j2', dest: '{{ nginx_dir }}/nginx.conf' } - - { src: 'mime.types.j2', dest: '{{ nginx_dir }}/mime.types' } - # - { src: 'ports.conf', dest: '/etc/{{ apache_service }}/ports.conf' } # 2021-08-09: Restored from enable-or-disable.yml then moved to roles/pbx/tasks/apache.yml - # - { src: 'iiab.conf.j2', dest: "{{ nginx_conf_dir }}/iiab.conf" } # Moved into homepage.yml, invoked later by roles/www_options/tasks/main.yml (see below!) - # start block - block: - name: Insure alternate nginx path is present @@ -66,11 +55,23 @@ - "{{ nginx_dir }}/sites-available" - "{{ nginx_dir }}/sites-enabled" - - name: Link {{ nginx_dir }}/modules-enabled + - name: Link {{ nginx_dir }}/ files file: - src: /etc/nginx/modules-enabled - path: "{{ nginx_dir }}/modules-enabled" + src: /etc/nginx/{{ item }} + path: "{{ nginx_dir }}/{{ item }}" state: link + with_items: + - modules-available + - modules-enabled + - snippets + - fastcgi.conf + - fastcgi_params + - koi-win + - koi-utf + - proxy_params + - scgi_params + - uwsgi_params + - win-utf - name: Grab stock unit file copy: @@ -90,14 +91,20 @@ # - { regexp: '^ExecStart=/usr/sbin/nginx', line: 'ExecStart=/usr/sbin/nginx -c {{ nginx_dir }}/nginx.conf' } # - { regexp: '^ExecReload=/usr/sbin/nginx', line: 'ExecReload=/usr/sbin/nginx -c {{ nginx_dir }}/nginx.conf' } - - name: start iiab-nginx on port {{ nginx_port }} - systemd: - daemon_reload: yes - name: iiab-nginx.service - state: restarted # end block when: nginx_port|int != 80 or nginx_dir != "/etc/nginx" +- name: 'Install 3 (of 5) files from template: /etc/nginx/server.conf, /etc/nginx/nginx.conf, /etc/nginx/mime.types' + template: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + with_items: + - { src: 'server.conf.j2', dest: '{{ nginx_dir }}/server.conf' } + - { src: 'nginx.conf.j2', dest: '{{ nginx_dir }}/nginx.conf' } + - { src: 'mime.types.j2', dest: '{{ nginx_dir }}/mime.types' } + # - { src: 'ports.conf', dest: '/etc/{{ apache_service }}/ports.conf' } # 2021-08-09: Restored from enable-or-disable.yml then moved to roles/pbx/tasks/apache.yml + # - { src: 'iiab.conf.j2', dest: "{{ nginx_conf_dir }}/iiab.conf" } # Moved into homepage.yml, invoked later by roles/www_options/tasks/main.yml (see below!) + - debug: msg: roles/nginx/tasks/homepage.yml will run LATER (invoked by roles/www_options/tasks/main.yml) SO THAT NGINX CAN REDIRECT http://box TO http://box{{ iiab_home_url }} (based on var iiab_home_url) # - include_tasks: roles/nginx/tasks/homepage.yml