From: Paul Bonaud Date: Fri, 4 Jan 2019 17:31:43 +0000 (+0100) Subject: fix: statically include sub tasks for 'tags' to work X-Git-Tag: v1.14~2^2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=ab4d465aa2541ccca2e4c0610b60e53ea9a29c21;hp=-c;p=github%2Ffretlink%2Fansible-clever.git 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 --- ab4d465aa2541ccca2e4c0610b60e53ea9a29c21 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 @@ --- # 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 @@ -21,18 +21,15 @@ - 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