1
votes

I am coding a custom module that is executed inside a pillar (to set a pillar variable) but I need it to retrieve an external parameter.

The idea is to retrieve a parameter from the master server. For example, if I execute

salt 'myminion' state.highstate

the custom module will be called and it should retrieve a parameter to generate the pillar.

I was looking into options like:

  1. Using environment variables: It doesn't work as it seems that the execution modules does nothave access to the shell environment of the salt command.

  2. Using command line paramenters: I dont know if it is even possible as I couldn't find any documentation.

  3. Using an additional pillar in the command line: It doesn't work as the execution module is executed during pillar evaluation so it does not have access to __pillar__ or __salt__['pillar.get'] (both empty).

  4. Reading from stdin: Does not workfrom a custom module.

  5. Using a file to read info: I didn't even tryied this because it is not an option for me for security reasons. I dont want the information stored.

Any ideas if or how is this possible to do?

Thanks a lot!

1

1 Answers

0
votes

By:

a custom module that is executed inside a pillar (to set a pillar variable)

do you mean an external pillar?

If so, passing it parameters is covered in that document:

You can pass a single argument, a list of arguments or a dictionary of arguments to your pillar:

ext_pillar:
  - example_a: some argument
  - example_b:
    - argumentA
    - argumentB
  - example_c:
    keyA: valueA
    keyB: valueB

External pillars merge their data into the pillar dictionary, and are "custom modules", so I think that would fit your case.

If that's not what you're trying to do, can you update the question? Where is this parameter coming from? Is it different depending on the minion (minion_id is always passed to an external pillar)?

(edit) Adding a couple links about safely storing secrets: