zuul-jobs/roles/emit-job-header/tasks/main.yaml
Ian Wienand 6d23d20f2f linters: add names to blocks
This is preparation for a later version of ansbile-lint, which finds
missing names on blocks.  This seems a reasonable rule, and the
Ansible manual says [1]

  Names for blocks have been available since Ansible 2.3. We recommend
  using names in all tasks, within blocks or elsewhere, for better
  visibility into the tasks being executed when you run the playbook.

This simply adds a name tag for blocks that are missing it.  This
should have no operational change, but allows us to update the linter
in a follow-on change.

[1] https://docs.ansible.com/ansible/latest/user_guide/playbooks_blocks.html

Change-Id: I92ed4616775650aced352bc9088a07e919f1a25f
2022-07-27 17:13:39 +10:00

44 lines
1.8 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 %}
- 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'] }}
{% 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