Add generation of cloud.cfg

Change-Id: I2b36ee800cdc682bd81376b7916f40f0d8555326
This commit is contained in:
Dmitry Bogun 2016-12-12 18:53:14 +02:00 committed by Andrei V. Ostapenko
parent c912791aa1
commit 48e7493173
2 changed files with 85 additions and 0 deletions

View File

@ -110,6 +110,8 @@ class Environment(object):
self.node = node.Node(
self.jinja_env, node_template, self.network.name, ssh_key_path)
public_key = '.'.join([ssh_key_path, 'pub'])
self._generate_cloud_config(public_key)
self.add_pxe_config_for_current_node()
self.network.add_node(self.node)
@ -165,6 +167,16 @@ class Environment(object):
with open(conf_path, 'w') as f:
f.write(pxe_config)
def _generate_cloud_config(self, public_key):
""""Used to support logging into the tenant image."""
with open(public_key, 'r') as f:
key = f.readline()
template = self.jinja_env.get_template('cloud.cfg.template')
path = os.path.join(self.node.workdir, 'cloud.cfg')
with open(path, 'w') as f:
f.write(template.render(bareon_public_key=key))
def _setup_webserver(self):
port = CONF.stub_webserver_port
LOG.info("Starting stub webserver (at IP {0} port {1}, path to tenant "

View File

@ -0,0 +1,73 @@
datasource_list: [ None ]
hostname: fpa-func-test-tenant-vm
users:
- default
disable_root: 1
ssh_pwauth: 0
locale_configfile: /etc/sysconfig/i18n
mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2']
resize_rootfs_tmp: /dev
ssh_deletekeys: 0
ssh_genkeytypes: ~
syslog_fix_perms: ~
cloud_init_modules:
- migrator
- bootcmd
- write-files
- growpart
- resizefs
- set_hostname
- update_hostname
- update_etc_hosts
- rsyslog
- users-groups
- ssh
cloud_config_modules:
- mounts
- locale
- set-passwords
- yum-add-repo
- package-update-upgrade-install
- timezone
- puppet
- chef
- salt-minion
- mcollective
- disable-ec2-metadata
- runcmd
cloud_final_modules:
- rightscale_userdata
- scripts-per-once
- scripts-per-boot
- scripts-per-instance
- scripts-user
- ssh-authkey-fingerprints
- keys-to-console
- phone-home
- final-message
system_info:
default_user:
name: centos
lock_passwd: false
passwd: $6$YMOcabt27LSO.t$XcfOjDLlZWrMKvnrHJCZ/FTg8DAOphqtotYhrBCr0ZVxup.7R4HuwexRY.UtgHjOBkkL6Cz247CeLIo1a0YQu.
gecos: Cloud User
groups: [wheel, adm, systemd-journal]
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
shell: /bin/bash
ssh_authorized_keys:
- {{ bareon_public_key }}
distro: rhel
paths:
cloud_dir: /var/lib/cloud
templates_dir: /etc/cloud/templates
ssh_svcname: sshd
# vim:syntax=yaml