Last active
December 14, 2015 13:09
-
-
Save DazWorrall/5091529 to your computer and use it in GitHub Desktop.
Apply a salt state to the current machine using the internal api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import salt.config | |
opts = salt.config.minion_config('/tmp/foo') # Doesnt need to be present | |
opts['file_client'] = 'local' # I dont know if this is right. Not 'remote' | |
opts['cachedir'] = '/tmp/salt' # Needs to be writeable | |
d = { | |
'/tmp/bacon': { | |
'file': [ | |
'directory', | |
{'mode': 777}, | |
] | |
} | |
} | |
m = salt.minion.SMinion(opts) | |
print m.functions['state.high'](d) | |
# Outputs: | |
#{'file_|-/tmp/bacon_|-/tmp/bacon_|-directory': {'comment': 'Directory /tmp/bacon updated', '__run_num__': 0, 'changes': {'/tmp/bacon': 'New Dir', 'mode': '777'}, 'name': '/tmp/bacon', 'result': True}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment