zuul-jobs/roles/emit-job-header/tasks/main.yaml
Tristan Cacqueray 7766406431 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
2018-09-13 11:33:17 +00:00

35 lines
1.3 KiB
YAML

# We don't want this to run for every host, it should only run once.
- run_once: yes
block:
- name: Setup log path fact
include_role:
name: set-zuul-log-path-fact
- name: Print job information
debug:
msg: |
# Job Information
Ansible Version: {{ ansible_version['full'] }}
Job: {{ zuul.job }}
Pipeline: {{ zuul.pipeline }}
Executor: {{ zuul.executor.hostname }}
{% if zuul.change_url is defined %}
Triggered by: {{ zuul.change_url }}
{% endif %}
{% if zuul_log_url is defined and zuul_log_path is defined %}
Log URL (when completed): {{ zuul_log_url }}/{{ zuul_log_path }}
{% endif %}
- name: Print node information
debug:
msg: |
# Node Information
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