---
# 1. Find the physical RPM file
- name: "Discovery: Find the RPM file in the migration directory"
ansible.builtin.find:
paths: "/tmp/{{ lightspeed.build_version }}"
patterns: "*.rpm"
register: found_rpms
# 2. Extract naming metadata
- name: "Logic: Extract naming metadata from filename"
ansible.builtin.set_fact:
# Captures the full filename (e.g., CPLSEMEA-1.0.0.x86_64.rpm)
discovered_filename: "{{ found_rpms.files[0].path | basename }}"
# Captures just the version (e.g., 1.0.0)
app_version: "{{ (found_rpms.files[0].path | basename | regex_search('^(.*)-(.*)\\.x86_64\\.rpm$', '\\2'))[0] }}"
when: found_rpms.matched > 0
# NEW STEP: Print the extracted values for visibility in logs
- name: "Debug: Show Discovered RPM and Extracted Version"
ansible.builtin.debug:
msg:
- "Full RPM Filename: {{ discovered_filename }}"
- "Extracted App Version: {{ app_version }}"
# 3. Install using the discovered path
- name: "Install RPM package in the Linux servers"
ansible.builtin.yum:
name: "{{ found_rpms.files[0].path }}"
state: present
disable_gpg_check: yes
become: yes
register: rpm_install_status
# 4. Create the symlink
- name: "Create symlink to default version"
ansible.builtin.file:
src: "/opt/CPLS/{{ app_version }}"
dest: "/opt/CPLS/live"
state: link
force: yes
follow: false
become: yes
# 5. Verify the link contents
- name: "Verification: List content of the symbolic link"
ansible.builtin.command:
cmd: "ls -ltr /opt/CPLS/live/"
register: symlink_contents
become: yes
# noqa command-instead-of-module
- name: "Verification: Display results"
ansible.builtin.debug:
var: symlink_contents.stdout_lines
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)