Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Salt: Can I use an argument from the command line as a jinja variable?

Given a file called package-list, I want to do something like:

salt state.sls install-packages list_to_install=package-list

...and then in the sls:

packages:
    pkg.installed:
        - names:
            {% include list_to_install %}
like image 532
jMyles Avatar asked Jul 17 '13 22:07

jMyles


Video Answer


1 Answers

You can do this using Pillar:

packages:
  pkg:
    - installed
    - pkgs: {{ salt['pillar.get']('packages') }}

Then pass the pillar argument containing valid YAML:

salt '*' state.sls package-list pillar='{packages: [foo, bar, baz]}'
like image 120
whiteinge Avatar answered Oct 12 '22 22:10

whiteinge