Merge "net-config-multinode: make controlplane int idempotent"
[apex-tripleo-heat-templates.git] / puppet / major_upgrade_steps.j2.yaml
1 {% set upgrade_steps_max = 8 -%}
2 {% set enabled_roles = roles|rejectattr('disable_upgrade_deployment')|list -%}
3 heat_template_version: ocata
4 description: 'Upgrade steps for all roles'
5
6 parameters:
7   servers:
8     type: json
9
10   role_data:
11     type: json
12     description: Mapping of Role name e.g Controller to the per-role data
13
14   UpdateIdentifier:
15     type: string
16     description: >
17       Setting to a previously unused value during stack-update will trigger
18       the Upgrade resources to re-run on all roles.
19
20 conditions:
21   # Conditions to disable any steps where the task list is empty
22 {% for step in range(0, upgrade_steps_max) %}
23   {% for role in roles %}
24   UpgradeBatchConfig_Step{{step}}Enabled:
25     not:
26       equals:
27         - {get_param: [role_data, {{role.name}}, upgrade_batch_tasks]}
28         - []
29   UpgradeConfig_Step{{step}}Enabled:
30     not:
31       equals:
32         - {get_param: [role_data, {{role.name}}, upgrade_tasks]}
33         - []
34   {% endfor %}
35 {% endfor %}
36
37 resources:
38
39 # Upgrade Steps for all roles, batched updates
40 # FIXME(shardy): would be nice to make the number of steps configurable
41 {% for step in range(0, upgrade_steps_max) %}
42   {% for role in roles %}
43   # Step {{step}} resources
44   {{role.name}}UpgradeBatchConfig_Step{{step}}:
45     type: OS::TripleO::UpgradeConfig
46     condition: UpgradeBatchConfig_Step{{step}}Enabled
47   # The UpgradeConfig resources could actually be created without
48   # serialization, but the event output is easier to follow if we
49   # do, and there should be minimal performance hit (creating the
50   # config is cheap compared to the time to apply the deployment).
51   {% if step > 0 %}
52     depends_on:
53       {% for dep in roles %}
54       - {{dep.name}}UpgradeBatch_Step{{step -1}}
55       {% endfor %}
56   {% endif %}
57     properties:
58       UpgradeStepConfig: {get_param: [role_data, {{role.name}}, upgrade_batch_tasks]}
59       step: {{step}}
60
61   {{role.name}}UpgradeBatch_Step{{step}}:
62     type: OS::Heat::StructuredDeploymentGroup
63     condition: UpgradeBatchConfig_Step{{step}}Enabled
64   {% if step > 0 %}
65     depends_on:
66       {% for dep in roles %}
67       - {{dep.name}}UpgradeBatch_Step{{step -1}}
68       {% endfor %}
69   {% endif %}
70     update_policy:
71       batch_create:
72         max_batch_size: {{role.upgrade_batch_size|default(1)}}
73       rolling_update:
74         max_batch_size: {{role.upgrade_batch_size|default(1)}}
75     properties:
76       name: {{role.name}}UpgradeBatch_Step{{step}}
77       servers: {get_param: [servers, {{role.name}}]}
78       config: {get_resource: {{role.name}}UpgradeBatchConfig_Step{{step}}}
79       input_values:
80         role: {{role.name}}
81         update_identifier: {get_param: UpdateIdentifier}
82   {% endfor %}
83 {% endfor %}
84
85 # Upgrade Steps for all roles
86 # FIXME(shardy): would be nice to make the number of steps configurable
87 {% for step in range(0, upgrade_steps_max) %}
88   {% for role in roles %}
89   # Step {{step}} resources
90   {{role.name}}UpgradeConfig_Step{{step}}:
91     type: OS::TripleO::UpgradeConfig
92     condition: UpgradeConfig_Step{{step}}Enabled
93   # The UpgradeConfig resources could actually be created without
94   # serialization, but the event output is easier to follow if we
95   # do, and there should be minimal performance hit (creating the
96   # config is cheap compared to the time to apply the deployment).
97     depends_on:
98   {% if step > 0 %}
99       {% for dep in roles %}
100         {% if not dep.disable_upgrade_deployment|default(false) %}
101       - {{dep.name}}Upgrade_Step{{step -1}}
102         {% endif %}
103       {% endfor %}
104   {% else %}
105       {% for dep in roles %}
106       - {{dep.name}}UpgradeBatch_Step{{upgrade_steps_max -1}}
107       {% endfor %}
108   {% endif %}
109     properties:
110       UpgradeStepConfig: {get_param: [role_data, {{role.name}}, upgrade_tasks]}
111       step: {{step}}
112   {% if not role.disable_upgrade_deployment|default(false) %}
113   {{role.name}}Upgrade_Step{{step}}:
114     type: OS::Heat::StructuredDeploymentGroup
115     condition: UpgradeConfig_Step{{step}}Enabled
116     depends_on:
117   {% if step > 0 %}
118       {% for dep in roles %}
119         {% if not dep.disable_upgrade_deployment|default(false) %}
120       - {{dep.name}}Upgrade_Step{{step -1}}
121         {% endif %}
122       {% endfor %}
123   {% else %}
124       {% for dep in roles %}
125       - {{dep.name}}UpgradeBatch_Step{{upgrade_steps_max -1}}
126       {% endfor %}
127   {% endif %}
128     properties:
129       name: {{role.name}}Upgrade_Step{{step}}
130       servers: {get_param: [servers, {{role.name}}]}
131       config: {get_resource: {{role.name}}UpgradeConfig_Step{{step}}}
132       input_values:
133         role: {{role.name}}
134         update_identifier: {get_param: UpdateIdentifier}
135   {% endif %}
136   {% endfor %}
137 {% endfor %}
138
139   # Post upgrade deployment steps for all roles
140   # This runs the normal configuration (e.g puppet) steps unless upgrade
141   # is disabled for the role
142   AllNodesPostUpgradeSteps:
143     type: OS::TripleO::PostUpgradeSteps
144     depends_on:
145 {%- for dep in enabled_roles %}
146       - {{dep.name}}Upgrade_Step{{upgrade_steps_max - 1}}
147 {%- endfor %}
148     properties:
149       servers: {get_param: servers}
150       role_data: {get_param: role_data}
151
152 outputs:
153   # Output the config for each role, just use Step1 as the config should be
154   # the same for all steps (only the tag provided differs)
155   upgrade_configs:
156     description: The per-role upgrade configuration used
157     value:
158 {% for role in roles %}
159       {{role.name.lower()}}: {get_attr: [{{role.name}}UpgradeConfig_Step1, upgrade_config]}
160 {% endfor %}
161