zuul-jobs/roles/emit-job-header/tasks/main.yaml
Dong Zhang 3e3e5e23dc Print instance type in emit-job-header role
It would be useful especially when ec2 fleet api is configured,
and the instance type is unknown in advance.

Change-Id: Ibcdade5cfffd13fddd95e797c60c5327bb34fdb6
2024-09-10 15:16:19 +02:00

48 lines
2.1 KiB
YAML

# We don't want this to run for every host, it should only run once.
- name: Emit log header
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 %}
{% if zuul.event_id is defined %}
Event ID: {{ zuul.event_id }}
{% endif %}
# The "Product Name" prints the instance type for AWS nodes but may be something else
# for other providers. It is useful when AWS EC2 Fleet is configured so that we know
# the exact instance type of the running node
- name: Print node information
debug:
msg: |
# Node Information
Inventory Hostname: {{ zj_item }}
Hostname: {{ hostvars[zj_item]['ansible_hostname'] | default('unknown') }}
Username: {{ hostvars[zj_item]['ansible_user'] | default('unknown') }}
Distro: {{ hostvars[zj_item]['ansible_distribution'] | default('unknown') }} {{ hostvars[zj_item]['ansible_distribution_version'] | default('unknown') }}
Provider: {{ hostvars[zj_item]['nodepool']['provider'] }}
Label: {{ hostvars[zj_item]['nodepool']['label'] }}
Product Name: {{ hostvars[zj_item]['ansible_product_name'] | default('unknown') }}
{% if hostvars[zj_item]['nodepool']['interface_ip'] is defined %}
Interface IP: {{ hostvars[zj_item]['nodepool']['interface_ip'] }}
{% endif %}
loop: "{{ query('inventory_hostnames', 'all,!localhost') }}"
loop_control:
loop_var: zj_item
ignore_errors: yes # noqa ignore-errors