From 94e69147a7ad908cb2781df7255a8cb548b7ac15 Mon Sep 17 00:00:00 2001 From: Albin Vass Date: Mon, 16 Mar 2020 11:07:10 +0100 Subject: [PATCH] Replace occurences of '/' in nodename to something more path friendly Inventory hostnames like "abc/123" is valid in both ansible and zuul but this role breaks since it uses it as part of a path. This sanitizes the hostname from "abc/123" to "abc_123". Change-Id: Ic89d595b6f004b5ca4805f1af8387e8ba56564aa --- roles/validate-host/defaults/main.yaml | 1 + roles/validate-host/tasks/main.yaml | 8 ++++++-- test-playbooks/base-roles/validate-host.yaml | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/roles/validate-host/defaults/main.yaml b/roles/validate-host/defaults/main.yaml index 80ced4067..5a89d2e53 100644 --- a/roles/validate-host/defaults/main.yaml +++ b/roles/validate-host/defaults/main.yaml @@ -1,3 +1,4 @@ zuul_site_image_manifest_files: - /etc/dib-builddate.txt - /etc/image-hostname.txt +validate_host_hostname: "{{ inventory_hostname }}" diff --git a/roles/validate-host/tasks/main.yaml b/roles/validate-host/tasks/main.yaml index 98b252d25..98da1e931 100644 --- a/roles/validate-host/tasks/main.yaml +++ b/roles/validate-host/tasks/main.yaml @@ -13,10 +13,14 @@ setup: register: setupinfo +- name: Sanitize hostname + set_fact: + validate_host_hostname_sanitized: "{{ validate_host_hostname | replace('/', '_') }}" + - name: Write out all ansible variables/facts known for each host delegate_to: localhost template: - dest: "{{ zuul_info_dir }}/host-info.{{ inventory_hostname }}.yaml" + dest: "{{ zuul_info_dir }}/host-info.{{ validate_host_hostname_sanitized }}.yaml" src: templates/host-info.j2 - name: zuul_debug_info block @@ -31,7 +35,7 @@ - name: Write out all zuul information for each host delegate_to: localhost template: - dest: "{{ zuul_info_dir }}/zuul-info.{{ inventory_hostname }}.txt" + dest: "{{ zuul_info_dir }}/zuul-info.{{ validate_host_hostname_sanitized }}.txt" src: templates/zuul-info.j2 when: ansible_python_version is version('2.7', '>=') diff --git a/test-playbooks/base-roles/validate-host.yaml b/test-playbooks/base-roles/validate-host.yaml index 67e40da7e..88dcdb62f 100644 --- a/test-playbooks/base-roles/validate-host.yaml +++ b/test-playbooks/base-roles/validate-host.yaml @@ -11,3 +11,4 @@ roles: - role: validate-host zuul_site_traceroute_host: files.openstack.org + validate_host_hostname: "abc/123"