I have an Ansible task to install Anaconda:
---
- name: "Set variables"
set_fact:
package: "/software/anaconda/Anaconda3-2019.07-Linux-x86_64.sh"
- set_fact:
anadir: "/opt/anaconda/anaconda3-2019.07"
- name: "Check existence"
stat:
path: "{{ anadir }}"
register: anaconda
- debug:
msg: "{{ anadir }} already exists."
when: anaconda.stat.exists == True
- name: Install Anaconda
shell: "/bin/bash {{ package }} -b -p {{ anadir }}"
when: anaconda.stat.exists == False
But I don't want to have the version hardcoded in the file. I don't even want it in any kind of variable.
If I have a link in my directory /software/anaconda
like latest -> Anaconda3-2019.07-Linux-x86_64.sh
I am sure I can set a fact with the value Anaconda3-2019.07-Linux-x86_64.sh
. But I could not find an elegant way to do it.
Run the stat
module against your latest
link, register the result and explore it.
You should find a lnk_source
key pointing to your original file.