From b8325fd754275608f729f21ada66796d896a2708 Mon Sep 17 00:00:00 2001 From: L3D Date: Thu, 4 Feb 2021 13:49:56 +0100 Subject: [PATCH] rename service and adjust nginx configuration --- handlers/main.yml | 2 +- tasks/default_site.yml | 8 +++---- tasks/nginx.yml | 48 ++++++++++-------------------------------- tasks/single_site.yml | 16 +++++++------- 4 files changed, 24 insertions(+), 50 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 70eedf4..56dcac6 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -7,7 +7,7 @@ state: restarted -- name: Reload nginx +- name: systemctl reload nginx systemd: name: 'nginx.service' daemon_reload: yes diff --git a/tasks/default_site.yml b/tasks/default_site.yml index ca60819..69dc88b 100644 --- a/tasks/default_site.yml +++ b/tasks/default_site.yml @@ -8,7 +8,7 @@ group: root mode: 'u=rw,g=r,o=r' notify: - - Reload nginx + - systemctl reload nginx tags: - configuration - nginx @@ -23,7 +23,7 @@ group: root mode: 'u=rw,g=r,o=r' notify: - - Reload nginx + - systemctl reload nginx tags: - configuration - nginx @@ -36,7 +36,7 @@ dest: '/etc/nginx/sites-enabled/{{ inventory_hostname }}_http' state: link notify: - - Reload nginx + - systemctl reload nginx tags: - configuration - nginx @@ -50,7 +50,7 @@ # dest: '/etc/nginx/sites-enabled/{{ inventory_hostname }}_tls' # state: link # notify: -# - Reload nginx +# - systemctl reload nginx # tags: # - configuration # - nginx diff --git a/tasks/nginx.yml b/tasks/nginx.yml index 7eb9b0b..27e203d 100644 --- a/tasks/nginx.yml +++ b/tasks/nginx.yml @@ -1,6 +1,6 @@ --- - - name: Copy main nginx configuration file + become: true copy: src: 'nginx/nginx.conf' dest: '/etc/nginx/' @@ -8,87 +8,64 @@ group: root mode: 'u=rw,g=r,o=r' notify: - - Reload nginx - tags: - - configuration - - nginx - + - systemctl reload nginx - name: Create 'private' directory + become: true file: path: '/etc/nginx/private' state: directory owner: root group: root mode: 'u=rwx,g=rx,o=rx' - tags: - - configuration - - nginx - - dhparam - - name: Create new dhparam of size '{{ nginx__dhparam_size }}' + become: true openssl_dhparam: path: '/etc/nginx/private/dhparam.pem' size: '{{ nginx__dhparam_size | mandatory }}' notify: - - Reload nginx - tags: - - configuration - - nginx - - dhparam - + - systemctl reload nginx - name: Create 'sites-available' directory + become: true file: path: '/etc/nginx/sites-available' state: directory owner: root group: root mode: 'u=rwx,g=rx,o=rx' - tags: - - configuration - - nginx - - name: Create 'sites-enabled' directory + become: true file: path: '/etc/nginx/sites-enabled' state: directory owner: root group: root mode: 'u=rwx,g=rx,o=rx' - tags: - - configuration - - nginx - # Todo: Reconsider best practices - name: Remove default site config from package installation + become: true file: path: '{{ item }}' state: absent with_items: - '/etc/nginx/sites-enabled/default' - '/etc/nginx/sites-available/default' - tags: - - configuration - - nginx - - name: Create 'snippets' directory + become: true file: path: '/etc/nginx/snippets' state: directory owner: root group: root mode: 'u=rwx,g=rx,o=rx' - tags: - - configuration - - nginx - - name: Copy nginx snippet files + become: true copy: src: 'files/nginx/snippets/{{ item }}' dest: '/etc/nginx/snippets/{{ item }}' @@ -97,7 +74,4 @@ mode: 'u=rw,g=r,o=r' with_items: '{{ snippet_files }}' notify: - - Reload nginx - tags: - - configuration - - nginx + - systemctl reload nginx diff --git a/tasks/single_site.yml b/tasks/single_site.yml index e2046a3..ede1b41 100644 --- a/tasks/single_site.yml +++ b/tasks/single_site.yml @@ -11,7 +11,7 @@ mode: 'u=rw,g=r,o=r' #when: site.http_plain_template | default(True) notify: - - Reload nginx + - systemctl reload nginx tags: - configuration - nginx @@ -27,7 +27,7 @@ mode: 'u=rw,g=r,o=r' #when: not site.redirect_target | default(True) notify: - - Reload nginx + - systemctl reload nginx tags: - configuration - nginx @@ -42,7 +42,7 @@ group: root mode: 'u=rw,g=r,o=r' notify: - - Reload nginx + - systemctl reload nginx tags: - configuration - nginx @@ -57,7 +57,7 @@ group: root mode: 'u=rw,g=r,o=r' notify: - - Reload nginx + - systemctl reload nginx tags: - configuration - nginx @@ -72,7 +72,7 @@ group: root mode: 'u=rw,g=r,o=r' notify: - - Reload nginx + - systemctl reload nginx tags: - configuration - nginx @@ -89,7 +89,7 @@ # with_items: '{{ site.snippets }}' # when: site.snippets | default([]) # notify: -# - Reload nginx +# - systemctl reload nginx # tags: # - configuration # - nginx @@ -103,7 +103,7 @@ state: link when: site.http_plain_template | default(True) notify: - - Reload nginx + - systemctl reload nginx tags: - configuration - nginx @@ -117,7 +117,7 @@ # dest: '/etc/nginx/sites-enabled/{{ site.name }}_tls' # state: link # notify: -# - Reload nginx +# - systemctl reload nginx # tags: # - configuration # - nginx