Skip to content
Snippets Groups Projects
Commit 1da2a7fb authored by ale's avatar ale
Browse files

added manage_etc_hosts option to generate /etc/hosts

parent b9cd1c0e
No related branches found
No related tags found
No related merge requests found
......@@ -172,6 +172,31 @@ def create_root_authorized_keys(config):
fd.write('%s\n' % key)
def create_etc_hosts(config):
contents = ['''# Automatically generated - do not edit!
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
''']
for hostname, hostinfo in sorted(config['hosts'].itervalues()):
names = ['%s.%s' % (hostname, config['domain'])]
if 'base.monitor' in hostinfo.get('roles', []):
names.append('monitor.%s' % config['domain'])
names.append(hostname)
ips = hostinfo['ip']
if isinstance(ips, basestring):
ips = [ips]
for ip in ips:
contents.append('%s %s\n' % (ip, ' '.join(names)))
with open(minicl.ROOT + '/etc/hosts', 'w') as fd:
fd.write(''.join(contents))
def copy_deploy_key(deploy_key_file, force=False):
if force or not os.path.exists(deploy_key_file):
common.copyfileattrs(deploy_key_file,
......@@ -195,6 +220,8 @@ def update_system(config):
setup_deploy_key(config)
create_root_authorized_keys(config)
create_dsh_config(config)
if config.get('manage_etc_hosts', False):
create_etc_hosts(config)
update_users(config)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment