DEV Community

Query Filter
Query Filter

Posted on

docker24

- name: "Find the RPM file in the migration directory"
  ansible.builtin.find:
    paths: "/tmp/{{ lightspeed.build_version }}"
    patterns: "*.rpm"
  register: found_rpms

- name: "Extract naming metadata from filename"
  ansible.builtin.set_fact:
    # This regex looks for: [Anything]-[Version].x86_64.rpm
    # It captures [Anything] as 'app_name' and [Version] as 'app_version'
    rpm_filename: "{{ found_rpms.files[0].path | basename }}"
    app_name: "{{ (found_rpms.files[0].path | basename | regex_search('^(.*)-(.*)\\.x86_64\\.rpm$', '\\1'))[0] }}"
    app_version: "{{ (found_rpms.files[0].path | basename | regex_search('^(.*)-(.*)\\.x86_64\\.rpm$', '\\2'))[0] }}"

- name: "DEBUG: Show extracted values"
  ansible.builtin.debug:
    msg: 
      - "Full File: {{ rpm_filename }}"
      - "Parsed Name: {{ app_name }}"
      - "Parsed Version: {{ app_version }}"

- name: "Install the discovered RPM"
  ansible.builtin.yum:
    name: "{{ found_rpms.files[0].path }}"
    state: present
    disable_gpg_check: yes
  become: yes

- name: "Create symlink to the extracted version"
  ansible.builtin.file:
    # Points to /opt/CPLS/1.0.0 (or whatever version was parsed)
    src: "/opt/CPLS/{{ app_version }}"
    dest: "/opt/CPLS/live"
    state: link
    force: yes
    follow: false
  become: yes
Enter fullscreen mode Exit fullscreen mode

Top comments (0)