snippetMinor
How to insert a minion Powershell variable into Salt Pillar or Mine?
Viewed 0 times
mineinsertpillarintopowershellsaltminionhowvariable
Problem
Say I have a Powershell script, named
I can call it from a Salt state with -
But what can I do to retrieve that value and insert it into a Pillar (or a Mine)?
test.ps1, that has this:$VariableForPillar = 5I can call it from a Salt state with -
test powershell run:
cmd.run:
- name: 'C:\Windows\System32\WindowsPowershell\v1.0\powershell.exe -ExecutionPolicy ByPass -File d:/tmp/Powershell/test.ps1'But what can I do to retrieve that value and insert it into a Pillar (or a Mine)?
Solution
You can only insert the return into the mine.
Just specify the cmd.run (or possibly cmd.script) in your mine_functions and you will get the whole return back.
If you want to have a script that sets up extra config on the minion, I would recommend writing a custom grain.
https://docs.saltstack.com/en/latest/topics/grains/#writing-grains
Just specify the cmd.run (or possibly cmd.script) in your mine_functions and you will get the whole return back.
If you want to have a script that sets up extra config on the minion, I would recommend writing a custom grain.
https://docs.saltstack.com/en/latest/topics/grains/#writing-grains
Context
StackExchange DevOps Q#1133, answer score: 4
Revisions (0)
No revisions yet.