Created
December 10, 2014 04:54
-
-
Save jasonrm/a90906ce0eb381b61c5b to your computer and use it in GitHub Desktop.
Quick testing with Salt as the resource source for Rundeck
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 modules | |
import salt.client | |
# Import third party libs | |
import yaml | |
def resources(): | |
''' | |
Print a list of all of the minions as YAML formatted resource for rundeck | |
''' | |
client = salt.client.LocalClient(__opts__['conf_file']) | |
minions = client.cmd('*', 'grains.items', timeout=2) | |
resources = {} | |
for minion_id in minions: | |
resources[minion_id] = { | |
'nodename': minion_id, | |
'hostname': minion_id, | |
'username': 'rundeck', | |
} | |
try: | |
resources[minion_id]['osFamily'] = minions[minion_id]['os_family'] | |
except KeyError: | |
resources[minion_id]['osFamily'] = None | |
try: | |
resources[minion_id]['osArch'] = minions[minion_id]['osarch'] | |
except KeyError: | |
resources[minion_id]['osArch'] = None | |
try: | |
resources[minion_id]['osName'] = minions[minion_id]['osfullname'] | |
except KeyError: | |
resources[minion_id]['osName'] = None | |
try: | |
resources[minion_id]['osVersion'] = minions[minion_id]['osrelease'] | |
except KeyError: | |
resources[minion_id]['osVersion'] = None | |
try: | |
resources[minion_id]['location'] = minions[minion_id]['location'] | |
except KeyError: | |
resources[minion_id]['location'] = None | |
try: | |
resources[minion_id]['roles'] = minions[minion_id]['roles'] | |
except KeyError: | |
resources[minion_id]['roles'] = None | |
print yaml.safe_dump(resources, default_flow_style=False) |
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
#!/bin/bash | |
sudo /usr/bin/salt-run rundeck.resources |
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
rundeck ALL=(ALL) NOPASSWD: ALL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment