From c2685732a4d09a1be6b6833ae5bf0d64815dac80 Mon Sep 17 00:00:00 2001 From: Emilien Mantel Date: Thu, 15 Mar 2018 18:06:38 +0100 Subject: [PATCH] Manages Ansible 2.4+ with Docker Closes #30 --- handlers/main.yml | 18 ++++++++++++++++-- tasks/ssl/acme.yml | 10 +++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index ebb10f9..f4c5254 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -2,21 +2,35 @@ - name: reload nginx command: nginx -t - notify: real-reload nginx + notify: + - real-reload nginx + - docker reload nginx - name: restart nginx command: nginx -t - notify: real-restart nginx + notify: + - real-restart nginx + - docker restart nginx - name: real-reload nginx service: name: nginx state: reloaded + when: ansible_virtualization_type != 'docker' - name: real-restart nginx service: name: nginx state: restarted + when: ansible_virtualization_type != 'docker' + +- name: docker reload nginx + command: service nginx reload + when: ansible_virtualization_type == 'docker' + +- name: docker restart nginx + command: service nginx restart + when: ansible_virtualization_type == 'docker' - name: restart nginx freebsd service: diff --git a/tasks/ssl/acme.yml b/tasks/ssl/acme.yml index a64e26f..dea956d 100644 --- a/tasks/ssl/acme.yml +++ b/tasks/ssl/acme.yml @@ -48,11 +48,15 @@ with_items: "{{ acme_create }}" register: fake_site -- name: SERVICE | Reload nginx +- name: SERVICE | Restart nginx service: name: nginx - state: reloaded - when: fake_site.changed + state: restarted + when: fake_site.changed and ansible_virtualization_type != 'docker' + +- name: COMMAND | Restart nginx + command: service nginx restart + when: fake_site.changed and ansible_virtualization_type == 'docker' - name: SHELL | Get certificates shell: '{{ nginx_acmesh_bin }} --issue{% if item.name is string %} -d {{ item.name }}{% else %}{% for name in item.name %} -d {{ name }}{% endfor %}{% endif %} --nginx {% if nginx_acmesh_test %}--test{% endif %}'