{% set enabled_roles = roles|rejectattr('disable_upgrade_deployment')|list -%} {% set batch_upgrade_steps_max = 3 -%} {% set upgrade_steps_max = 6 -%} 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 role in roles %} {{role.name}}UpgradeBatchConfigEnabled: not: equals: - {get_param: [role_data, {{role.name}}, upgrade_batch_tasks]} - [] {{role.name}}UpgradeConfigEnabled: not: equals: - {get_param: [role_data, {{role.name}}, upgrade_tasks]} - [] {%- endfor %} resources: # Upgrade Steps for all roles, batched updates # 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). {% for step in range(0, batch_upgrade_steps_max) %} # Batch config resources step {{step}} {%- for role in roles %} {{role.name}}UpgradeBatchConfig_Step{{step}}: type: OS::TripleO::UpgradeConfig {%- if step > 0 %} depends_on: {%- for dep in enabled_roles %} - {{dep.name}}UpgradeBatch_Step{{step -1}} {%- endfor %} {%- endif %} properties: UpgradeStepConfig: {get_param: [role_data, {{role.name}}, upgrade_batch_tasks]} step: {{step}} {%- endfor %} # Batch deployment resources for step {{step}} (only for enabled roles) {%- for role in enabled_roles %} {{role.name}}UpgradeBatch_Step{{step}}: type: OS::Heat::SoftwareDeploymentGroup condition: {{role.name}}UpgradeBatchConfigEnabled {%- if step > 0 %} depends_on: {%- for dep in enabled_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 {%- for step in range(0, upgrade_steps_max) %} # Config resources for step {{step}} {%- for role in roles %} {{role.name}}UpgradeConfig_Step{{step}}: type: OS::TripleO::UpgradeConfig # 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 enabled_roles %} - {{dep.name}}Upgrade_Step{{step -1}} {%- endfor %} {%- else %} {%- for dep in enabled_roles %} - {{dep.name}}UpgradeBatch_Step{{batch_upgrade_steps_max -1}} {%- endfor %} {%- endif %} properties: UpgradeStepConfig: {get_param: [role_data, {{role.name}}, upgrade_tasks]} step: {{step}} {%- endfor %} # Deployment resources for step {{step}} (only for enabled roles) {%- for role in enabled_roles %} {{role.name}}Upgrade_Step{{step}}: type: OS::Heat::SoftwareDeploymentGroup condition: {{role.name}}UpgradeConfigEnabled depends_on: {%- if step > 0 %} {%- for dep in enabled_roles %} - {{dep.name}}Upgrade_Step{{step -1}} {%- endfor %} {%- else %} {%- for dep in enabled_roles %} - {{dep.name}}UpgradeBatch_Step{{batch_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} {%- 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 %}