]> git.immae.eu Git - github/fretlink/ansible-clever.git/commitdiff
fix: statically include sub tasks for 'tags' to work 31/head
authorPaul Bonaud <paul.bonaud@fretlink.com>
Fri, 4 Jan 2019 17:31:43 +0000 (18:31 +0100)
committerPaul Bonaud <paul.bonaud@fretlink.com>
Fri, 4 Jan 2019 17:38:31 +0000 (18:38 +0100)
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

tasks/main.yml

index b8b4446f3acc7a4df1ea74a83333ada4eb82072a..8167762a649a1feee1c0be537c4b738c06d09a8c 100644 (file)
@@ -1,19 +1,19 @@
 ---
 # tasks file for clever
 - name: Setup environment for clever
-  include_tasks: setup.yml
+  import_tasks: setup.yml
   tags:
     - clever
     - clever-setup
 
 - name: Login to clever
-  include_tasks: login.yml
+  import_tasks: login.yml
   tags:
     - clever
     - clever-login
 
 - name: Manage environment
-  include_tasks: environment.yml
+  import_tasks: environment.yml
   tags:
     - clever
     - clever-env
 - name: Include specific tasks
   include_tasks: "{{ clever_app_tasks_file }}"
   when: clever_app_tasks_file is defined
-  tags:
-    - clever
-    - clever-specific-role
 
 - name: Deploy app
-  include_tasks: deploy.yml
+  import_tasks: deploy.yml
   tags:
    - clever
    - clever-deploy
 
 - name: Post deploy tasks
-  include_tasks: post_deploy.yml
+  import_tasks: post_deploy.yml
   tags:
    - clever
    - clever-deploy