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