From 7766406431f66d6d8a9317699af8f7f1b9ce1e97 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Thu, 13 Sep 2018 11:08:56 +0000 Subject: [PATCH] emit-job-header: fix print node information This task may be failing when ansible_hostname is not available: The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'ansible_hostname' Change-Id: I8d67d8aa284b6ce9ae012608e8f1b12784ce836b --- roles/emit-job-header/tasks/main.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/roles/emit-job-header/tasks/main.yaml b/roles/emit-job-header/tasks/main.yaml index a2d8b70aa..d98aeb4fd 100644 --- a/roles/emit-job-header/tasks/main.yaml +++ b/roles/emit-job-header/tasks/main.yaml @@ -24,10 +24,11 @@ debug: msg: | # Node Information - Hostname: {{ hostvars[item]['ansible_hostname'] }} + Hostname: {{ hostvars[item]['ansible_hostname']|default('unknown') }} Provider: {{ hostvars[item]['nodepool']['provider'] }} Label: {{ hostvars[item]['nodepool']['label'] }} {% if hostvars[item]['nodepool']['interface_ip'] is defined %} Interface IP: {{ hostvars[item]['nodepool']['interface_ip'] }} {% endif %} loop: "{{ query('inventory_hostnames', 'all,!localhost') }}" + ignore_errors: yes