- name: Artifact download and RPM deployment
hosts: artifact_download
become: yes
gather_facts: yes
pre_tasks:
- name: "Discovery: Find the newest GComet RPM in /tmp"
ansible.builtin.find:
paths: "/tmp"
patterns: "GComet*.rpm"
recurse: yes
register: discovered_rpms # Fixed name
- name: "Discovery: Process found file"
block:
- name: "Identify target file"
set_fact:
target_file_path: "{{ (discovered_rpms.files | sort(attribute='mtime') | last).path }}"
- name: "Extract Version and Filename"
set_fact:
artifacts_file_name: "{{ target_file_path | basename }}"
discovered_version: "{{ target_file_path | dirname | basename }}"
when: discovered_rpms.matched > 0
- name: "Discovery: Fallback to Harness Env Var if /tmp is empty"
set_fact:
discovered_version: "{{ lookup('env', 'BUILD_VERSION') }}"
artifacts_file_name: "GComet.rpm"
target_file_path: "Not found in /tmp (using environment default)"
when: discovered_rpms.matched == 0
- name: "Discovery: Map to Legacy Variables"
set_fact:
lightspeed:
build_version: "{{ discovered_version }}"
# --- NEW CLEAR PRINTING SECTION ---
- name: "REPORT: Show Discovered Deployment Metadata"
ansible.builtin.debug:
msg:
- "------------------------------------------------"
- "HOST: {{ inventory_hostname }}"
- "VERSION: {{ lightspeed.build_version }}"
- "FILENAME: {{ artifacts_file_name }}"
- "SOURCE: {{ 'Local Filesystem' if discovered_rpms.matched > 0 else 'Harness Env Var' }}"
- "------------------------------------------------"
roles:
- role: artifacts_download_v1
- role: rpm_deployment
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)