roles/nginx: Use dynamic includes for tasks

As of Ansible 2.4 and 2.5 the behavior for importing tasks has changed
to introduce the notion of static imports and dynamic includes. If the
tasks doing the import is using variable interpolation or conditionals
then the task should be dynamic. This results in quicker playbook runs
due to less importing of unneccessary tasks.

One side effect of this is that child tasks of dynamic includes do not
inherit their parents' tags so you must tag them explicitly or a block.
This commit is contained in:
Alan Orth 2018-04-26 10:45:01 +03:00
parent c608331e3c
commit 2da7f39bb4
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
2 changed files with 32 additions and 30 deletions

View File

@ -35,7 +35,7 @@
tags: nginx tags: nginx
- name: Configure nginx virtual hosts - name: Configure nginx virtual hosts
import_tasks: vhosts.yml include_tasks: vhosts.yml
when: nginx_vhosts is defined when: nginx_vhosts is defined
tags: nginx tags: nginx

View File

@ -1,5 +1,6 @@
--- ---
- block:
- name: Configure https vhosts - name: Configure https vhosts
template: src=vhost.conf.j2 dest={{ nginx_confd_path }}/{{ item.domain_name }}.conf mode=0644 owner=root group=root template: src=vhost.conf.j2 dest={{ nginx_confd_path }}/{{ item.domain_name }}.conf mode=0644 owner=root group=root
loop: "{{ nginx_vhosts }}" loop: "{{ nginx_vhosts }}"
@ -35,5 +36,6 @@
- include_tasks: letsencrypt.yml - include_tasks: letsencrypt.yml
when: use_letsencrypt is defined and use_letsencrypt == True when: use_letsencrypt is defined and use_letsencrypt == True
tags: letsencrypt tags: letsencrypt
tags: nginx
# vim: set ts=2 sw=2: # vim: set ts=2 sw=2: