Use a jinja block to reduce str_replace repetition

It would appear that we use the same str_replace params most
of the time, and there's no harm in using aliases where only
some of them are used. This way we reduce the maintenance
burden because we only need to maintain it in one place.

Change-Id: Ib034405a15ade9e9fb234a9875ebbe922abfdfc6
(cherry picked from commit dda2030a6a)
This commit is contained in:
Jesse Pretorius (odyssey4me) 2020-02-24 16:09:02 +00:00 committed by Sergii Golovatiuk
parent ddc46a7f6d
commit bee336a036
1 changed files with 10 additions and 93 deletions

View File

@ -407,6 +407,7 @@ outputs:
generate-config-tasks: {get_file: generate-config-tasks.yaml}
host-container-puppet-tasks: {get_file: host-container-puppet-tasks.yaml}
deploy_steps_playbook:
{% block deploy_steps_str_replace_params %}
str_replace:
params:
BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]}
@ -423,6 +424,7 @@ outputs:
DOCKER_PUPPET_PROCESS_COUNT: {get_param: DockerPuppetProcessCount}
DOCKER_PUPPET_MOUNT_HOST_PUPPET: {get_param: DockerPuppetMountHostPuppet}
SELINUX_MODE: {get_param: SELinuxMode}
{% endblock %}
template: |
- hosts: DEPLOY_SOURCE_HOST
name: Gather facts from undercloud
@ -899,21 +901,7 @@ outputs:
- always
{%- endfor %}
update_steps_playbook:
str_replace:
params:
DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts}
DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts}
CONTAINER_CLI: {get_param: ContainerCli}
CONTAINER_LOG_STDOUT_PATH: {get_param: ContainerLogStdoutPath}
CONTAINER_HEALTHCHECK_DISABLED: {get_param: ContainerHealthcheckDisabled}
DEPLOY_IDENTIFIER: {get_param: DeployIdentifier}
BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]}
ENABLE_DEBUG: {get_param: ConfigDebug}
ENABLE_PUPPET: {get_param: EnablePuppet}
ENABLE_PAUNCH: {get_param: EnablePaunch}
DOCKER_PUPPET_DEBUG: {get_param: DockerPuppetDebug}
DOCKER_PUPPET_PROCESS_COUNT: {get_param: DockerPuppetProcessCount}
DOCKER_PUPPET_MOUNT_HOST_PUPPET: {get_param: DockerPuppetMountHostPuppet}
{{ self.deploy_steps_str_replace_params() }}
template: |
- hosts: DEPLOY_SOURCE_HOST
name: Gather facts from undercloud
@ -1008,21 +996,7 @@ outputs:
{%- endfor %}
external_update_steps_tasks: {get_attr: [ExternalUpdateTasks, value]}
external_update_steps_playbook:
str_replace:
params:
DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts}
DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts}
DEPLOY_IDENTIFIER: {get_param: DeployIdentifier}
BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]}
ENABLE_DEBUG: {get_param: ConfigDebug}
ENABLE_PUPPET: {get_param: EnablePuppet}
ENABLE_PAUNCH: {get_param: EnablePaunch}
DOCKER_PUPPET_DEBUG: {get_param: DockerPuppetDebug}
DOCKER_PUPPET_PROCESS_COUNT: {get_param: DockerPuppetProcessCount}
DOCKER_PUPPET_MOUNT_HOST_PUPPET: {get_param: DockerPuppetMountHostPuppet}
CONTAINER_CLI: {get_param: ContainerCli}
CONTAINER_LOG_STDOUT_PATH: {get_param: ContainerLogStdoutPath}
CONTAINER_HEALTHCHECK_DISABLED: {get_param: ContainerHealthcheckDisabled}
{{ self.deploy_steps_str_replace_params() }}
template: |
- hosts: DEPLOY_SOURCE_HOST
name: Gather facts from undercloud
@ -1129,10 +1103,7 @@ outputs:
- always
{%- endfor %}
pre_upgrade_rolling_steps_playbook:
str_replace:
params:
DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts}
DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts}
{{ self.deploy_steps_str_replace_params() }}
template: |
{%- for role in roles %}
- hosts: {{role.name}}
@ -1182,17 +1153,7 @@ outputs:
loop_var: step
{%- endfor %}
upgrade_steps_playbook:
str_replace:
params:
DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts}
DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts}
CONTAINER_CLI: {get_param: ContainerCli}
ENABLE_PAUNCH: {get_param: EnablePaunch}
CONTAINER_LOG_STDOUT_PATH: {get_param: ContainerLogStdoutPath}
CONTAINER_HEALTHCHECK_DISABLED: {get_param: ContainerHealthcheckDisabled}
DEPLOY_IDENTIFIER: {get_param: DeployIdentifier}
BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]}
ENABLE_DEBUG: {get_param: ConfigDebug}
{{ self.deploy_steps_str_replace_params() }}
template: |
- hosts: DEPLOY_SOURCE_HOST:DEPLOY_TARGET_HOST
name: Gather facts from undercloud
@ -1285,21 +1246,7 @@ outputs:
- always
{%- endfor %}
post_upgrade_steps_playbook:
str_replace:
params:
DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts}
DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts}
CONTAINER_CLI: {get_param: ContainerCli}
CONTAINER_LOG_STDOUT_PATH: {get_param: ContainerLogStdoutPath}
CONTAINER_HEALTHCHECK_DISABLED: {get_param: ContainerHealthcheckDisabled}
DEPLOY_IDENTIFIER: {get_param: DeployIdentifier}
BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]}
ENABLE_DEBUG: {get_param: ConfigDebug}
ENABLE_PUPPET: {get_param: EnablePuppet}
ENABLE_PAUNCH: {get_param: EnablePaunch}
DOCKER_PUPPET_DEBUG: {get_param: DockerPuppetDebug}
DOCKER_PUPPET_PROCESS_COUNT: {get_param: DockerPuppetProcessCount}
DOCKER_PUPPET_MOUNT_HOST_PUPPET: {get_param: DockerPuppetMountHostPuppet}
{{ self.deploy_steps_str_replace_params() }}
template: |
- hosts: DEPLOY_TARGET_HOST
any_errors_fatal: yes
@ -1321,21 +1268,7 @@ outputs:
loop_var: step
external_upgrade_steps_tasks: {get_attr: [ExternalUpgradeTasks, value]}
external_upgrade_steps_playbook:
str_replace:
params:
DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts}
DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts}
DEPLOY_IDENTIFIER: {get_param: DeployIdentifier}
BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]}
ENABLE_DEBUG: {get_param: ConfigDebug}
ENABLE_PUPPET: {get_param: EnablePuppet}
ENABLE_PAUNCH: {get_param: EnablePaunch}
DOCKER_PUPPET_DEBUG: {get_param: DockerPuppetDebug}
DOCKER_PUPPET_PROCESS_COUNT: {get_param: DockerPuppetProcessCount}
DOCKER_PUPPET_MOUNT_HOST_PUPPET: {get_param: DockerPuppetMountHostPuppet}
CONTAINER_CLI: {get_param: ContainerCli}
CONTAINER_LOG_STDOUT_PATH: {get_param: ContainerLogStdoutPath}
CONTAINER_HEALTHCHECK_DISABLED: {get_param: ContainerHealthcheckDisabled}
{{ self.deploy_steps_str_replace_params() }}
template: |
- hosts: DEPLOY_SOURCE_HOST
name: Gather facts from undercloud
@ -1451,20 +1384,7 @@ outputs:
{%- endfor %}
scale_steps_tasks: {get_attr: [ScaleTasks, value]}
scale_playbook:
str_replace:
params:
DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts}
DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts}
DEPLOY_IDENTIFIER: {get_param: DeployIdentifier}
BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]}
ENABLE_DEBUG: {get_param: ConfigDebug}
ENABLE_PUPPET: {get_param: EnablePuppet}
ENABLE_PAUNCH: {get_param: EnablePaunch}
DOCKER_PUPPET_DEBUG: {get_param: DockerPuppetDebug}
DOCKER_PUPPET_PROCESS_COUNT: {get_param: DockerPuppetProcessCount}
DOCKER_PUPPET_MOUNT_HOST_PUPPET: {get_param: DockerPuppetMountHostPuppet}
CONTAINER_CLI: {get_param: ContainerCli}
CONTAINER_LOG_STDOUT_PATH: {get_param: ContainerLogStdoutPath}
{{ self.deploy_steps_str_replace_params() }}
template: |
# Collect the facts from the overcloud nodes but ignore unreachable
# nodes in the case of a dead node which needs to be part of the
@ -1566,10 +1486,7 @@ outputs:
tags:
- scale
fast_forward_upgrade_playbook:
str_replace:
params:
DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts}
DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts}
{{ self.deploy_steps_str_replace_params() }}
template: |
- hosts: DEPLOY_TARGET_HOST
any_errors_fatal: yes