Skip to content

Instantly share code, notes, and snippets.

@markuskont
Created January 31, 2017 15:09
Show Gist options
  • Save markuskont/76dce9cf6945aad840bd70f31d88b88a to your computer and use it in GitHub Desktop.
Save markuskont/76dce9cf6945aad840bd70f31d88b88a to your computer and use it in GitHub Desktop.
Convert puppet facts to salt grains
#!/usr/bin/env python
import subprocess
from subprocess import Popen, PIPE
import json, os
def facter():
binary = "/opt/puppetlabs/puppet/bin/facter"
if os.path.isfile(binary):
output = json.loads(subprocess.Popen([binary, '-p', '-j'], stdout=PIPE, stderr=PIPE).stdout.read().rstrip('\n'))
else:
output = None
return {
'facter': output
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment