Simplify jinja for primary_role_name

'disable_upgrade_deployment' to disable upgrades
has been dropped from roles_data since long.

Change-Id: I1e6c355c9fc28fed581525e42fb4ccacbfe8e896
This commit is contained in:
ramishra 2021-05-24 11:22:50 +05:30
parent 098df978cf
commit 5541696d4a
2 changed files with 19 additions and 28 deletions

View File

@ -1,18 +1,11 @@
# certain initialization steps (run in a container) will occur # certain initialization steps (run in a container) will occur
# on the role marked as primary controller or the first role listed # on the role marked as primary controller or the first role listed
{%- if enabled_roles is not defined or enabled_roles == [] -%} {%- set primary_role_name = roles[0].name -%}
# On upgrade certain roles can be disabled for operator driven upgrades {%- for role in roles if ('primary' in role.tags and 'controller' in role.tags) -%}
# See major_upgrade_steps.j2.yaml and post-upgrade.j2.yaml {%- if loop.first -%}
{%- set enabled_roles = roles -%} {%- set primary_role_name = role.name -%}
{%- endif -%}
{%- set primary_role = [enabled_roles[0]] -%}
{%- for role in enabled_roles -%}
{%- if 'primary' in role.tags and 'controller' in role.tags -%}
{%- set _ = primary_role.pop() -%}
{%- set _ = primary_role.append(role) -%}
{%- endif -%} {%- endif -%}
{%- endfor -%} {%- endfor -%}
{%- set primary_role_name = primary_role[0].name -%}
# primary role is: {{primary_role_name}} # primary role is: {{primary_role_name}}
{% set deploy_steps_max = 6 -%} {% set deploy_steps_max = 6 -%}
{% set update_steps_max = 6 -%} {% set update_steps_max = 6 -%}
@ -109,7 +102,7 @@ parameters:
type: string type: string
constraints: constraints:
- allowed_values: [ 'enforcing', 'permissive', 'disabled' ] - allowed_values: [ 'enforcing', 'permissive', 'disabled' ]
{% for role in enabled_roles %} {% for role in roles %}
{{role.name}}Count: {{role.name}}Count:
description: Number of {{role.name}} nodes to deploy description: Number of {{role.name}} nodes to deploy
type: number type: number
@ -249,7 +242,7 @@ parameter_groups:
- EnablePaunch - EnablePaunch
conditions: conditions:
{% for role in enabled_roles %} {% for role in roles %}
{{role.name}}NonZero: {{role.name}}NonZero:
not: not:
equals: equals:
@ -265,7 +258,7 @@ resources:
type: comma_delimited_list type: comma_delimited_list
value: value:
list_concat_unique: list_concat_unique:
{%- for role in enabled_roles %} {%- for role in roles %}
- if: - if:
- {{role.name}}NonZero - {{role.name}}NonZero
- get_param: [role_data, {{role.name}}, pre_deploy_step_tasks] - get_param: [role_data, {{role.name}}, pre_deploy_step_tasks]
@ -278,7 +271,7 @@ resources:
type: comma_delimited_list type: comma_delimited_list
value: value:
list_concat_unique: list_concat_unique:
{%- for role in enabled_roles %} {%- for role in roles %}
- if: - if:
- {{role.name}}NonZero - {{role.name}}NonZero
- get_param: [role_data, {{role.name}}, external_deploy_tasks] - get_param: [role_data, {{role.name}}, external_deploy_tasks]
@ -291,7 +284,7 @@ resources:
type: comma_delimited_list type: comma_delimited_list
value: value:
list_concat_unique: list_concat_unique:
{%- for role in enabled_roles %} {%- for role in roles %}
- if: - if:
- {{role.name}}NonZero - {{role.name}}NonZero
- get_param: [role_data, {{role.name}}, external_post_deploy_tasks] - get_param: [role_data, {{role.name}}, external_post_deploy_tasks]
@ -304,7 +297,7 @@ resources:
type: comma_delimited_list type: comma_delimited_list
value: value:
list_concat_unique: list_concat_unique:
{%- for role in enabled_roles %} {%- for role in roles %}
- get_param: [role_data, {{role.name}}, scale_tasks] - get_param: [role_data, {{role.name}}, scale_tasks]
{%- endfor %} {%- endfor %}
@ -314,7 +307,7 @@ resources:
type: comma_delimited_list type: comma_delimited_list
value: value:
list_concat_unique: list_concat_unique:
{%- for role in enabled_roles %} {%- for role in roles %}
- if: - if:
- {{role.name}}NonZero - {{role.name}}NonZero
- get_param: [role_data, {{role.name}}, external_update_tasks] - get_param: [role_data, {{role.name}}, external_update_tasks]
@ -327,7 +320,7 @@ resources:
type: comma_delimited_list type: comma_delimited_list
value: value:
list_concat_unique: list_concat_unique:
{%- for role in enabled_roles %} {%- for role in roles %}
- if: - if:
- {{role.name}}NonZero - {{role.name}}NonZero
- get_param: [role_data, {{role.name}}, external_upgrade_tasks] - get_param: [role_data, {{role.name}}, external_upgrade_tasks]
@ -346,8 +339,8 @@ resources:
expression: switch($.data = {} => "no_bootstrap_server", $.data != {} => $.data.items().orderBy($[0]).first()[1]) expression: switch($.data = {} => "no_bootstrap_server", $.data != {} => $.data.items().orderBy($[0]).first()[1])
data: {get_param: [servers, {{primary_role_name}}]} data: {get_param: [servers, {{primary_role_name}}]}
# BEGIN CONFIG STEPS, only on enabled_roles # BEGIN CONFIG STEPS, only on roles
{%- for role in enabled_roles %} {%- for role in roles %}
# Note, this should be the last step to execute configuration changes. # Note, this should be the last step to execute configuration changes.
# Ensure that all {{role.name}}ExtraConfigPost steps are executed # Ensure that all {{role.name}}ExtraConfigPost steps are executed
# after all the previous deployment steps. # after all the previous deployment steps.
@ -365,7 +358,7 @@ resources:
condition: {{role.name}}NonZero condition: {{role.name}}NonZero
type: OS::TripleO::Tasks::{{role.name}}PostConfig type: OS::TripleO::Tasks::{{role.name}}PostConfig
depends_on: depends_on:
{%- for dep in enabled_roles %} {%- for dep in roles %}
- {{dep.name}}ExtraConfigPost - {{dep.name}}ExtraConfigPost
{%- endfor %} {%- endfor %}
properties: properties:

View File

@ -1,11 +1,9 @@
{%- set primary_role = [roles[0]] -%} {%- set primary_role_name = roles[0].name -%}
{%- for role in roles -%} {%- for role in roles if ('primary' in role.tags and 'controller' in role.tags) -%}
{%- if 'primary' in role.tags and 'controller' in role.tags -%} {%- if loop.first -%}
{%- set _ = primary_role.pop() -%} {%- set primary_role_name = role.name -%}
{%- set _ = primary_role.append(role) -%}
{%- endif -%} {%- endif -%}
{%- endfor -%} {%- endfor -%}
{%- set primary_role_name = primary_role[0].name -%}
# primary role is: {{primary_role_name}} # primary role is: {{primary_role_name}}
heat_template_version: wallaby heat_template_version: wallaby