Skip to content

Instantly share code, notes, and snippets.

@non7top
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save non7top/73ecd104c755db25e1bc to your computer and use it in GitHub Desktop.
Save non7top/73ecd104c755db25e1bc to your computer and use it in GitHub Desktop.
Custom pillar module that reads data from simple ini file.
#!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