Merge "Composable Zaqar services"
[apex-tripleo-heat-templates.git] / puppet / major_upgrade_steps.j2.yaml
1 heat_template_version: 2016-10-14
2 description: 'Upgrade steps for all roles'
3
4 parameters:
5   servers:
6     type: json
7
8   role_data:
9     type: json
10     description: Mapping of Role name e.g Controller to the per-role data
11
12   UpdateIdentifier:
13     type: string
14     description: >
15       Setting to a previously unused value during stack-update will trigger
16       the Upgrade resources to re-run on all roles.
17
18   UpgradeInitCommand:
19     type: string
20     description: |
21       Command or script snippet to run on all overcloud nodes to
22       initialize the upgrade process. E.g. a repository switch.
23     default: ''
24
25 resources:
26
27   # For the UpgradeInit also rename /etc/resolv.conf.save for +bug/1567004
28   UpgradeInitConfig:
29     type: OS::Heat::SoftwareConfig
30     properties:
31       group: script
32       config:
33         list_join:
34         - ''
35         - - "#!/bin/bash\n\n"
36           - "if [[ -f /etc/resolv.conf.save ]] ; then rm /etc/resolv.conf.save; fi\n\n"
37           - get_param: UpgradeInitCommand
38
39 {% for role in roles %}
40   {{role.name}}Upgrade_Init:
41     type: OS::Heat::StructuredDeploymentGroup
42     properties:
43       name: {{role.name}}Upgrade_Init
44       servers: {get_param: [servers, {{role.name}}]}
45       config: {get_resource: UpgradeInitConfig}
46 {% endfor %}
47
48 # Upgrade Steps for all roles
49 # FIXME(shardy): would be nice to make the number of steps configurable
50 {% for step in range(1, 8) %}
51   {% for role in roles %}
52   # Step {{step}} resources
53   {{role.name}}UpgradeConfig_Step{{step}}:
54     type: OS::TripleO::UpgradeConfig
55   # The UpgradeConfig resources could actually be created without
56   # serialization, but the event output is easier to follow if we
57   # do, and there should be minimal performance hit (creating the
58   # config is cheap compared to the time to apply the deployment).
59     depends_on:
60   {% if step == 1 %}
61       - {{role.name}}Upgrade_Init
62   {% else %}
63       {% for dep in roles %}
64       - {{dep.name}}Upgrade_Step{{step -1}}
65       {% endfor %}
66   {% endif %}
67     properties:
68       UpgradeStepConfig: {get_param: [role_data, {{role.name}}, upgrade_tasks]}
69       step: {{step}}
70
71   {{role.name}}Upgrade_Step{{step}}:
72     type: OS::Heat::StructuredDeploymentGroup
73   {% if step > 1 %}
74     depends_on:
75       {% for dep in roles %}
76       - {{dep.name}}Upgrade_Step{{step -1}}
77       {% endfor %}
78   {% endif %}
79     properties:
80       name: {{role.name}}Upgrade_Step{{step}}
81       servers: {get_param: [servers, {{role.name}}]}
82       config: {get_resource: {{role.name}}UpgradeConfig_Step{{step}}}
83       input_values:
84         role: {{role.name}}
85         update_identifier: {get_param: UpdateIdentifier}
86   {% endfor %}
87 {% endfor %}
88
89 outputs:
90   # Output the config for each role, just use Step1 as the config should be
91   # the same for all steps (only the tag provided differs)
92   upgrade_configs:
93     description: The per-role upgrade configuration used
94     value:
95 {% for role in roles %}
96       {{role.name.lower()}}: {get_attr: [{{role.name}}UpgradeConfig_Step1, upgrade_config]}
97 {% endfor %}
98