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:
parent
cdead64021
commit
3eb4a5a66a
@ -86,14 +86,6 @@ def bootstrap_server(server, key, name, volume, keep):
|
|||||||
'install_puppet.sh')
|
'install_puppet.sh')
|
||||||
ssh_client.ssh('bash -x 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
|
# Write out the private SSH key we generated
|
||||||
key_file = tempfile.NamedTemporaryFile(delete=not keep)
|
key_file = tempfile.NamedTemporaryFile(delete=not keep)
|
||||||
key.write_private_key(key_file)
|
key.write_private_key(key_file)
|
||||||
@ -110,17 +102,20 @@ def bootstrap_server(server, key, name, volume, keep):
|
|||||||
'-i', inventory_file.name, '-l', server.id,
|
'-i', inventory_file.name, '-l', server.id,
|
||||||
'--private-key={key}'.format(key=key_file.name),
|
'--private-key={key}'.format(key=key_file.name),
|
||||||
"--ssh-common-args='-o StrictHostKeyChecking=no'",
|
"--ssh-common-args='-o StrictHostKeyChecking=no'",
|
||||||
|
'-e', 'target={id}'.format(id=server.id),
|
||||||
]
|
]
|
||||||
|
|
||||||
# Run the remote puppet apply playbook limited to just this server
|
# Run the remote puppet apply playbook limited to just this server
|
||||||
# we just created
|
# we just created
|
||||||
try:
|
try:
|
||||||
print subprocess.check_output(
|
for playbook in [
|
||||||
ansible_cmd + [
|
'set_hostnames.yml',
|
||||||
os.path.join(
|
'remote_puppet_adhoc.yaml']:
|
||||||
SCRIPT_DIR, '..', 'playbooks',
|
print subprocess.check_output(
|
||||||
'remote_puppet_adhoc.yaml')],
|
ansible_cmd + [
|
||||||
stderr=subprocess.STDOUT)
|
os.path.join(
|
||||||
|
SCRIPT_DIR, '..', 'playbooks', playbook)],
|
||||||
|
stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print "Subprocess failed"
|
print "Subprocess failed"
|
||||||
print e.output
|
print e.output
|
||||||
|
Loading…
x
Reference in New Issue
Block a user