infra-ansible/roles/deploy_hiera/files/generate_hiera_common.py
Ricardo Carrillo Cruz 55303f4bb8 Major refactor
Decoupled several things from bootstrap roles into subroles
and added several default and group variables
2015-04-13 14:23:22 +02:00

21 lines
487 B
Python

#!/usr/bin/env python
import yaml
import paramiko
import StringIO
KEY_LENGTH = 2048
HIERA_SSH_PARAMS = ['puppetmaster_root_rsa_key']
HIERA_COMMON_YAML_FILE = '/etc/puppet/hieradata/production/common.yaml'
out = StringIO.StringIO()
d = {}
for h in HIERA_SSH_PARAMS:
k = paramiko.RSAKey.generate(KEY_LENGTH)
k.write_private_key(out)
d[h] = out.getvalue()
with open(HIERA_COMMON_YAML_FILE, "w") as f:
yaml.safe_dump(d, f, explicit_start=True, default_flow_style=False)