'How to symlink in saltstack latest version or file

ln -fs /opt/app/$(ls -rt file-*.jar | tail -n1) /opt/app/file.jar

works in bash very well

dir contains

file-1.jar
file-2.jar
file-3.jar

How can I do this in a salt stack state sls formula ?



Solution 1:[1]

{% set latest_jar = salt['cmd.shell']('ls -rt /opt/app/file-*.jar | tail -n1') %}

link-latest-jar:
  file.symlink:
    - name: /opt/app/file.jar
    - target: {{ latest_jar }}

works for me... thx for help

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 LongLastingNewbie