tripleo-heat-templates/puppet/major_upgrade_steps.j2.yaml
Steven Hardy 87af02d673 Disable puppet on upgrade for roles not upgrading
Where the role has disabled upgrades, we need to skip both the ansible and
puppet steps.  To do this we refactor the post.j2.yaml so that it can be
included in the upgrade template with an adjusted list of roles.

Note this requires https://review.openstack.org/#/c/425220/ - this
change will be required for local testing of this patch
(run mistral-db-mange populate after updating tripleo-common
and restart the mistral services, or update your repos and re-run
openstack undercloud install).

Partially-Implements: blueprint overcloud-upgrades-per-service
Change-Id: Ie7d0fa6fef3528bd93e6cde076b964ea8de3185a
2017-02-03 11:43:47 +00:00

162 lines
5.3 KiB
YAML

{% set upgrade_steps_max = 8 -%}
{% set enabled_roles = roles|rejectattr('disable_upgrade_deployment')|list -%}
heat_template_version: ocata
description: 'Upgrade steps for all roles'
parameters:
servers:
type: json
role_data:
type: json
description: Mapping of Role name e.g Controller to the per-role data
UpdateIdentifier:
type: string
description: >
Setting to a previously unused value during stack-update will trigger
the Upgrade resources to re-run on all roles.
conditions:
# Conditions to disable any steps where the task list is empty
{% for step in range(0, upgrade_steps_max) %}
{% for role in roles %}
UpgradeBatchConfig_Step{{step}}Enabled:
not:
equals:
- {get_param: [role_data, {{role.name}}, upgrade_batch_tasks]}
- []
UpgradeConfig_Step{{step}}Enabled:
not:
equals:
- {get_param: [role_data, {{role.name}}, upgrade_tasks]}
- []
{% endfor %}
{% endfor %}
resources:
# Upgrade Steps for all roles, batched updates
# FIXME(shardy): would be nice to make the number of steps configurable
{% for step in range(0, upgrade_steps_max) %}
{% for role in roles %}
# Step {{step}} resources
{{role.name}}UpgradeBatchConfig_Step{{step}}:
type: OS::TripleO::UpgradeConfig
condition: UpgradeBatchConfig_Step{{step}}Enabled
# The UpgradeConfig resources could actually be created without
# serialization, but the event output is easier to follow if we
# do, and there should be minimal performance hit (creating the
# config is cheap compared to the time to apply the deployment).
{% if step > 0 %}
depends_on:
{% for dep in roles %}
- {{dep.name}}UpgradeBatch_Step{{step -1}}
{% endfor %}
{% endif %}
properties:
UpgradeStepConfig: {get_param: [role_data, {{role.name}}, upgrade_batch_tasks]}
step: {{step}}
{{role.name}}UpgradeBatch_Step{{step}}:
type: OS::Heat::StructuredDeploymentGroup
condition: UpgradeBatchConfig_Step{{step}}Enabled
{% if step > 0 %}
depends_on:
{% for dep in roles %}
- {{dep.name}}UpgradeBatch_Step{{step -1}}
{% endfor %}
{% endif %}
update_policy:
batch_create:
max_batch_size: {{role.upgrade_batch_size|default(1)}}
rolling_update:
max_batch_size: {{role.upgrade_batch_size|default(1)}}
properties:
name: {{role.name}}UpgradeBatch_Step{{step}}
servers: {get_param: [servers, {{role.name}}]}
config: {get_resource: {{role.name}}UpgradeBatchConfig_Step{{step}}}
input_values:
role: {{role.name}}
update_identifier: {get_param: UpdateIdentifier}
{% endfor %}
{% endfor %}
# Upgrade Steps for all roles
# FIXME(shardy): would be nice to make the number of steps configurable
{% for step in range(0, upgrade_steps_max) %}
{% for role in roles %}
# Step {{step}} resources
{{role.name}}UpgradeConfig_Step{{step}}:
type: OS::TripleO::UpgradeConfig
condition: UpgradeConfig_Step{{step}}Enabled
# The UpgradeConfig resources could actually be created without
# serialization, but the event output is easier to follow if we
# do, and there should be minimal performance hit (creating the
# config is cheap compared to the time to apply the deployment).
depends_on:
{% if step > 0 %}
{% for dep in roles %}
{% if not dep.disable_upgrade_deployment|default(false) %}
- {{dep.name}}Upgrade_Step{{step -1}}
{% endif %}
{% endfor %}
{% else %}
{% for dep in roles %}
- {{dep.name}}UpgradeBatch_Step{{upgrade_steps_max -1}}
{% endfor %}
{% endif %}
properties:
UpgradeStepConfig: {get_param: [role_data, {{role.name}}, upgrade_tasks]}
step: {{step}}
{% if not role.disable_upgrade_deployment|default(false) %}
{{role.name}}Upgrade_Step{{step}}:
type: OS::Heat::StructuredDeploymentGroup
condition: UpgradeConfig_Step{{step}}Enabled
depends_on:
{% if step > 0 %}
{% for dep in roles %}
{% if not dep.disable_upgrade_deployment|default(false) %}
- {{dep.name}}Upgrade_Step{{step -1}}
{% endif %}
{% endfor %}
{% else %}
{% for dep in roles %}
- {{dep.name}}UpgradeBatch_Step{{upgrade_steps_max -1}}
{% endfor %}
{% endif %}
properties:
name: {{role.name}}Upgrade_Step{{step}}
servers: {get_param: [servers, {{role.name}}]}
config: {get_resource: {{role.name}}UpgradeConfig_Step{{step}}}
input_values:
role: {{role.name}}
update_identifier: {get_param: UpdateIdentifier}
{% endif %}
{% endfor %}
{% endfor %}
# Post upgrade deployment steps for all roles
# This runs the normal configuration (e.g puppet) steps unless upgrade
# is disabled for the role
AllNodesPostUpgradeSteps:
type: OS::TripleO::PostUpgradeSteps
depends_on:
{%- for dep in enabled_roles %}
- {{dep.name}}Upgrade_Step{{upgrade_steps_max - 1}}
{%- endfor %}
properties:
servers: {get_param: servers}
role_data: {get_param: role_data}
outputs:
# Output the config for each role, just use Step1 as the config should be
# the same for all steps (only the tag provided differs)
upgrade_configs:
description: The per-role upgrade configuration used
value:
{% for role in roles %}
{{role.name.lower()}}: {get_attr: [{{role.name}}UpgradeConfig_Step1, upgrade_config]}
{% endfor %}