From 14d57fc477df08d6cb8172e00fd0398880acae7d Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Thu, 10 Aug 2023 22:44:47 +0200 Subject: [PATCH] roles/nginx: reformat main tasks --- roles/nginx/tasks/main.yml | 73 +++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 13 deletions(-) diff --git a/roles/nginx/tasks/main.yml b/roles/nginx/tasks/main.yml index 723482e..2deee49 100644 --- a/roles/nginx/tasks/main.yml +++ b/roles/nginx/tasks/main.yml @@ -1,13 +1,25 @@ --- - name: Add nginx.org apt signing key - ansible.builtin.apt_key: id=0x573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 url=https://nginx.org/keys/nginx_signing.key state=present + ansible.builtin.apt_key: + id: 0x573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 + url: https://nginx.org/keys/nginx_signing.key + state: present register: add_nginx_apt_key - tags: nginx, packages + tags: + - nginx + - packages - name: Add nginx.org repo - ansible.builtin.template: src=nginx_org_sources.list.j2 dest=/etc/apt/sources.list.d/nginx_org_sources.list owner=root group=root mode=0644 + ansible.builtin.template: + src: nginx_org_sources.list.j2 + dest: /etc/apt/sources.list.d/nginx_org_sources.list + owner: root + group: root + mode: 0644 register: add_nginx_apt_repository - tags: nginx, packages + tags: + - nginx + - packages - name: Update apt cache ansible.builtin.apt: @@ -17,17 +29,32 @@ add_nginx_apt_repository is changed - name: Install nginx - ansible.builtin.apt: pkg=nginx cache_valid_time=3600 state=present - tags: nginx, packages + ansible.builtin.apt: + pkg: nginx + cache_valid_time: 3600 + state: present + tags: + - nginx + - packages - name: Copy nginx.conf - ansible.builtin.template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf mode=0644 owner=root group=root + ansible.builtin.template: + src: nginx.conf.j2 + dest: /etc/nginx/nginx.conf + mode: 0644 + owner: root + group: root notify: - reload nginx tags: nginx - name: Copy extra nginx configs - ansible.builtin.copy: src={{ item }} dest=/etc/nginx/{{ item }} mode=0644 owner=root group=root + ansible.builtin.copy: + src: "{{ item }}" + dest: "/etc/nginx/{{ item }}" + mode: 0644 + owner: root + group: root loop: - extra-security.conf - fastcgi_cache @@ -36,11 +63,18 @@ tags: nginx - name: Remove default nginx vhost - ansible.builtin.file: path=/etc/nginx/conf.d/default.conf state=absent + ansible.builtin.file: + path: /etc/nginx/conf.d/default.conf + state: absent tags: nginx - name: Create fastcgi cache dir - ansible.builtin.file: path=/var/cache/nginx/cached/fastcgi state=directory owner=nginx group=nginx mode=0755 + ansible.builtin.file: + path: /var/cache/nginx/cached/fastcgi + state: directory + owner: nginx + group: nginx + mode: 0755 tags: nginx - name: Configure nginx virtual hosts @@ -54,19 +88,32 @@ tags: wordpress - name: Configure blank nginx vhost - ansible.builtin.template: src=blank-vhost.conf.j2 dest={{ nginx_confd_path }}/blank-vhost.conf mode=0644 owner=root group=root + ansible.builtin.template: + src: blank-vhost.conf.j2 + dest: "{{ nginx_confd_path }}/blank-vhost.conf" + mode: 0644 + owner: root + group: root notify: - reload nginx tags: nginx - name: Configure munin vhost - ansible.builtin.copy: src=munin.conf dest=/etc/nginx/conf.d/munin.conf mode=0644 owner=root group=root + ansible.builtin.copy: + src: munin.conf + dest: /etc/nginx/conf.d/munin.conf + mode: 0644 + owner: root + group: root notify: - reload nginx tags: nginx - name: Start and enable nginx service - ansible.builtin.systemd: name=nginx state=started enabled=true + ansible.builtin.systemd: + name: nginx + state: started + enabled: true tags: nginx - name: Configure Let's Encrypt