Created
January 31, 2017 15:09
-
-
Save markuskont/76dce9cf6945aad840bd70f31d88b88a to your computer and use it in GitHub Desktop.
Convert puppet facts to salt grains
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
#!/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