Ensure consistency with hostname comparison

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
This commit is contained in:
Cédric Jeanneret 2020-03-27 11:35:50 +01:00
parent 0d0d6adc19
commit e236ff0cf9
5 changed files with 14 additions and 14 deletions

View File

@ -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:

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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