From 82c976b46d0141347e7359e3f7719a91cdda891e Mon Sep 17 00:00:00 2001 From: Alexander Gordeev Date: Fri, 24 Oct 2014 20:01:00 +0400 Subject: [PATCH] A couple of hot fixes for fuel-agent 1) Fix cloud-init meta-data templates Just meta-data comments layout. 2) Fix repos handling in nailgun drivers Remove quotes from urls since apt refuses to work with them. 3) Fix ntp.conf issue Wrong semaphore ids in boothook were wrong Closes-Bug: #1388042 Implements: blueprint image-based-provisioning Change-Id: Iad6755753cc1fa938b370016cd2f4026e76b90a3 --- cloud-init-templates/boothook_centos.jinja2 | 6 +++--- cloud-init-templates/boothook_ubuntu.jinja2 | 6 ++++-- cloud-init-templates/cloud_config_centos.jinja2 | 5 ++++- cloud-init-templates/cloud_config_ubuntu.jinja2 | 9 +++++++-- cloud-init-templates/meta-data_centos.jinja2 | 7 ++++--- cloud-init-templates/meta-data_ubuntu.jinja2 | 7 ++++--- fuel_agent/drivers/nailgun.py | 3 ++- fuel_agent/tests/test_nailgun.py | 2 +- 8 files changed, 29 insertions(+), 16 deletions(-) diff --git a/cloud-init-templates/boothook_centos.jinja2 b/cloud-init-templates/boothook_centos.jinja2 index 2acd78c..70e7947 100644 --- a/cloud-init-templates/boothook_centos.jinja2 +++ b/cloud-init-templates/boothook_centos.jinja2 @@ -74,9 +74,9 @@ cloud-init-per instance sync_hwclock hwclock --systohc cloud-init-per instance edit_ntp_conf1 sed -i '/^\s*tinker panic/ d' /etc/ntp.conf cloud-init-per instance edit_ntp_conf2 sed -i '1 i tinker panic 0' /etc/ntp.conf cloud-init-per instance edit_ntp_conf3 echo 0 > /var/lib/ntp/drift -cloud-init-per instance edit_ntp_conf_0 chown ntp: /var/lib/ntp/drift -cloud-init-per instance edit_ntp_conf3 sed -i '/^\s*server/ d' /etc/ntp.conf -cloud-init-per instance edit_ntp_conf4 echo "server {{ common.master_ip }} burst iburst" | tee -a /etc/ntp.conf +cloud-init-per instance edit_ntp_conf4 chown ntp: /var/lib/ntp/drift +cloud-init-per instance edit_ntp_conf5 sed -i '/^\s*server/ d' /etc/ntp.conf +cloud-init-per instance edit_ntp_conf6 echo "server {{ common.master_ip }} burst iburst" | tee -a /etc/ntp.conf # Point installed ntpd to Master node diff --git a/cloud-init-templates/boothook_ubuntu.jinja2 b/cloud-init-templates/boothook_ubuntu.jinja2 index 0a5d2c7..92fc86a 100644 --- a/cloud-init-templates/boothook_ubuntu.jinja2 +++ b/cloud-init-templates/boothook_ubuntu.jinja2 @@ -10,6 +10,8 @@ function add_str_to_file_if_not_exists { fi } +cloud-init-per instance wipe_sources_list_templates echo | tee /etc/cloud/templates/sources.list.ubuntu.tmpl + # configure udev rules # udev persistent net @@ -57,8 +59,8 @@ cloud-init-per instance sync_hwclock hwclock --systohc cloud-init-per instance edit_ntp_conf1 sed -i '/^\s*tinker panic/ d' /etc/ntp.conf cloud-init-per instance edit_ntp_conf2 sed -i '1 i tinker panic 0' /etc/ntp.conf cloud-init-per instance edit_ntp_conf3 echo 0 > /var/lib/ntp/drift -cloud-init-per instance edit_ntp_conf3 sed -i '/^\s*server/ d' /etc/ntp.conf -cloud-init-per instance edit_ntp_conf4 echo "server {{ common.master_ip }} burst iburst" | tee -a /etc/ntp.conf +cloud-init-per instance edit_ntp_conf4 sed -i '/^\s*server/ d' /etc/ntp.conf +cloud-init-per instance edit_ntp_conf5 echo "server {{ common.master_ip }} burst iburst" | tee -a /etc/ntp.conf cloud-init-per instance removeUseDNS sed -i --follow-symlinks -e '/UseDNS/d' /etc/ssh/sshd_config add_str_to_file_if_not_exists /etc/ssh/sshd_config 'UseDNS' 'UseDNS no' diff --git a/cloud-init-templates/cloud_config_centos.jinja2 b/cloud-init-templates/cloud_config_centos.jinja2 index 22ad2e7..a0c5b0a 100644 --- a/cloud-init-templates/cloud_config_centos.jinja2 +++ b/cloud-init-templates/cloud_config_centos.jinja2 @@ -1,11 +1,14 @@ #cloud-config +resize_rootfs: false +growpart: + mode: false disable_ec2_metadata: true disable_root: false # password: RANDOM # chpasswd: { expire: True } -ssh_pwauth: True +ssh_pwauth: true ssh_authorized_keys: {% for key in common.ssh_auth_keys %} - {{ key }} diff --git a/cloud-init-templates/cloud_config_ubuntu.jinja2 b/cloud-init-templates/cloud_config_ubuntu.jinja2 index 34bddde..5137351 100644 --- a/cloud-init-templates/cloud_config_ubuntu.jinja2 +++ b/cloud-init-templates/cloud_config_ubuntu.jinja2 @@ -1,8 +1,13 @@ #cloud-config +resize_rootfs: false +growpart: + mode: false disable_ec2_metadata: true disable_root: false - -ssh_pwauth: True +user: root +password: r00tme +chpasswd: { expire: false } +ssh_pwauth: true ssh_authorized_keys: {% for key in common.ssh_auth_keys %} - {{ key }} diff --git a/cloud-init-templates/meta-data_centos.jinja2 b/cloud-init-templates/meta-data_centos.jinja2 index d487b68..b3103e6 100644 --- a/cloud-init-templates/meta-data_centos.jinja2 +++ b/cloud-init-templates/meta-data_centos.jinja2 @@ -1,10 +1,11 @@ # instance-id will be autogenerated # instance-id: iid-abcdefg network-interfaces: | + auto {{ common.admin_iface_name|default("eth0") }} iface {{ common.admin_iface_name|default("eth0") }} inet static address {{ common.admin_ip }} -# network 192.168.1.0 + # network 192.168.1.0 netmask {{ common.admin_mask }} -# broadcast 192.168.1.255 -# gateway 192.168.1.254 + # broadcast 192.168.1.255 + # gateway 192.168.1.254 hostname: {{ common.hostname }} diff --git a/cloud-init-templates/meta-data_ubuntu.jinja2 b/cloud-init-templates/meta-data_ubuntu.jinja2 index d487b68..b3103e6 100644 --- a/cloud-init-templates/meta-data_ubuntu.jinja2 +++ b/cloud-init-templates/meta-data_ubuntu.jinja2 @@ -1,10 +1,11 @@ # instance-id will be autogenerated # instance-id: iid-abcdefg network-interfaces: | + auto {{ common.admin_iface_name|default("eth0") }} iface {{ common.admin_iface_name|default("eth0") }} inet static address {{ common.admin_ip }} -# network 192.168.1.0 + # network 192.168.1.0 netmask {{ common.admin_mask }} -# broadcast 192.168.1.255 -# gateway 192.168.1.254 + # broadcast 192.168.1.255 + # gateway 192.168.1.254 hostname: {{ common.hostname }} diff --git a/fuel_agent/drivers/nailgun.py b/fuel_agent/drivers/nailgun.py index f135230..54bd2fd 100644 --- a/fuel_agent/drivers/nailgun.py +++ b/fuel_agent/drivers/nailgun.py @@ -321,7 +321,8 @@ class Nailgun(object): admin_mask=admin_interface['netmask'], admin_iface_name=admin_interface['name'], timezone=data['ks_meta'].get('timezone', 'America/Los_Angeles'), - ks_repos=dict(item.split('=') for item in + ks_repos=dict(map(lambda x: x.strip('"').strip("'"), + item.split('=')) for item in data['ks_meta']['repo_metadata'].split(',')) ) diff --git a/fuel_agent/tests/test_nailgun.py b/fuel_agent/tests/test_nailgun.py index 53bda2a..ce58444 100644 --- a/fuel_agent/tests/test_nailgun.py +++ b/fuel_agent/tests/test_nailgun.py @@ -106,7 +106,7 @@ PROVISION_SAMPLE_DATA = { "mco_auto_setup": 1, "auth_key": "fake_auth_key", "authorized_keys": ["fake_authorized_key1", "fake_authorized_key2"], - "repo_metadata": "repo1=repo1_url,repo2=repo2_url", + "repo_metadata": 'repo1="repo1_url",' + "repo2='repo2_url'", "pm_data": { "kernel_params": "console=ttyS0,9600 console=tty0 rootdelay=90 " "nomodeset",