From e236ff0cf97d370dcad74467caa2d88d133dc6c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Jeanneret?= Date: Fri, 27 Mar 2020 11:35:50 +0100 Subject: [PATCH] Ensure consistency with hostname comparison MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It might happen an operator wants to get «camelcased» hostname. Since the RFC[1] states "no distinction is made between upper and lower case", we have to ensure string comparisons made in ansible are all lowered. [1] https://tools.ietf.org/html/rfc952 Closes-Bug: #1869360 Needed-By: https://review.opendev.org/71541 Change-Id: I988a8ce958f9fb21115aacde526c2dc89a3c8d66 --- common/deploy-steps-tasks.yaml | 6 +++--- common/generate-config-tasks.yaml | 4 ++-- common/host-container-puppet-tasks.yaml | 6 +++--- deployment/haproxy/haproxy-public-tls-inject.yaml | 2 +- deployment/octavia/octavia-deployment-config.j2.yaml | 10 +++++----- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/common/deploy-steps-tasks.yaml b/common/deploy-steps-tasks.yaml index caeba1026a..ed5319861e 100644 --- a/common/deploy-steps-tasks.yaml +++ b/common/deploy-steps-tasks.yaml @@ -153,18 +153,18 @@ # Bootstrap tasks - run any tasks that have been defined ######################################################## -- name: "Clean container_puppet_tasks for {{ansible_hostname}} step {{step}}" +- name: "Clean container_puppet_tasks for {{ansible_hostname | lower}} step {{step}}" file: path: /var/lib/container-puppet/container-puppet-tasks{{step}}.json state: absent tags: - container_config_tasks -- name: Calculate container_puppet_tasks for {{ansible_hostname}} step {{step}} +- name: Calculate container_puppet_tasks for {{ansible_hostname | lower}} step {{step}} set_fact: host_container_puppet_tasks: "{{host_container_puppet_tasks|default([]) + [item]}}" loop: "{{container_puppet_tasks.get('step_' + step, [])}}" - when: (groups[item.service_name] | default ([]) | map('extract', hostvars, 'inventory_hostname') | sort | first) == ansible_hostname + when: (groups[item.service_name] | default ([]) | map('extract', hostvars, 'inventory_hostname') | sort | first | lower) == ansible_hostname | lower vars: container_puppet_tasks: "{{ lookup('file', tripleo_role_name + '/container_puppet_tasks.yaml', errors='ignore') | default({}, True) | from_yaml }}" tags: diff --git a/common/generate-config-tasks.yaml b/common/generate-config-tasks.yaml index f4caf6c2c8..bd221374b3 100644 --- a/common/generate-config-tasks.yaml +++ b/common/generate-config-tasks.yaml @@ -20,7 +20,7 @@ MOUNT_HOST_PUPPET: '{{docker_puppet_mount_host_puppet | default(true)}}' CONTAINER_LOG_STDOUT_PATH: "{{ container_log_stdout_path }}" CONTAINER_HEALTHCHECK_DISABLED: "{{ container_healthcheck_disabled }}" - SHORT_HOSTNAME: "{{ ansible_hostname }}" + SHORT_HOSTNAME: "{{ ansible_hostname | lower }}" check_mode: no register: generate_config_async_result @@ -61,7 +61,7 @@ net_host: true no_archive: false puppet_config: "/var/lib/container-puppet/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}container-puppet.json" - short_hostname: "{{ ansible_hostname }}" + short_hostname: "{{ ansible_hostname | lower }}" step: "{{ step }}" - name: "Manage Puppet containers (generate config) for step {{ step }} with tripleo-ansible" diff --git a/common/host-container-puppet-tasks.yaml b/common/host-container-puppet-tasks.yaml index 43d32bdd32..18fdb55db0 100644 --- a/common/host-container-puppet-tasks.yaml +++ b/common/host-container-puppet-tasks.yaml @@ -1,4 +1,4 @@ -- name: Write container-puppet-tasks json file for {{ansible_hostname}} step {{step}} +- name: Write container-puppet-tasks json file for {{ansible_hostname | lower}} step {{step}} no_log: True copy: content: "{{host_container_puppet_tasks|to_nice_json}}" @@ -27,7 +27,7 @@ CONTAINER_CLI: "{{ container_cli }}" DEBUG: "{{ docker_puppet_debug }}" MOUNT_HOST_PUPPET: '{{docker_puppet_mount_host_puppet}}' - SHORT_HOSTNAME: "{{ ansible_hostname }}" + SHORT_HOSTNAME: "{{ ansible_hostname | lower }}" PROCESS_COUNT: "{{ docker_puppet_process_count }}" register: bootstrap_tasks_async_result no_log: true @@ -61,7 +61,7 @@ net_host: true no_archive: true puppet_config: "/var/lib/container-puppet/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}container-puppet-tasks{{ step }}.json" - short_hostname: "{{ ansible_hostname }}" + short_hostname: "{{ ansible_hostname | lower }}" step: "{{ step }}" - name: "Manage Puppet containers (bootstrap tasks) for step {{ step }} with tripleo-ansible" diff --git a/deployment/haproxy/haproxy-public-tls-inject.yaml b/deployment/haproxy/haproxy-public-tls-inject.yaml index 33c13fb928..8d4c540d41 100644 --- a/deployment/haproxy/haproxy-public-tls-inject.yaml +++ b/deployment/haproxy/haproxy-public-tls-inject.yaml @@ -85,7 +85,7 @@ outputs: path: "{{cert_path}}" - name: set is_haproxy_bootstrap_node fact - set_fact: is_haproxy_bootstrap_node={{haproxy_short_bootstrap_node_name == ansible_hostname}} + set_fact: is_haproxy_bootstrap_node={{haproxy_short_bootstrap_node_name | lower == ansible_hostname | lower}} - name: get haproxy status register: haproxy_state diff --git a/deployment/octavia/octavia-deployment-config.j2.yaml b/deployment/octavia/octavia-deployment-config.j2.yaml index fa48aaf677..7286658826 100644 --- a/deployment/octavia/octavia-deployment-config.j2.yaml +++ b/deployment/octavia/octavia-deployment-config.j2.yaml @@ -297,10 +297,10 @@ outputs: {%- if 'octavia_' ~ octavia_groups %} {% for host in groups['octavia_' ~ octavia_group] -%} - {{ hostvars.raw_get(host)['ansible_hostname'] }}: + {{ hostvars.raw_get(host)['ansible_hostname'] | lower}}: ansible_user: {{ hostvars.raw_get(host)['ansible_ssh_user'] | default('heat-admin') }} - ansible_host: {{ hostvars.raw_get(host)['ansible_host'] | default(host) }} - canonical_hostname: {{ hostvars.raw_get(host)['canonical_hostname'] | default(host) }} + ansible_host: {{ hostvars.raw_get(host)['ansible_host'] | default(host) | lower }} + canonical_hostname: {{ hostvars.raw_get(host)['canonical_hostname'] | default(host) | lower }} ansible_become: true {% endfor %} @@ -310,8 +310,8 @@ outputs: Undercloud: hosts: {% for host in groups['Undercloud'] -%} - {{ hostvars.raw_get(host)['ansible_hostname'] }}: - ansible_host: {{ hostvars.raw_get(host)['ansible_host'] | default(host) }} + {{ hostvars.raw_get(host)['ansible_hostname'] | lower}}: + ansible_host: {{ hostvars.raw_get(host)['ansible_host'] | default(host) | lower }} ansible_become: false ansible_connection: local