From 6f8b2db26a9b3d605b60a539e2e0c4333cbb12b4 Mon Sep 17 00:00:00 2001 From: James Slagle Date: Thu, 5 Dec 2019 11:00:55 -0500 Subject: [PATCH] Use include_tasks instead of import_tasks include_tasks is dynamic and the tasks are either included (or not) at runtime. This has the advantage that if a "when" keyword excludes the include_tasks, then all the tasks are excluded as a group. This is opposed to import_tasks which happen at playbook parse time. The "when" keyword is inherited by each individual task that was imported. While the two are functionally equivalent for these use cases, import_tasks ends up being much slower, since ansible then has to compute a much larger set of tasks to skip at runtime. Using include_tasks is much faster, even at small scale (~50 hosts). Change-Id: I2db81d39b3294aa2784a340562f10fd9bf3fe9ee --- common/deploy-steps-tasks-step-0.j2.yaml | 2 +- common/deploy-steps.j2 | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/deploy-steps-tasks-step-0.j2.yaml b/common/deploy-steps-tasks-step-0.j2.yaml index fa69689204..1f78d9a043 100644 --- a/common/deploy-steps-tasks-step-0.j2.yaml +++ b/common/deploy-steps-tasks-step-0.j2.yaml @@ -13,6 +13,6 @@ copy: src=container_puppet_script.yaml dest=/var/lib/container-puppet/container-puppet.sh force=yes mode=0755 setype=container_file_t {%- for role in roles %} -- import_tasks: {{role.name}}/deploy_steps_tasks.yaml +- include_tasks: {{role.name}}/deploy_steps_tasks.yaml when: tripleo_role_name == '{{role.name}}' {%- endfor %} diff --git a/common/deploy-steps.j2 b/common/deploy-steps.j2 index 4043677c5f..5948358bd6 100644 --- a/common/deploy-steps.j2 +++ b/common/deploy-steps.j2 @@ -513,7 +513,7 @@ outputs: docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET tasks: - - import_tasks: deploy_steps_tasks_step_0.yaml + - include_tasks: deploy_steps_tasks_step_0.yaml tags: - overcloud - deploy_steps @@ -772,7 +772,7 @@ outputs: debug: msg: Use --start-at-task 'Deploy step tasks for {{step}}' to resume from this task {%- for role in roles %} - - import_tasks: {{role.name}}/deploy_steps_tasks.yaml + - include_tasks: {{role.name}}/deploy_steps_tasks.yaml when: tripleo_role_name == '{{role.name}}' {%- endfor %} tags: @@ -835,7 +835,7 @@ outputs: stat: path: /var/lib/tripleo-config/container-startup-config-1.json register: container_startup_configs_json_stat - - import_tasks: common_deploy_steps_tasks.yaml + - include_tasks: common_deploy_steps_tasks.yaml when: (deploy_identifier is defined and deploy_identifier != "" and deploy_identifier is not none) or (container_startup_configs_json_stat is defined and not container_startup_configs_json_stat.stat.exists) tags: