Created
August 14, 2013 14:18
-
-
Save cloudnull/6231488 to your computer and use it in GitHub Desktop.
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
CLIENTRB = """ | |
log_level :info | |
log_location STDOUT | |
chef_server_url '%(config_server)s' | |
validation_key '/etc/chef/validation.pem' | |
validation_client_name '%(config_clientname)s' | |
node_name '%(node_name)s' | |
""" | |
PLACESH = """#!/usr/bin/env python | |
# The cloud-init-er via Python | |
import os | |
import subprocess | |
import httplib | |
url = 'www.opscode.com' | |
path = '/chef/install.sh' | |
conn = httplib.HTTPSConnection(url) | |
conn.request('GET', path) | |
resp = conn.getresponse() | |
r_r = resp.read() | |
CLIENT = \"\"\"%(client)s\"\"\" | |
VALID = \"\"\"%(valid)s\"\"\" | |
FIRST = \"\"\"%(first_bt)s\"\"\" | |
open('%(script_loc)s', 'w').write(r_r) | |
subprocess.call(['/bin/bash', '%(script_loc)s']) | |
try: | |
os.remove('%(script_loc)s') | |
except Exception: | |
print('File Not Found') | |
try: | |
os.mkdir('%(dirname)s') | |
except Exception: | |
print('Directory Exists') | |
open('%(client_loc)s', 'w').write(CLIENT) | |
open('%(valid_loc)s', 'w').write(VALID) | |
open('%(first_bt_loc)s', 'w').write(FIRST) | |
subprocess.call(['/usr/bin/chef-client', | |
'-j', | |
'%(first_bt_loc)s', | |
'-c', | |
'%(client_loc)s', | |
'-E', | |
'%(config_env)s', | |
'-L', | |
'/var/log/chef-client.log']) | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment