Skip to content

Instantly share code, notes, and snippets.

@rafalf
Last active August 29, 2015 14:01
Show Gist options
  • Save rafalf/41f9cf5dde17e71ee6c9 to your computer and use it in GitHub Desktop.
Save rafalf/41f9cf5dde17e71ee6c9 to your computer and use it in GitHub Desktop.
puppet/aws: reading userdata powershell script, wrapping in <powershell> tags and setting environment variables
def _read_script(self, script_name, site_name, type):
script = ""
script += "<powershell>\n\n"
# set environment variable
script += " [Environment]::SetEnvironmentVariable(\"ENVNAME\", \"" + site_name + "\", \"Machine\")\n"
script += " [Environment]::SetEnvironmentVariable(\"NTPSERVER\", \"ntp." + site_name + "\", \"Machine\")\n"
script += " [Environment]::SetEnvironmentVariable(\"PREPDIR\", \"C:\\AmazonEnvPrep-v2012\", \"Machine\")\n"
script += " [Environment]::SetEnvironmentVariable(\"FACTER_fqdn\", \"dummy.ammado.com\", \"Machine\")\n"
script += " [Environment]::SetEnvironmentVariable(\"FACTER_envtype\", \"" + type + "\", \"Machine\")\n"
try:
f = open(script_name, 'r')
data = f.read()
f.close()
except IOError, e:
self.logger.info('Error opening file: %s' % (e))
script += data
script += "\n</powershell>"
# f = open("C:\\test.log", 'w')
# f.write(script)
# f.close()
return script
@rafalf
Copy link
Author

rafalf commented Feb 17, 2015

configuring two facters for puppet:
FACTER_fqdn,
FACTER_envtype

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment