Use jinja raw tag instead of quoted concatenation

Many of the lines are difficult to grasp due to the crazy
quotation and concatenation implemented to get the desired
result from generating playbooks via a jinja template.

We can make it easier to read and easier to understand by
using the jinja raw tag instead. This eases the maintenace
burden on us all and helps us sleep better at night.

Change-Id: I82c4de4a63817707a2b0ed0ced827be37c0d0463
This commit is contained in:
Jesse Pretorius (odyssey4me) 2020-03-11 16:52:52 +00:00
parent 9666a7e645
commit 42059a1031
1 changed files with 50 additions and 42 deletions

View File

@ -434,24 +434,26 @@ outputs:
- hosts: all
name: Manage SELinux and generate /etc/hosts
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
tasks:
- name: Set selinux state
selinux:
policy: targeted
state: SELINUX_MODE
{% raw %}
- name: Configure Hosts Entries
include_role:
name: tripleo_hosts_entries
vars:
tripleo_hosts_entries_undercloud_hosts_entries: {{ '"{{ ' }} undercloud_hosts_entries {{ ' }}"' }}
tripleo_hosts_entries_extra_hosts_entries: {{ '"{{ ' }} extra_hosts_entries {{ ' }}"' }}
tripleo_hosts_entries_vip_hosts_entries: {{ '"{{ ' }} vip_hosts_entries {{ ' }}"' }}
tripleo_hosts_entries_undercloud_hosts_entries: "{{ undercloud_hosts_entries }}"
tripleo_hosts_entries_extra_hosts_entries: "{{ extra_hosts_entries }}"
tripleo_hosts_entries_vip_hosts_entries: "{{ vip_hosts_entries }}"
{% endraw %}
- hosts: DEPLOY_TARGET_HOST
name: Common roles for TripleO servers
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
# pre_tasks run before any roles in a play, so we use it for the
# named debug task for --start-at-task.
@ -469,7 +471,7 @@ outputs:
- hosts: {{primary_role_name}}:DEPLOY_TARGET_HOST
name: Deploy step tasks for step 0
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
vars:
bootstrap_server_id: BOOTSTRAP_SERVER_ID
@ -492,7 +494,7 @@ outputs:
- hosts: {{primary_role_name}}:DEPLOY_TARGET_HOST
name: Server pre deployment steps
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
tasks:
- import_tasks: hiera_steps_tasks.yaml
@ -502,9 +504,10 @@ outputs:
- hosts: {{primary_role_name}}:DEPLOY_TARGET_HOST
name: Server deployments
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
tasks:
{% raw %}
- name: Server deployments
delegate_to: localhost
run_once: true
@ -513,7 +516,7 @@ outputs:
- include_tasks: deployments.yaml
vars:
force: false
with_items: "{{ '{{' }} hostvars[inventory_hostname]['pre_deployments_' ~ tripleo_role_name]|default([]) {{ '}}' }}"
with_items: "{{ hostvars[inventory_hostname]['pre_deployments_' ~ tripleo_role_name]|default([]) }}"
- name: Check for previous run of NetworkConfig
stat:
@ -529,13 +532,13 @@ outputs:
- name: Check NetworkConfig script existence
local_action:
module: stat
path: {{ '"{{' }} lookup('first_found', NetworkConfig_paths, errors='ignore') {{ '}}"' }}
path: "{{ lookup('first_found', NetworkConfig_paths, errors='ignore') }}"
become: no
register: NetworkConfig_stat
vars:
NetworkConfig_paths:
- {{ '"{{' }} tripleo_role_name ~ '/' ~ inventory_hostname ~ '/NetworkConfig' {{ '}}"' }}
- {{ '"{{' }} tripleo_role_name ~ '/NetworkConfig' {{ '}}"' }}
- "{{ tripleo_role_name ~ '/' ~ inventory_hostname ~ '/NetworkConfig' }}"
- "{{ tripleo_role_name ~ '/NetworkConfig' }}"
- name: NetworkConfig
block:
@ -550,22 +553,22 @@ outputs:
- name: Render NetworkConfig script
template:
dest: /var/lib/tripleo-config/scripts/run_os_net_config.sh
src: {{ '"{{' }} NetworkConfig_stat.stat.path {{ '}}"' }}
src: "{{ NetworkConfig_stat.stat.path }}"
mode: 0755
- name: Run NetworkConfig script
command: /var/lib/tripleo-config/scripts/run_os_net_config.sh
async: {{ '"{{' }} async_timeout | default(300) {{ '}}"' }}
poll: {{ '"{{' }} async_poll | default(3) {{ '}}"' }}
async: "{{ async_timeout | default(300) }}"
poll: "{{ async_poll | default(3) }}"
environment:
bridge_name: {{ '"{{' }} neutron_physical_bridge_name {{ '}}"' }}
interface_name: {{ '"{{' }} neutron_public_interface_name {{ '}}"' }}
bridge_name: "{{ neutron_physical_bridge_name }}"
interface_name: "{{ neutron_public_interface_name }}"
register: NetworkConfig_result
failed_when: false
- name: Write rc of NetworkConfig script
copy:
content: {{ '"{{' }} NetworkConfig_result.rc {{ '}}"' }}
content: "{{ NetworkConfig_result.rc }}"
dest: /var/lib/tripleo-config/os-net-config.returncode
- name: NetworkConfig stdout
@ -602,26 +605,27 @@ outputs:
- name: AllNodesValidationConfig
script: all_nodes_validation_script.sh
environment:
validate_controllers_icmp: {{ '"{{' }} validate_controllers_icmp {{ '}}"' }}
validate_gateways_icmp: {{ '"{{' }} validate_gateways_icmp {{ '}}"' }}
validate_fqdn: {{ '"{{' }} validate_fqdn {{ '}}"' }}
validate_ntp: {{ '"{{' }} validate_ntp {{ '}}"' }}
ping_test_ips: {{ '"{{' }} ping_test_ips | to_json {{ '}}"' }}
tripleo_role_name: {{ '"{{' }} tripleo_role_name {{ '}}"' }}
validate_controllers_icmp: "{{ validate_controllers_icmp }}"
validate_gateways_icmp: "{{ validate_gateways_icmp }}"
validate_fqdn: "{{ validate_fqdn }}"
validate_ntp: "{{ validate_ntp }}"
ping_test_ips: "{{ ping_test_ips | to_json }}"
tripleo_role_name: "{{ tripleo_role_name }}"
- name: ArtifactsConfig
script: deploy-artifacts.sh
environment:
artifact_urls: {{ '"{{' }} deploy_artifact_urls {{ '}}"' }}
artifact_urls: "{{ deploy_artifact_urls }}"
tags:
- overcloud
- pre_deploy_steps
{% endraw %}
{%- for role in roles %}
- hosts: {{role.name}}
name: {{role.name}} Host prep steps
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
vars:
bootstrap_server_id: BOOTSTRAP_SERVER_ID
@ -650,7 +654,7 @@ outputs:
- hosts: DEPLOY_SOURCE_HOST
name: External deployment step {{step}}
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
become: false
vars:
@ -679,7 +683,7 @@ outputs:
- hosts: {{primary_role_name}}:DEPLOY_TARGET_HOST
name: Deploy step tasks for {{step}}
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
# FIXME(shardy) - it would be nice to use strategy: free to
# allow the tasks per-step to run in parallel on each role,
@ -698,11 +702,13 @@ outputs:
docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET
tasks:
- name: Write the config_step hieradata for the deploy step {{step}} tasks
{% raw %}
copy:
content: "{{ '{{' }} dict(step=step|int) | to_json {{ '}}' }}"
content: "{{ dict(step=step | int) | to_json }}"
dest: /etc/puppet/hieradata/config_step.json
force: true
mode: '0600'
{% endraw %}
- name: Deploy step tasks for {{step}}
delegate_to: localhost
run_once: true
@ -724,7 +730,7 @@ outputs:
{% if step == 1 %}
- hosts: {{primary_role_name}}:DEPLOY_TARGET_HOST
name: Overcloud common bootstrap tasks for step 1
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
vars:
bootstrap_server_id: BOOTSTRAP_SERVER_ID
@ -760,7 +766,7 @@ outputs:
{% endif %}
- hosts: {{primary_role_name}}:DEPLOY_TARGET_HOST
name: Overcloud common deploy step tasks {{step}}
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
vars:
bootstrap_server_id: BOOTSTRAP_SERVER_ID
@ -795,7 +801,7 @@ outputs:
{%- endfor %}
- hosts: {{primary_role_name}}:DEPLOY_TARGET_HOST
name: Server Post Deployments
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
tasks:
- name: Server Post Deployments
@ -803,17 +809,19 @@ outputs:
run_once: true
debug:
msg: Use --start-at-task 'Server Post Deployments' to resume from this task
{% raw %}
- include_tasks: deployments.yaml
vars:
force: false
with_items: "{{ '{{' }} hostvars[inventory_hostname]['post_deployments_' ~ tripleo_role_name]|default([]) {{ '}}' }}"
with_items: "{{ hostvars[inventory_hostname]['post_deployments_' ~ tripleo_role_name]|default([]) }}"
tags:
- overcloud
- post_deploy_steps
{% endraw %}
- hosts: DEPLOY_SOURCE_HOST
name: External deployment Post Deploy tasks
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
become: false
vars:
@ -858,8 +866,8 @@ outputs:
{%- for role in roles %}
- hosts: {{role.name}}
name: Run update
serial: {{ '"{{' }} update_serial | default({{role.update_serial | default(1)}}) {{ '}}"' }}
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
serial: "{% raw %}{{ update_serial | default({% endraw %}{{ role.update_serial | default(1) }}{% raw %})}}{% endraw %}"
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
vars:
bootstrap_server_id: BOOTSTRAP_SERVER_ID
@ -914,7 +922,7 @@ outputs:
{%- for step in range(external_update_steps_max) %}
- hosts: DEPLOY_SOURCE_HOST
name: External update step {{step}}
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
become: false
vars:
@ -942,7 +950,7 @@ outputs:
# variables "exported" from update tasks
- hosts: DEPLOY_SOURCE_HOST
name: External deploy step {{step}}
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
become: false
vars:
@ -982,7 +990,7 @@ outputs:
- hosts: {{role.name}}
name: Run pre-upgrade rolling tasks
serial: {{ role.deploy_serial | default(1) }}
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
tasks:
- include_tasks: pre_upgrade_rolling_steps_tasks.yaml
@ -1000,7 +1008,7 @@ outputs:
{%- for step in range(0,upgrade_steps_max) %}
- hosts: DEPLOY_TARGET_HOST
name: Upgrade tasks for step {{step}}
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
vars:
bootstrap_server_id: BOOTSTRAP_SERVER_ID
@ -1061,7 +1069,7 @@ outputs:
{%- for step in range(external_upgrade_steps_max) %}
- hosts: DEPLOY_SOURCE_HOST
name: External upgrade step {{step}}
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
become: false
vars:
@ -1092,7 +1100,7 @@ outputs:
# variables "exported" from upgrade tasks
- hosts: DEPLOY_SOURCE_HOST
name: External deploy step {{step}}
gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }}
gather_facts: "{% raw %}{{ gather_facts | default(false) }}{% endraw %}"
any_errors_fatal: yes
become: false
vars: