- name: Deploy and Verify RPM
block:
# 1. Install the RPM (Idempotent: skips if already present)
- name: Install {{ comet_application_name }}
ansible.builtin.yum:
name: "/path/to/{{ rpm_filename }}"
state: present
# 2. Refresh package facts to include the new RPM in the inventory
- name: Refresh package facts
ansible.builtin.package_facts:
manager: auto
# 3. Parse version and release from the filename dynamically
# Logic: Assumes format [Name]-[Version]-[Release].x86_64.rpm
- name: Extract metadata from filename
ansible.builtin.set_fact:
target_version: "{{ rpm_filename | regex_replace('^' ~ comet_application_name ~ '-(.*)-(.*)\\.x86_64\\.rpm$', '\\1') }}"
target_release: "{{ rpm_filename | regex_replace('^' ~ comet_application_name ~ '-(.*)-(.*)\\.x86_64\\.rpm$', '\\2') }}"
# 4. Report the installed package info
- name: Report installation details
ansible.builtin.debug:
msg: |
Installation Verified:
- Package: {{ item.name }}
- Version: {{ item.version }}
- Release: {{ item.release }}
- Architecture: {{ item.arch }}
- Source: {{ item.source }}
loop: "{{ ansible_facts.packages[comet_application_name] | default([]) }}"
when: "item.version == target_version and item.release == target_release"
rescue:
- name: Handle failures
ansible.builtin.fail:
msg: "The installation or verification of {{ comet_application_name }} failed."
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)