jMyles
jMyles

Reputation: 12172

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 %}

Upvotes: 9

Views: 4172

Answers (1)

whiteinge
whiteinge

Reputation: 605

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]}'

Upvotes: 11

Related Questions