summaryrefslogtreecommitdiff
path: root/global/overlay/etc/puppet/cosmos_enc.py
blob: 131d161f5251d8d379cafd165a219635dfed7c11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python

import sys
import yaml
import os
import re

node_name = sys.argv[1]

db_file = os.environ.get("COSMOS_ENC_DB","/etc/puppet/cosmos-db.yaml")
db = dict(classes=dict())

if os.path.exists(db_file):
   with open(db_file) as fd:
      db.update(yaml.load(fd))

print yaml.dump(dict(classes=db['classes'].get(node_name,dict()),parameters=dict(roles=db.get('members',[]))))