---# 1. First, find the physical RPM file in the migration directory-name:"Discovery:FindtheRPMfileinthemigrationdirectory"ansible.builtin.find:paths:"/tmp/{{lightspeed.build_version}}"patterns:"*.rpm"register:found_rpms# 2. Extract the Version (e.g., 1.0.0) from the filename dynamically-name:"Logic:Extractnamingmetadatafromfilename"ansible.builtin.set_fact:# This regex captures the version string between the hyphen and the arch suffixapp_version:"{{(found_rpms.files[0].path|basename|regex_search('^(.*)-(.*)\\.x86_64\\.rpm$','\\2'))[0]}}"when:found_rpms.matched > 0# 3. Install using the discovered path-name:"InstallRPMpackageintheLinuxservers"ansible.builtin.yum:name:"{{found_rpms.files[0].path}}"state:presentdisable_gpg_check:yesbecome:yesregister:rpm_install_status# 4. Create the symlink using the EXTRACTED version (app_version)-name:"Createsymlinktodefaultversion"ansible.builtin.file:# Points to /opt/CPLS/1.0.0 instead of the migration IDsrc:"/opt/CPLS/{{app_version}}"dest:"/opt/CPLS/live"state:linkforce:yesfollow:falsebecome:yes# 5. Verification messages-name:"Verification:Announcedirectorycheck"ansible.builtin.debug:msg:"Checkingcontentsof/opt/CPLS/live/(Version:{{app_version}})"-name:"Verification:Listcontentofthesymboliclink"ansible.builtin.command:cmd:"ls-ltr/opt/CPLS/live/"register:symlink_contentsbecome:yes# noqa command-instead-of-module-name:"Verification:Displayresults"ansible.builtin.debug:var:symlink_contents.stdout_lines
Top comments (0)
Subscribe
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (0)