summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rwxr-xr-xbin/cloud-init2
-rw-r--r--cloudinit/config/cc_resolv_conf.py29
-rw-r--r--cloudinit/ec2_utils.py4
-rw-r--r--cloudinit/settings.py2
-rw-r--r--cloudinit/sources/DataSourceCloudStack.py3
-rw-r--r--doc/examples/cloud-config-disk-setup.txt16
-rw-r--r--systemd/cloud-init.service3
-rw-r--r--templates/resolv.conf.tmpl2
-rw-r--r--tests/unittests/test_datasource/test_openstack.py4
-rw-r--r--tests/unittests/test_ec2_util.py8
11 files changed, 49 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog
index 296a15cd..b420d037 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,13 @@
- SeLinuxGuard: remove invalid check that looked for stat.st_mode in os.lstat.
- do not write comments in /etc/timezone (LP: #1341710)
- ubuntu: provide 'ubuntu-init-switch' module to aid in systemd testing.
+ - status/result json: remove 'end' entry which was always null
+ - systemd: make cloud-init block ssh service startup to guarantee keys
+ are generated. [Jordan Evans] (LP: #1333920)
+ - default settings: fix typo resulting in OpenStack and GCE not working
+ unless config explicitly provided (LP: #1329583) [Garrett Holmstrom])
+ - fix rendering resolv.conf if no 'options' are provided (LP: #1328953)
+ - docs: fix disk-setup to reference 'table_type' [Rail Aliiev] (LP: #1313114)
0.7.5:
- open 0.7.5
- Add a debug log message around import failures
diff --git a/bin/cloud-init b/bin/cloud-init
index ad0ba214..866f8ca4 100755
--- a/bin/cloud-init
+++ b/bin/cloud-init
@@ -478,7 +478,7 @@ def status_wrapper(name, args, data_d=None, link_d=None):
nullstatus = {
'errors': [],
'start': None,
- 'end': None,
+ 'finished': None,
}
status = {'v1': {}}
for m in modes:
diff --git a/cloudinit/config/cc_resolv_conf.py b/cloudinit/config/cc_resolv_conf.py
index 879b62b1..bbaa6c63 100644
--- a/cloudinit/config/cc_resolv_conf.py
+++ b/cloudinit/config/cc_resolv_conf.py
@@ -49,23 +49,22 @@
#
+from cloudinit import log as logging
from cloudinit.settings import PER_INSTANCE
from cloudinit import templater
from cloudinit import util
+LOG = logging.getLogger(__name__)
+
frequency = PER_INSTANCE
distros = ['fedora', 'rhel', 'sles']
-def generate_resolv_conf(cloud, log, params):
- template_fn = cloud.get_template_filename('resolv.conf')
- if not template_fn:
- log.warn("No template found, not rendering /etc/resolv.conf")
- return
-
+def generate_resolv_conf(template_fn, params, target_fname="/etc/resolv.conf"):
flags = []
false_flags = []
+
if 'options' in params:
for key, val in params['options'].iteritems():
if type(val) == bool:
@@ -77,12 +76,15 @@ def generate_resolv_conf(cloud, log, params):
for flag in flags + false_flags:
del params['options'][flag]
+ if not params.get('options'):
+ params['options'] = {}
+
params['flags'] = flags
- log.debug("Writing resolv.conf from template %s" % template_fn)
- templater.render_to_file(template_fn, '/etc/resolv.conf', params)
+ LOG.debug("Writing resolv.conf from template %s" % template_fn)
+ templater.render_to_file(template_fn, target_fname, params)
-def handle(name, cfg, _cloud, log, _args):
+def handle(name, cfg, cloud, log, _args):
"""
Handler for resolv.conf
@@ -102,8 +104,13 @@ def handle(name, cfg, _cloud, log, _args):
" 'manage_resolv_conf' present but set to False"), name)
return
- if not "resolv_conf" in cfg:
+ if "resolv_conf" not in cfg:
log.warn("manage_resolv_conf True but no parameters provided!")
- generate_resolv_conf(_cloud, log, cfg["resolv_conf"])
+ template_fn = cloud.get_template_filename('resolv.conf')
+ if not template_fn:
+ log.warn("No template found, not rendering /etc/resolv.conf")
+ return
+
+ generate_resolv_conf(template_fn=template_fn, params=cfg["resolv_conf"])
return
diff --git a/cloudinit/ec2_utils.py b/cloudinit/ec2_utils.py
index a7c9c9ab..0c751140 100644
--- a/cloudinit/ec2_utils.py
+++ b/cloudinit/ec2_utils.py
@@ -166,7 +166,9 @@ def get_instance_metadata(api_version='latest',
metadata_address='http://169.254.169.254',
ssl_details=None, timeout=5, retries=5):
md_url = url_helper.combine_url(metadata_address, api_version)
- md_url = url_helper.combine_url(md_url, 'meta-data')
+ # Note, 'meta-data' explicitly has trailing /.
+ # this is required for CloudStack (LP: #1356855)
+ md_url = url_helper.combine_url(md_url, 'meta-data/')
caller = functools.partial(util.read_file_or_url,
ssl_details=ssl_details, timeout=timeout,
retries=retries)
diff --git a/cloudinit/settings.py b/cloudinit/settings.py
index 37d4958b..5efcb0b0 100644
--- a/cloudinit/settings.py
+++ b/cloudinit/settings.py
@@ -37,7 +37,7 @@ CFG_BUILTIN = {
'OVF',
'MAAS',
'GCE',
- 'OpenStack'
+ 'OpenStack',
'Ec2',
'CloudSigma',
'CloudStack',
diff --git a/cloudinit/sources/DataSourceCloudStack.py b/cloudinit/sources/DataSourceCloudStack.py
index 08f661e4..1bbeca59 100644
--- a/cloudinit/sources/DataSourceCloudStack.py
+++ b/cloudinit/sources/DataSourceCloudStack.py
@@ -78,7 +78,8 @@ class DataSourceCloudStack(sources.DataSource):
(max_wait, timeout) = self._get_url_settings()
- urls = [self.metadata_address + "/latest/meta-data/instance-id"]
+ urls = [uhelp.combine_url(self.metadata_address,
+ 'latest/meta-data/instance-id')]
start_time = time.time()
url = uhelp.wait_for_url(urls=urls, max_wait=max_wait,
timeout=timeout, status_cb=LOG.warn)
diff --git a/doc/examples/cloud-config-disk-setup.txt b/doc/examples/cloud-config-disk-setup.txt
index 0dfef8e8..3e46a22e 100644
--- a/doc/examples/cloud-config-disk-setup.txt
+++ b/doc/examples/cloud-config-disk-setup.txt
@@ -7,7 +7,7 @@
disk_setup:
ephmeral0:
- type: 'mbr'
+ table_type: 'mbr'
layout: True
overwrite: False
@@ -23,7 +23,7 @@ fs_setup:
device_aliases: {'ephemeral0': '/dev/sdb'}
disk_setup:
ephemeral0:
- type: mbr
+ table_type: mbr
layout: True
overwrite: False
@@ -40,7 +40,7 @@ fs_setup:
device_aliases: {'ephemeral0': '/dev/sdb'}
disk_setup:
ephemeral0:
- type: mbr
+ table_type: mbr
layout: False
overwrite: False
@@ -63,10 +63,10 @@ fs_setup:
disk_setup:
ephmeral0:
- type: 'mbr'
+ table_type: 'mbr'
layout: 'auto'
/dev/xvdh:
- type: 'mbr'
+ table_type: 'mbr'
layout:
- 33
- [33, 82]
@@ -79,7 +79,7 @@ disk_setup:
# The general format is:
# disk_setup:
# <DEVICE>:
-# type: 'mbr'
+# table_type: 'mbr'
# layout: <LAYOUT|BOOL>
# overwrite: <BOOL>
#
@@ -96,7 +96,7 @@ disk_setup:
# Note: At this time, there is no handling or setup of
# device mapper targets.
#
-# type=<TYPE>: Currently the following are supported:
+# table_type=<TYPE>: Currently the following are supported:
# 'mbr': default and setups a MS-DOS partition table
#
# Note: At this time only 'mbr' partition tables are allowed.
@@ -116,7 +116,7 @@ disk_setup:
# partition having a swap label, taking 1/3 of the disk space
# and the remainder being used as the second partition.
# /dev/xvdh':
-# type: 'mbr'
+# table_type: 'mbr'
# layout:
# - [33,82]
# - 66
diff --git a/systemd/cloud-init.service b/systemd/cloud-init.service
index 018a1fa8..6b0c7229 100644
--- a/systemd/cloud-init.service
+++ b/systemd/cloud-init.service
@@ -1,8 +1,9 @@
[Unit]
Description=Initial cloud-init job (metadata service crawler)
After=local-fs.target network.target cloud-init-local.service
+Before=sshd.service sshd-keygen.service
Requires=network.target
-Wants=local-fs.target cloud-init-local.service
+Wants=local-fs.target cloud-init-local.service sshd.service sshd-keygen.service
[Service]
Type=oneshot
diff --git a/templates/resolv.conf.tmpl b/templates/resolv.conf.tmpl
index 6f908f30..1300156c 100644
--- a/templates/resolv.conf.tmpl
+++ b/templates/resolv.conf.tmpl
@@ -21,7 +21,7 @@ domain {{domain}}
sortlist {% for sort in sortlist %}{{sort}} {% endfor %}
{% endif %}
-{% if options is defined or flags is defined %}
+{% if options or flags %}
options {% for flag in flags %}{{flag}} {% endfor %}
{% for key, value in options.iteritems() -%}
diff --git a/tests/unittests/test_datasource/test_openstack.py b/tests/unittests/test_datasource/test_openstack.py
index c088bb55..f43cbec8 100644
--- a/tests/unittests/test_datasource/test_openstack.py
+++ b/tests/unittests/test_datasource/test_openstack.py
@@ -88,7 +88,7 @@ def _register_uris(version, ec2_files, ec2_meta, os_files):
path = uri.path.lstrip("/")
if path in ec2_files:
return (200, headers, ec2_files.get(path))
- if path == 'latest/meta-data':
+ if path == 'latest/meta-data/':
buf = StringIO()
for (k, v) in ec2_meta.items():
if isinstance(v, (list, tuple)):
@@ -97,7 +97,7 @@ def _register_uris(version, ec2_files, ec2_meta, os_files):
buf.write("%s" % (k))
buf.write("\n")
return (200, headers, buf.getvalue())
- if path.startswith('latest/meta-data'):
+ if path.startswith('latest/meta-data/'):
value = None
pieces = path.split("/")
if path.endswith("/"):
diff --git a/tests/unittests/test_ec2_util.py b/tests/unittests/test_ec2_util.py
index 700254a3..84aa002e 100644
--- a/tests/unittests/test_ec2_util.py
+++ b/tests/unittests/test_ec2_util.py
@@ -44,7 +44,7 @@ class TestEc2Util(helpers.HttprettyTestCase):
@hp.activate
def test_metadata_fetch_no_keys(self):
- base_url = 'http://169.254.169.254/%s/meta-data' % (self.VERSION)
+ base_url = 'http://169.254.169.254/%s/meta-data/' % (self.VERSION)
hp.register_uri(hp.GET, base_url, status=200,
body="\n".join(['hostname',
'instance-id',
@@ -62,7 +62,7 @@ class TestEc2Util(helpers.HttprettyTestCase):
@hp.activate
def test_metadata_fetch_key(self):
- base_url = 'http://169.254.169.254/%s/meta-data' % (self.VERSION)
+ base_url = 'http://169.254.169.254/%s/meta-data/' % (self.VERSION)
hp.register_uri(hp.GET, base_url, status=200,
body="\n".join(['hostname',
'instance-id',
@@ -83,7 +83,7 @@ class TestEc2Util(helpers.HttprettyTestCase):
@hp.activate
def test_metadata_fetch_with_2_keys(self):
- base_url = 'http://169.254.169.254/%s/meta-data' % (self.VERSION)
+ base_url = 'http://169.254.169.254/%s/meta-data/' % (self.VERSION)
hp.register_uri(hp.GET, base_url, status=200,
body="\n".join(['hostname',
'instance-id',
@@ -108,7 +108,7 @@ class TestEc2Util(helpers.HttprettyTestCase):
@hp.activate
def test_metadata_fetch_bdm(self):
- base_url = 'http://169.254.169.254/%s/meta-data' % (self.VERSION)
+ base_url = 'http://169.254.169.254/%s/meta-data/' % (self.VERSION)
hp.register_uri(hp.GET, base_url, status=200,
body="\n".join(['hostname',
'instance-id',