diff --git a/roles/web_server/tasks/main.yml b/roles/web_server/tasks/main.yml index 5231de98a857f8f8c810a65b7cde8a08adfd63cc..1f33b0473f3bacf13d42f38867de597f47185f85 100644 --- a/roles/web_server/tasks/main.yml +++ b/roles/web_server/tasks/main.yml @@ -1,12 +1,12 @@ --- - name: Install nginx - apt: + ansible.builtin.apt: name: nginx state: present - name: Allow nginx user to traverse the directory with TLS private keys - user: + ansible.builtin.user: name: www-data append: true groups: ssl-cert @@ -14,7 +14,7 @@ - Restart nginx - name: Deploy nginx TLS private key - copy: + ansible.builtin.copy: dest: "/etc/ssl/private/{{ ansible_fqdn }}_https.key" content: "{{ default_https_tls_key }}" mode: "0640" @@ -24,7 +24,7 @@ - Restart nginx - name: Deploy nginx TLS certificate - copy: + ansible.builtin.copy: dest: "/etc/ssl/certs/{{ ansible_fqdn }}_https.pem" content: "{{ default_https_tls_certificate }}" mode: "0644" @@ -34,7 +34,7 @@ - Restart nginx - name: Generate the HTTPS server Diffie-Hellman parameter - openssl_dhparam: + community.crypto.openssl_dhparam: owner: root group: root mode: "0640" @@ -44,7 +44,7 @@ - Restart nginx - name: Deploy configuration file for checking certificate validity via cron - copy: + ansible.builtin.copy: content: "/etc/ssl/certs/{{ ansible_fqdn }}_https.pem" dest: "/etc/check_certificate/{{ ansible_fqdn }}_https.conf" owner: root @@ -52,7 +52,7 @@ mode: "0644" - name: Remove TLS protocol configuration from the main configuration file - lineinfile: + ansible.builtin.lineinfile: dest: "/etc/nginx/nginx.conf" backrefs: true regexp: "^\\s*ssl_protocols" @@ -61,7 +61,7 @@ - Restart nginx - name: Harden TLS by allowing only TLSv1.2 and PFS ciphers - template: + ansible.builtin.template: dest: "/etc/nginx/conf.d/tls.conf" src: "tls.conf.j2" owner: "root" @@ -71,7 +71,7 @@ - Restart nginx - name: Deploy script for verification of nginx vhost configurations - copy: + ansible.builtin.copy: src: "nginx_verify_site.sh" dest: "/usr/local/bin/nginx_verify_site.sh" owner: root @@ -79,7 +79,7 @@ mode: "0755" - name: Deploy default vhost configuration - template: + ansible.builtin.template: src: "nginx-default.j2" dest: "/etc/nginx/sites-available/default" owner: root @@ -90,7 +90,7 @@ - Restart nginx - name: Enable default website - file: + ansible.builtin.file: src: "/etc/nginx/sites-available/default" dest: "/etc/nginx/sites-enabled/default" state: link @@ -98,7 +98,7 @@ - Restart nginx - name: Deploy firewall configuration for web server - copy: + ansible.builtin.copy: src: "ferm_http.conf" dest: "/etc/ferm/conf.d/30-web.conf" owner: root @@ -108,7 +108,7 @@ - Restart ferm - name: Remove the default Debian html files - file: + ansible.builtin.file: path: "{{ item }}" state: absent with_items: @@ -116,7 +116,7 @@ - /var/www/html/ - name: Create directory for storing the default website page - file: + ansible.builtin.file: path: "/var/www/default/" state: directory owner: root @@ -124,7 +124,7 @@ mode: "0750" - name: Deploy the default index.html - template: + ansible.builtin.template: src: "index.html.j2" dest: /var/www/default/index.html owner: root @@ -132,13 +132,13 @@ mode: "0640" - name: Enable nginx service - service: + ansible.builtin.service: name: nginx enabled: true state: started - name: Install base packages for Python web applications - apt: + ansible.builtin.apt: name: - python3-setuptools - virtualenv @@ -146,12 +146,12 @@ state: present - name: Install base packages for PHP web applications - apt: + ansible.builtin.apt: name: "{{ php_fpm_package_name }}" state: present - name: Create directories for storing per-site socket files - file: + ansible.builtin.file: path: "/run/{{ item }}" state: directory owner: root @@ -162,7 +162,7 @@ - php - name: Create directories for storing per-site socket files on boot - copy: + ansible.builtin.copy: content: "d /run/{{ item.socket_dir }}/ 0750 root www-data - -" dest: "/etc/tmpfiles.d/{{ item.tmpfiles_d }}" owner: root @@ -175,7 +175,7 @@ tmpfiles_d: "{{ php_fpm_service_name }}.conf" - name: Create directory for storing PHP-FPM service configuration overrides - file: + ansible.builtin.file: path: "/etc/systemd/system/{{ php_fpm_service_name }}.service.d/" state: directory owner: root @@ -183,7 +183,7 @@ mode: "0755" - name: Configure PHP-FPM service to run with umask 0007 - copy: + ansible.builtin.copy: src: "php_fpm_umask.conf" dest: "/etc/systemd/system/{{ php_fpm_service_name }}.service.d/umask.conf" owner: root @@ -194,18 +194,18 @@ - Restart PHP-FPM - name: Enable service used for running PHP web applications - service: + ansible.builtin.service: name: "{{ php_fpm_service_name }}" enabled: true state: started - name: Read timezone on server - slurp: + ansible.builtin.slurp: src: "/etc/timezone" register: server_timezone - name: Configure timezone for PHP - template: + ansible.builtin.template: src: "php_timezone.ini.j2" dest: "{{ item }}/30-timezone.ini" owner: root @@ -218,7 +218,7 @@ - Restart PHP-FPM - name: Explicitly run all handlers - include_tasks: ../handlers/main.yml + ansible.builtin.include_tasks: ../handlers/main.yml when: "run_handlers | default(False) | bool()" tags: - handlers