From 7b2fc4e014e6b7a43e6b8fc719d82c3d0b0a8bed Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 4 Apr 2012 21:35:32 -0400 Subject: initial checkin of kernel commandline cloud-config url support --- doc/kernel-cmdline.txt | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 doc/kernel-cmdline.txt (limited to 'doc') diff --git a/doc/kernel-cmdline.txt b/doc/kernel-cmdline.txt new file mode 100644 index 00000000..0b77a9af --- /dev/null +++ b/doc/kernel-cmdline.txt @@ -0,0 +1,48 @@ +In order to allow an ephemeral, or otherwise pristine image to +receive some configuration, cloud-init will read a url directed by +the kernel command line and proceed as if its data had previously existed. + +This allows for configuring a meta-data service, or some other data. + +Note, that usage of the kernel command line is somewhat of a last resort, +as it requires knowing in advance the correct command line or modifying +the boot loader to append data. + +For example, when 'cloud-init start' runs, it will check to +see if if one of 'cloud-config-url' or 'url' appear in key/value fashion +in the kernel command line as in: + root=/dev/sda ro url=http://foo.bar.zee/abcde + +Cloud-init will then read the contents of the given url. +If the content starts with '#cloud-config', it will store +that data to the local filesystem in a static filename +'/etc/cloud/cloud.cfg.d/91_kernel_cmdline_url.cfg', and consider it as +part of the config from that point forward. + +If that file exists already, it will not be overwritten, and the url parameters +completely ignored. + +Then, when the DataSource runs, it will find that config already available. + +So, in able to configure the MAAS DataSource by controlling the kernel +command line from outside the image, you can append: + url=http://your.url.here/abcdefg +or + cloud-config-url=http://your.url.here/abcdefg + +Then, have the following content at that url: + #cloud-config + datasource: + MAAS: + metadata_url: http://mass-host.localdomain/source + consumer_key: Xh234sdkljf + token_key: kjfhgb3n + token_secret: 24uysdfx1w4 + +Notes: + * Because 'url=' is so very generic, in order to avoid false positives, + cloud-init requires the content to start with '#cloud-config' in order + for it to be considered. + * The url= is un-authed http GET, and contains credentials + It could be set up to be randomly generated and also check source + address in order to be more secure -- cgit v1.2.3 From e105bfb7b3bf352244a73fc3a7e08a12a102f477 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 4 Apr 2012 22:05:17 -0400 Subject: add reading of 'seedfrom' via DataSourceNoCloud's DataSourceConfig What this does is provide an second DataSource that could use the kernel command line url=. For example: ro root=/dev/vda url=http://example.com/i-abcdefg/ http://example.com/i-abcdefg/ would contain: datasource: NoCloud: # default seedfrom is None # if found, then it should contain a url with: # /user-data and /meta-data # seedfrom: http://my.example.com/i-abcde seedfrom: http://example.com/i-abcdefg/ Then, the NoCloudNet DataSource would find that seedfrom config and consume data at http://example.com/i-abcdefg/user-data and http://example.com/i-abcdefg/meta-data --- cloudinit/DataSourceNoCloud.py | 7 +++++++ doc/examples/cloud-config-datasources.txt | 7 +++++++ 2 files changed, 14 insertions(+) (limited to 'doc') diff --git a/cloudinit/DataSourceNoCloud.py b/cloudinit/DataSourceNoCloud.py index 62ecc088..fe649513 100644 --- a/cloudinit/DataSourceNoCloud.py +++ b/cloudinit/DataSourceNoCloud.py @@ -67,6 +67,13 @@ class DataSourceNoCloud(DataSource.DataSource): found.append(self.seeddir) log.debug("using seeded cache data in %s" % self.seeddir) + # if the datasource config had a 'seedfrom' entry, then that takes + # precedence over a 'seedfrom' that was found in a filesystem + # but not over external medi + if 'seedfrom' in self.ds_cfg and self.ds_cfg['seedfrom']: + found.append(["ds_config"]) + md["seedfrom"] = self.ds_cfg['seedfrom'] + fslist = util.find_devs_with("TYPE=vfat") fslist.extend(util.find_devs_with("TYPE=iso9660")) diff --git a/doc/examples/cloud-config-datasources.txt b/doc/examples/cloud-config-datasources.txt index 63a6cfc4..d10dde05 100644 --- a/doc/examples/cloud-config-datasources.txt +++ b/doc/examples/cloud-config-datasources.txt @@ -24,3 +24,10 @@ datasource: consumer_key: Xh234sdkljf token_key: kjfhgb3n token_secret: 24uysdfx1w4 + + NoCloud: + # default seedfrom is None + # if found, then it should contain a url with: + # /user-data and /meta-data + # seedfrom: http://my.example.com/i-abcde + seedfrom: None -- cgit v1.2.3