From ab4d465aa2541ccca2e4c0610b60e53ea9a29c21 Mon Sep 17 00:00:00 2001 From: Paul Bonaud Date: Fri, 4 Jan 2019 18:31:43 +0100 Subject: 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 --- tasks/main.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'tasks/main.yml') 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 -- cgit v1.2.3