diff options
author | Paul Bonaud <paul.bonaud@fretlink.com> | 2019-01-04 18:31:43 +0100 |
---|---|---|
committer | Paul Bonaud <paul.bonaud@fretlink.com> | 2019-01-04 18:38:31 +0100 |
commit | ab4d465aa2541ccca2e4c0610b60e53ea9a29c21 (patch) | |
tree | 27c42af7e107b46820cd806979b1be7d1972c31f /tasks/main.yml | |
parent | e5697403dacf206a7fe99c2efa9fe03297785446 (diff) | |
download | ansible-clever-ab4d465aa2541ccca2e4c0610b60e53ea9a29c21.tar.gz ansible-clever-ab4d465aa2541ccca2e4c0610b60e53ea9a29c21.tar.zst ansible-clever-ab4d465aa2541ccca2e4c0610b60e53ea9a29c21.zip |
fix: statically include sub tasks for 'tags' to work
In ansible the `include_tasks` loads the tasks dynamically. Thus it
does not apply the tag specified at the include level to all sub
tasks.
In order to make sure all included tasks inherit the specified `tags:`
we need to include the tasks files "statically". It is very similar to
cases where we have a `when:` condition that we want to apply to all
included subtasks. cf https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html#applying-when-to-roles-imports-and-includes
Diffstat (limited to 'tasks/main.yml')
-rw-r--r-- | tasks/main.yml | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/tasks/main.yml b/tasks/main.yml index b8b4446..8167762 100644 --- a/tasks/main.yml +++ b/tasks/main.yml | |||
@@ -1,19 +1,19 @@ | |||
1 | --- | 1 | --- |
2 | # tasks file for clever | 2 | # tasks file for clever |
3 | - name: Setup environment for clever | 3 | - name: Setup environment for clever |
4 | include_tasks: setup.yml | 4 | import_tasks: setup.yml |
5 | tags: | 5 | tags: |
6 | - clever | 6 | - clever |
7 | - clever-setup | 7 | - clever-setup |
8 | 8 | ||
9 | - name: Login to clever | 9 | - name: Login to clever |
10 | include_tasks: login.yml | 10 | import_tasks: login.yml |
11 | tags: | 11 | tags: |
12 | - clever | 12 | - clever |
13 | - clever-login | 13 | - clever-login |
14 | 14 | ||
15 | - name: Manage environment | 15 | - name: Manage environment |
16 | include_tasks: environment.yml | 16 | import_tasks: environment.yml |
17 | tags: | 17 | tags: |
18 | - clever | 18 | - clever |
19 | - clever-env | 19 | - clever-env |
@@ -21,18 +21,15 @@ | |||
21 | - name: Include specific tasks | 21 | - name: Include specific tasks |
22 | include_tasks: "{{ clever_app_tasks_file }}" | 22 | include_tasks: "{{ clever_app_tasks_file }}" |
23 | when: clever_app_tasks_file is defined | 23 | when: clever_app_tasks_file is defined |
24 | tags: | ||
25 | - clever | ||
26 | - clever-specific-role | ||
27 | 24 | ||
28 | - name: Deploy app | 25 | - name: Deploy app |
29 | include_tasks: deploy.yml | 26 | import_tasks: deploy.yml |
30 | tags: | 27 | tags: |
31 | - clever | 28 | - clever |
32 | - clever-deploy | 29 | - clever-deploy |
33 | 30 | ||
34 | - name: Post deploy tasks | 31 | - name: Post deploy tasks |
35 | include_tasks: post_deploy.yml | 32 | import_tasks: post_deploy.yml |
36 | tags: | 33 | tags: |
37 | - clever | 34 | - clever |
38 | - clever-deploy | 35 | - clever-deploy |