---

- name: Prepare Nginx
  hosts: localhost
  connection: local
  vars_files:
    - config.build.yaml
    - config.defaults.yaml
    - ../config.yaml

  tasks:
    - import_tasks: tasks_check_settings.yaml

    - name: Prepare Diffie-Hellman parameters file
      block:
        - name: Check that the Diffie-Hellman parameters file is exists
          stat:
            path: ./dist/conf/nginx/dhparams.pem
          register: dhparams_stat_result

        - name: Generate Diffie-Hellman parameters file with 2048 bits size. IT MAY TAKE A LONG TIME!
          # https://docs.ansible.com/ansible/2.9/modules/openssl_dhparam_module.html
          openssl_dhparam:
            path: ./dist/conf/nginx/dhparams.pem
            size: 2048
            state: present
            #owner:
            #group:
            #mode:
          when: not dhparams_stat_result.stat.exists
