Question

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 %}
Was it helpful?

Solution

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]}'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top