diff --git a/haproxy/tasks/haproxy-letsencrypt-acmetool.yml b/haproxy/tasks/haproxy-letsencrypt-acmetool.yml new file mode 100644 index 00000000..67b0ced2 --- /dev/null +++ b/haproxy/tasks/haproxy-letsencrypt-acmetool.yml @@ -0,0 +1,8 @@ +--- +- name: Install a script that fix the letsencrypt certificate for haproxy and then reload the service + copy: src=haproxy-letsencrypt-acme.sh dest={{ letsencrypt_acme_services_scripts_dir }}/haproxy owner=root group=root mode=4555 + when: + - haproxy_letsencrypt_managed + - letsencrypt_acme_install + tags: [ 'haproxy', 'letsencrypt' ] + diff --git a/haproxy/tasks/haproxy-letsencrypt.yml b/haproxy/tasks/haproxy-letsencrypt.yml index d98dc8b3..d95ac98b 100644 --- a/haproxy/tasks/haproxy-letsencrypt.yml +++ b/haproxy/tasks/haproxy-letsencrypt.yml @@ -5,11 +5,3 @@ - haproxy_letsencrypt_managed - letsencrypt_install tags: [ 'haproxy', 'letsencrypt' ] - -- name: Install a script that fix the letsencrypt certificate for haproxy and then reload the service - copy: src=haproxy-letsencrypt-acme.sh dest={{ letsencrypt_acme_services_scripts_dir }}/haproxy owner=root group=root mode=4550 - when: - - haproxy_letsencrypt_managed - - letsencrypt_acme_install - tags: [ 'haproxy', 'letsencrypt' ] - diff --git a/haproxy/tasks/main.yml b/haproxy/tasks/main.yml index cdf9d555..8c2f9fd1 100644 --- a/haproxy/tasks/main.yml +++ b/haproxy/tasks/main.yml @@ -1,4 +1,10 @@ --- - include: haproxy-service.yml - include: haproxy-letsencrypt.yml - when: haproxy_letsencrypt_managed + when: + - haproxy_letsencrypt_managed + - letsencrypt_install is defined +- include: haproxy-letsencrypt-acmetool.yml + when: + - haproxy_letsencrypt_managed + - letsencrypt_acme_install is defined diff --git a/letsencrypt-acmetool-client/handlers/main.yml b/letsencrypt-acmetool-client/handlers/main.yml new file mode 100644 index 00000000..c4309b3b --- /dev/null +++ b/letsencrypt-acmetool-client/handlers/main.yml @@ -0,0 +1,9 @@ +--- +- name: Initialize letsencrypt acmetool + become: True + become_user: '{{ letsencrypt_acme_user }}' + command: '{{ letsencrypt_acme_command }} {{ letsencrypt_acme_command_opts }} quickstart ; {{ letsencrypt_acme_command }} {{ letsencrypt_acme_command_opts }} reconcile' + args: + creates: '{{ letsencrypt_acme_user_home }}/accounts' + when: letsencrypt_acme_install + diff --git a/letsencrypt-acmetool-client/tasks/main.yml b/letsencrypt-acmetool-client/tasks/main.yml index 6e0272d0..faa108c3 100644 --- a/letsencrypt-acmetool-client/tasks/main.yml +++ b/letsencrypt-acmetool-client/tasks/main.yml @@ -4,6 +4,7 @@ when: - letsencrypt_acme_install - is_ubuntu + notify: Initialize letsencrypt acmetool tags: letsencrypt - name: Install the letsencrypt acmetool repo key on debian @@ -18,6 +19,7 @@ when: - letsencrypt_acme_install - is_debian + notify: Initialize letsencrypt acmetool tags: letsencrypt - name: Create the letsencrytp acme user @@ -82,24 +84,6 @@ - "'{{ letsencrypt_acme_authenticator }}' != 'listener'" tags: letsencrypt -- name: letsencrypt acmetool initializaztion - become: True - become_user: '{{ letsencrypt_acme_user }}' - command: '{{ letsencrypt_acme_command }} {{ letsencrypt_acme_command_opts }} quickstart' - args: - creates: '{{ letsencrypt_acme_user_home }}/accounts' - when: letsencrypt_acme_install - tags: letsencrypt - -- name: letsencrypt acmetool request the first certificate - become: True - become_user: '{{ letsencrypt_acme_user }}' - command: '{{ letsencrypt_acme_command }} {{ letsencrypt_acme_command_opts }} reconcile' - args: - creates: '{{ letsencrypt_acme_certs_dir }}/cert' - when: letsencrypt_acme_install - tags: letsencrypt - - name: Install the sudoers config needed to run the acmetool hooks template: src=acme-sudoers.j2 dest=/etc/sudoers.d/letsencrypt-acme owner=root group=root mode=0440 when: letsencrypt_acme_install @@ -110,3 +94,23 @@ when: letsencrypt_acme_install tags: letsencrypt +- name: letsencrypt acmetool initializaztion + become: True + become_user: '{{ letsencrypt_acme_user }}' + command: '{{ letsencrypt_acme_command }} {{ letsencrypt_acme_command_opts }} quickstart' + args: + creates: '{{ letsencrypt_acme_user_home }}/accounts' + when: letsencrypt_acme_install + ignore_errors: True + tags: letsencrypt + +- name: letsencrypt acmetool request the first certificate + become: True + become_user: '{{ letsencrypt_acme_user }}' + command: '{{ letsencrypt_acme_command }} {{ letsencrypt_acme_command_opts }} reconcile' + args: + creates: '{{ letsencrypt_acme_certs_dir }}/cert' + when: letsencrypt_acme_install + ignore_errors: True + tags: letsencrypt +