Last active
August 29, 2015 14:01
-
-
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
This file contains 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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
configuring two facters for puppet:
FACTER_fqdn,
FACTER_envtype