[update/upgrade] 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).

This is applying what was done in https://review.opendev.org/697510
to the update/upgrade tasks.

When doing include_tasks, we ensure that we also apply the 'always' tag
so that we have access to use the tags in the included task files. See
[a] for further details.

[a] https://odyssey4.me/2019/11/26/ansible-include-tags.html

Change-Id: I2eab008ca27546acbd2b1275f07bcca0b84b858c
(cherry picked from commit 3040a61411)
This commit is contained in:
Jesse Pretorius (odyssey4me)
2020-02-21 12:10:02 +00:00
parent ea99331e7e
commit 2661ea24b7

View File

@@ -520,7 +520,7 @@ outputs:
docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT
docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET
tasks:
- include_tasks: deploy_steps_tasks_step_0.yaml
- import_tasks: deploy_steps_tasks_step_0.yaml
tags:
- overcloud
- deploy_steps
@@ -893,8 +893,10 @@ outputs:
external_post_deploy_steps_tasks: {get_attr: [ExternalPostDeployTasks, value]}
update_steps_tasks: |
{%- for role in roles %}
- import_tasks: {{role.name}}/update_tasks.yaml
- include_tasks: {{role.name}}/update_tasks.yaml
when: tripleo_role_name == '{{role.name}}'
tags:
- always
{%- endfor %}
update_steps_playbook:
str_replace:
@@ -981,8 +983,12 @@ outputs:
with_sequence: start=0 end={{update_steps_max-1}}
loop_control:
loop_var: step
- import_tasks: {{role.name}}/host_prep_tasks.yaml
tags:
- always
- include_tasks: {{role.name}}/host_prep_tasks.yaml
when: tripleo_role_name == '{{role.name}}'
tags:
- always
- import_tasks: deploy_steps_tasks_step_0.yaml
vars:
step: 0
@@ -991,10 +997,14 @@ outputs:
with_sequence: start=1 end={{deploy_steps_max-1}}
loop_control:
loop_var: step
tags:
- always
- include_tasks: post_update_steps_tasks.yaml
with_sequence: start=0 end={{post_update_steps_max-1}}
loop_control:
loop_var: step
tags:
- always
{%- endfor %}
external_update_steps_tasks: {get_attr: [ExternalUpdateTasks, value]}
external_update_steps_playbook:
@@ -1113,8 +1123,10 @@ outputs:
{%- endfor %}
pre_upgrade_rolling_steps_tasks: |
{%- for role in roles %}
- import_tasks: {{role.name}}/pre_upgrade_rolling_tasks.yaml
- include_tasks: {{role.name}}/pre_upgrade_rolling_tasks.yaml
when: tripleo_role_name == '{{role.name}}'
tags:
- always
{%- endfor %}
pre_upgrade_rolling_steps_playbook:
str_replace:
@@ -1255,8 +1267,10 @@ outputs:
container_healthcheck_disabled: CONTAINER_HEALTHCHECK_DISABLED
tasks:
{%- for role in roles %}
- import_tasks: {{role.name}}/upgrade_tasks_step{{step}}.yaml
- include_tasks: {{role.name}}/upgrade_tasks_step{{step}}.yaml
when: tripleo_role_name == '{{role.name}}'
tags:
- always
{%- endfor %}
tags:
- upgrade_steps
@@ -1265,8 +1279,10 @@ outputs:
{%- endfor %}
post_upgrade_steps_tasks: |
{%- for role in roles %}
- import_tasks: {{role.name}}/post_upgrade_tasks.yaml
- include_tasks: {{role.name}}/post_upgrade_tasks.yaml
when: tripleo_role_name == '{{role.name}}'
tags:
- always
{%- endfor %}
post_upgrade_steps_playbook:
str_replace:
@@ -1609,6 +1625,8 @@ outputs:
{%- for role in roles %}
- include_tasks: {{role.name}}/fast_forward_post_upgrade_tasks.yaml
when: tripleo_role_name == '{{role.name}}'
tags:
- always
{%- endfor %}
- name: Openstack Heat Agents package update
package: name=openstack-heat-agents state=latest
@@ -1620,6 +1638,8 @@ outputs:
{%- for role in roles %}
- include_tasks: {{role.name}}/fast_forward_upgrade_tasks.yaml
when: tripleo_role_name == '{{role.name}}'
tags:
- always
{%- endfor %}
fast_forward_upgrade_bootstrap_tasks: |
- include_tasks: fast_forward_upgrade_bootstrap_role_tasks.yaml
@@ -1632,9 +1652,13 @@ outputs:
when:
- tripleo_role_name == '{{role.name}}'
- is_bootstrap_node|bool
tags:
- always
{%- endfor %}
post_update_steps_tasks: |
{%- for role in roles %}
- import_tasks: {{role.name}}/post_update_tasks.yaml
- include_tasks: {{role.name}}/post_update_tasks.yaml
when: tripleo_role_name == '{{role.name}}'
tags:
- always
{%- endfor %}