Access argument from command line

40 Views Asked by At

I would like to be able to download a file and specify the file path that file is downloaded to using a salt formula. This formula would be triggered through an API call as a final step in a CI/CD pipeline.

How can I pass a command line argument to a salt formula and assign that argument to a jinja variable? A sample psuedo-code of what I am looking for is below:

{% set path = salt['arg']('path', '/usr/local/bin') %}

echo_path:
  cmd.run:
    - name: 'echo {{ path }}'
1

There are 1 best solutions below

0
OrangeDog On BEST ANSWER
salt '*' state.apply pillar='{"path": "/opt/actual/path"}'
{% set path = pillar.get('path', '/usr/local/bin') %}

echo_path:
  cmd.run:
    - name: 'echo {{ path }}'

Pillar can be passed via API calls in a similar way.