2121CHEF_INSTALL_TYPE = 'gems'
2222CHEF_RUBY_VERSION = '1.9.1'
2323CHEF_ENVIRONMENT = '_default'
24- CHEF_CLIENT_VERSION = '11.6 .2'
24+ CHEF_CLIENT_VERSION = '11.8 .2'
2525
2626# load chef config using CHEF_CONFIG_PATH
2727try :
4949 _valid_pem_path = os .path .join (CHEF_CONFIG_PATH , 'validation.pem' )
5050 CHEF_VALIDATION_KEY = subprocess .check_output (
5151 ['/bin/cat' , _valid_pem_path ]).strip ('\n ' )
52+ # write out knife template
53+ if not os .path .exists ('.chef' ):
54+ os .mkdir ('.chef' )
55+ _template_src = os .path .abspath (os .path .join (__file__ , '..' , 'ubuntu12.04-gems.erb' ))
56+ with open (_template_src ) as src :
57+ _knife_template = os .path .abspath (os .path .join ('.chef' , 'knife-template.erb' ))
58+ with open (_knife_template , 'w' ) as f :
59+ f .write (src .read ())
5260except Exception as err :
5361 msg = "Failed to auto-configure Chef -- {}" .format (err )
5462 if os .environ .get ('READTHEDOCS' ):
@@ -91,6 +99,7 @@ def bootstrap_node(node):
9199 # build knife bootstrap command
92100 args = ['knife' , 'bootstrap' , node ['fqdn' ]]
93101 args .extend (['--config' , '/etc/chef/client.rb' ])
102+ args .extend (['--template-file' , '.chef/knife-template.erb' ])
94103 args .extend (['--identity-file' , pk_path ])
95104 args .extend (['--node-name' , node ['id' ]])
96105 args .extend (['--sudo' , '--ssh-user' , node ['ssh_username' ]])
@@ -103,14 +112,13 @@ def bootstrap_node(node):
103112 args .extend (['|' , 'tee' , output_path ])
104113 # TODO: figure out why home isn't being set correctly for knife exec
105114 env = os .environ .copy ()
106- env ['HOME' ] = '/opt /deis'
115+ env ['HOME' ] = '/var/lib /deis'
107116 # execute knife bootstrap
108117 p = subprocess .Popen (' ' .join (args ), env = env , shell = True )
109118 rc = p .wait ()
110119 # always print knife output
111120 with open (output_path ) as f :
112- output = f .read ()
113- print (output )
121+ output = str (f .read ())
114122 # raise an exception if bootstrap failed
115123 if rc != 0 or 'incorrect password' in output :
116124 raise RuntimeError ('Node Bootstrap Error:\n ' + output )
0 commit comments