Search code examples
dictionaryyamlsalt-project

how to pass a dict as function argument in salt


I need to use a

pip.installed

function in salt and pass it an argument

env_vars

with multiple params which should be eventually rendered to a python dictionary. It is okay if there were one parameter and the argument was expecting an argument of the type other than dictionary i then could pass it like so:

pip.installed:
  - env_vars: my_var

But i need to pass a dict and im not sure how to do it.

Should it be a construct like:

pip.installed:
  - env_vars:
    - my_var1: var_value
    - my_var2: var_value2

And how should i checked that my config actually renders to the correct form?


Solution

  • Dictionaries don't have dashes, just list items.

    pip.installed:
      - env_vars:
          my_var1: var_value
          my_var2: var_value2
    

    Edited the format per Damian's comment. Thanks, Damian!