privileged-playbook.yaml
========================
-----
- 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
- name: "Discovery: Fail if no RPM found"
ansible.builtin.fail:
msg: "No GComet RPM found in /tmp on {{ inventory_hostname }}."
when: discovered_rpms.matched == 0
- name: "Discovery: Identify target file"
set_fact:
target_file_path: "{{ (discovered_rpms.files | sort(attribute='mtime') | last).path }}"
- name: "Discovery: Extract Version and Filename"
set_fact:
# Extracting GComet-1.2.3.rpm
artifacts_file_name: "{{ target_file_path | basename }}"
# Extracting 1.2.3 from the directory name
discovered_version: "{{ target_file_path | dirname | basename }}"
- 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 }}"
- "PATH: {{ target_file_path }}"
- "------------------------------------------------"
# ----------------------------------
roles:
- role: artifacts_download_v1
- role: rpm_deployment
dev/hosts
==========
artifact_download:
hosts:
vrdegcometld.eur.nsroot.net:
vars:
# Now discovered dynamically by the playbook
artifacts_file_name: ""
distribution_type: "java"
owner: "cometgran"
group: "comet"
lightspeed:
build_version: ""
uat/hosts.yaml
===============
artifact_download:
hosts:
egtpsga56.nam.nsroot.net:
egtpsga57-phys.nam.nsroot.net:
egtpsga58-phys.nam.nsroot.net:
vars:
artifacts_file_name: ""
distribution_type: "java"
owner: "cometgran"
group: "comet"
lightspeed:
build_version: ""
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)