Last active
August 29, 2015 14:04
-
-
Save non7top/73ecd104c755db25e1bc to your computer and use it in GitHub Desktop.
Custom pillar module that reads data from simple ini file.
This file contains hidden or 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
#!py | |
# no globbing or extended matching of minion names | |
# ini format: | |
#[DEFAULT] | |
#sshd_port=22 | |
# | |
#[server1] | |
#sshd_port=10022 | |
# Import python libs | |
import collections | |
import logging | |
import ConfigParser | |
log = logging.getLogger(__name__) | |
Config = ConfigParser.ConfigParser() | |
Config.read("/etc/salt/pillar/settings.ini") | |
# read defaults | |
default=dict(Config.items('DEFAULT')) | |
def run(): | |
pillar={} | |
# read other sections | |
sections=Config.sections() | |
for section in sections: | |
pillar[section]=dict(Config.items(section)) | |
return pillar.get(__grains__['id'], default) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment