Use set-hostnames playbook in launch-node

We have a playbook that does the logic of setting the hostname. Rather
than implementing that logic in launch-node - just use the playbook.

Change-Id: I1a6c0ff12803bdac35631cb3bb2c8fe70cbd1904
This commit is contained in:
Monty Taylor 2016-03-09 13:02:14 -06:00 committed by Ricardo Carrillo Cruz
parent cdead64021
commit 3eb4a5a66a

View File

@ -86,14 +86,6 @@ def bootstrap_server(server, key, name, volume, keep):
'install_puppet.sh')
ssh_client.ssh('bash -x install_puppet.sh')
shortname = name.split('.')[0]
with ssh_client.open('/etc/hosts', 'w') as f:
f.write('127.0.0.1 localhost\n')
f.write('127.0.1.1 %s %s\n' % (name, shortname))
with ssh_client.open('/etc/hostname', 'w') as f:
f.write('%s\n' % (shortname,))
ssh_client.ssh("hostname %s" % (name,))
# Write out the private SSH key we generated
key_file = tempfile.NamedTemporaryFile(delete=not keep)
key.write_private_key(key_file)
@ -110,16 +102,19 @@ def bootstrap_server(server, key, name, volume, keep):
'-i', inventory_file.name, '-l', server.id,
'--private-key={key}'.format(key=key_file.name),
"--ssh-common-args='-o StrictHostKeyChecking=no'",
'-e', 'target={id}'.format(id=server.id),
]
# Run the remote puppet apply playbook limited to just this server
# we just created
try:
for playbook in [
'set_hostnames.yml',
'remote_puppet_adhoc.yaml']:
print subprocess.check_output(
ansible_cmd + [
os.path.join(
SCRIPT_DIR, '..', 'playbooks',
'remote_puppet_adhoc.yaml')],
SCRIPT_DIR, '..', 'playbooks', playbook)],
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
print "Subprocess failed"