From 9cc7489cca85eee6ce9950c1ee1d5f01c8251efc Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Thu, 9 May 2019 10:59:18 +0200 Subject: [PATCH] undercloud-setup: Introduce tripleo_set_unique_hostname variable In hostname playbook, add a task to modify /etc/hosts. tripleo_set_unique_hostname is a new boolean which if set to true, will add a line to /etc/hosts with an unique hostname ( {{ ansible_hostname }}-unique ) which will resolve the first IPv4 address found in the inventory. It is useful to reproduce a deployment where the operator is using hostnames to create SSL certificates and deploy the undecloud with the public host being an hostname/fqdn and not an IP address. Related-Bug: #1763776 Change-Id: I6425499e5d248e6cb2285f14dd9c6e716122b90b --- roles/undercloud-setup/defaults/main.yml | 1 + roles/undercloud-setup/tasks/hostname.yml | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/roles/undercloud-setup/defaults/main.yml b/roles/undercloud-setup/defaults/main.yml index 0b392b39c..59e58dd54 100644 --- a/roles/undercloud-setup/defaults/main.yml +++ b/roles/undercloud-setup/defaults/main.yml @@ -41,3 +41,4 @@ undercloud_ara_version: 0.15.0 undercloud_ara: false install_atop: true atop_command: atop -R -w /var/log/atop.bin +tripleo_set_unique_hostname: false diff --git a/roles/undercloud-setup/tasks/hostname.yml b/roles/undercloud-setup/tasks/hostname.yml index 52e633bca..e36492537 100644 --- a/roles/undercloud-setup/tasks/hostname.yml +++ b/roles/undercloud-setup/tasks/hostname.yml @@ -16,6 +16,16 @@ {{ working_dir }}/hostname.sh 2>&1 {{ timestamper_cmd }} > {{ working_dir }}/hostname.sh.log become: true +# https://launchpad.net/bugs/1763776 +- name: Add a unique hostname to /etc/hosts resolved to the first IPv4 available + become: true + lineinfile: + dest: /etc/hosts + state: present + insertafter: EOF + line: "{{ ansible_all_ipv4_addresses | first }} {{ ansible_hostname }}-unique" + when: tripleo_set_unique_hostname|default(false)|bool + # for undercloud containers only, starting from Rocky. - name: Override containerized undercloud CI hostname for tripleo client when: