Skip to content

Commit

Permalink
Change DH file if length updated
Browse files Browse the repository at this point in the history
  • Loading branch information
HanXHX committed Feb 12, 2019
1 parent c121139 commit a021888
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions tasks/ssl/standard.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
---

- name: COMMAND | Generate DH file
command: openssl dhparam -out {{ nginx_dh_path }} {{ nginx_dh_length }}
args:
creates: "{{ nginx_dh_path }}"
- block:

- name: STAT | Get info ajout DH file
stat:
path: "{{ nginx_dh_path }}"
get_checksum: no
register: stat_dh_file

- name: SHELL | Get info about DH file
shell: openssl dhparam -in {{ nginx_dh_path }} -text -noout 2>&1 | awk '/DH Parameters/ { print substr($3, 2) }'
changed_when: false
register: dh_info
when: stat_dh_file.stat.exists

- name: COMMAND | Generate DH file
command: openssl dhparam -out {{ nginx_dh_path }} {{ nginx_dh_length }}
when: not stat_dh_file.stat.exists or (dh_info.stdout | int != nginx_dh_length | int)
notify: restart nginx

when: nginx_dh is not string
notify: restart nginx
async: 1000
register: dh

- name: COPY | Deploy DH file from vars
copy:
Expand Down Expand Up @@ -53,11 +65,3 @@
when: item.self_signed is defined
notify: restart nginx
no_log: not nginx_debug_role

- name: Check DH command status
async_status:
jid: "{{ dh.ansible_job_id }}"
register: job_result
until: job_result.finished
retries: 30
when: not ansible_check_mode and nginx_dh is not string

0 comments on commit a021888

Please sign in to comment.