diff options
author | Scott Moser <smoser@brickies.net> | 2016-08-23 16:48:28 -0400 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2016-08-23 16:48:28 -0400 |
commit | 440d9a2eaab4fdafea6546dcfb9a3aeb0b73ce3e (patch) | |
tree | bd5c38f8a37729c99e81630f9edfe6420c7580fe | |
parent | e994467c0a83809d3733b8870d8230e4c87f173f (diff) | |
download | cloud-init-git-440d9a2eaab4fdafea6546dcfb9a3aeb0b73ce3e.tar.gz |
Import version 0.6.3~bzr539-0ubuntu1ubuntu/0.6.3_bzr539-0ubuntu1
Imported using git-dsc-commit.
-rw-r--r-- | debian/changelog | 20 | ||||
-rw-r--r-- | debian/cloud-init.postinst | 129 | ||||
-rw-r--r-- | debian/cloud-init.postrm | 1 | ||||
-rw-r--r-- | debian/cloud-init.templates | 6 |
4 files changed, 153 insertions, 3 deletions
diff --git a/debian/changelog b/debian/changelog index 09709961..2fa9c07e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,23 @@ +cloud-init (0.6.3~bzr539-0ubuntu1) precise; urgency=low + + * New upstream snapshot. + * add ability to configure Acquire::http::Pipeline-Depth via + cloud-config setting 'apt_pipelining' (LP: #942061) + * if cloud-config settings removed default certificats + (remove-defaults), then seed package ca-certificates to not + install new ones on upgrade. + * run-parts now uses internal implementation rather than + separate command. + * add MaaS datasource (LP: #942061) + * debian/cloud-init.postinst: address population of apt_pipeline + setting on installation. + * debian/cloud-init.postinst: support configuring cloud-init + maas datasource via preseed values cloud-init/maas-metadata-url and + cloud-init/maas-credentials. (LP: #942061) + * debian/cloud-init.postinst: support for (LP: #924375) + + -- Scott Moser <smoser@ubuntu.com> Fri, 09 Mar 2012 16:37:01 -0500 + cloud-init (0.6.3~bzr530-0ubuntu1) precise; urgency=low * New upstream snapshot. diff --git a/debian/cloud-init.postinst b/debian/cloud-init.postinst index 3c7f36e2..4cb75d80 100644 --- a/debian/cloud-init.postinst +++ b/debian/cloud-init.postinst @@ -2,6 +2,115 @@ . /usr/share/debconf/confmodule +set -f # disable pathname expansion +db_capb escape # to support carriage return / multi-line values + +update_cfg() { + # takes filename, header, new object (in yaml), optionally 'remover' + # and merges new into existing object in filename, and then updates file + # remover a string that means "delete existing entry" + python -c ' +import sys, yaml + +def update(src, cand): + if not (isinstance(src, dict) and isinstance(cand, dict)): + return cand + for k, v in cand.iteritems(): + # if the candidate has _ as value, delete source + if v == REMOVER: + if k in src: + del src[k] + continue + if k not in src: + src[k] = v + else: + src[k] = update(src[k], v) + return src + +(fname, header, newyaml) = sys.argv[1:4] +REMOVER = object +if len(sys.argv) == 5: + REMOVER = sys.argv[4] +newcfg = yaml.load(newyaml) + +with open(fname, "r") as fp: + cfg = yaml.load(fp) +if not cfg: cfg = {} + +cfg = update(cfg, newcfg) + +with open(fname, "w") as fp: + fp.write(header + "\n") + fp.write(yaml.dump(cfg))' "$@" +} + +handle_preseed_maas() { + local cfg_file="/etc/cloud/cloud.cfg.d/90_dpkg_maas.cfg" + local md_url="" creds_all="" c_key="" t_key="" t_sec="" c_sec=""; + + db_get "cloud-init/maas-metadata-url" && md_url="$RET" || : + db_get "cloud-init/maas-metadata-credentials" && creds_all="$RET" || : + + # nothing to do + [ -n "$md_url" -o -n "$creds_all" ] || return 0 + + # change a url query string format into : delimited + if [ -n "$creds_all" -a "${creds_all#*&}" != "${creds_all}" ]; then + creds_all=$(python -c 'from urlparse import parse_qs; import sys; +keys = parse_qs(sys.argv[1]) +for k in sys.argv[2:]: + sys.stdout.write("%s:" % keys.get(k,[""])[0])' "$creds_all" \ + oauth_consumer_key oauth_token_key oauth_token_secret +) + fi + + # now, if non-empty creds_all is: consumer_key:token_key:token_secret + if [ -n "$creds_all" ]; then + OIFS="$IFS"; IFS=:; set -- $creds_all; IFS="$OIFS" + c_key=$1; t_key=$2; t_sec=$3 + fi + + if [ "$md_url" = "_" -a "${c_key}:${t_key}:${t_sec}" = "_:_:_" ]; then + # if all these values were '_', the delete value, just delete the file. + rm -f "$cfg_file" + else + local header="# written by cloud-init debian package per preseed entries +# cloud-init/{maas-metadata-url,/maas-metadata-credentials}" + + local pair="" k="" v="" pload="" + for pair in "metadata_url:$md_url" "consumer_key:${c_key}" \ + "token_key:${t_key}" "token_secret:$t_sec"; do + k=${pair%%:*} + v=${pair#${k}:} + [ -n "$v" ] && pload="${pload} $k: \"$v\"," + done + + # '_' would indicate "delete", otherwise, existing entries are left + : >> "$cfg_file" && chmod go-w "$cfg_file" + update_cfg "$cfg_file" "$header" "datasource: { MaaS: { ${pload%,} } }" _ + fi + + # now clear the database of the values, as they've been consumed + db_unregister "cloud-init/maas-metadata-url" || : + db_unregister "cloud-init/maas-metadata-credentials" || : +} + +handle_preseed_local_cloud_config() { + local ccfg="" debconf_name="cloud-init/local-cloud-config" + local cfg_file="/etc/cloud/cloud.cfg.d/90_dpkg_local_cloud_config.cfg" + local header="# written by cloud-init debian package per preseed entry +# $debconf_name" + + db_get "${debconf_name}" && ccfg="$RET" || : + + if [ "$ccfg" = "_" ]; then + rm -f "$cfg_file" + elif [ -n "$ccfg" ]; then + { echo "$header"; echo "$ccfg"; } > "$cfg_file" + fi + db_unregister "${debconf_name}" || : +} + if [ "$1" = "configure" ]; then # disable ureadahead (LP: #499520) dpkg-divert --package cloud-init --rename --divert \ @@ -12,6 +121,26 @@ if [ "$1" = "configure" ]; then datasource_list: [ $RET ] EOF fi + + # we want to affect apt_pipelining on install, not wait for + # cloud-init to run it on next boot. + pipeline_f="/etc/apt/apt.conf.d/90cloud-init-pipelining" + if [ -f /var/lib/cloud/instance/obj.pkl ]; then + cloud-init-cfg apt_pipelining once-per-instance >/dev/null 2>&1 || + echo "Warning: failed to setup apt_pipelining" 1>&2 + elif [ ! -f "$pipeline_f" ]; then + # there was no cloud available, so populate it ourselves. + cat > "$pipeline_f" <<EOF +//Written by cloud-init per 'apt_pipelining' +Acquire::http::Pipeline-Depth "0"; +EOF + fi + + # if there are maas settings pre-seeded apply them + handle_preseed_maas + + # if there is generic cloud-config preseed, apply them + handle_preseed_local_cloud_config fi #DEBHELPER# diff --git a/debian/cloud-init.postrm b/debian/cloud-init.postrm index be09e409..59814f6a 100644 --- a/debian/cloud-init.postrm +++ b/debian/cloud-init.postrm @@ -9,6 +9,7 @@ case "$1" in remove) dpkg-divert --package cloud-init --remove --rename --divert \ /etc/init/ureadahead.conf.disabled /etc/init/ureadahead.conf + rm -f /etc/cloud/cloud.cfg.d/90cloud-init-pipelining ;; esac diff --git a/debian/cloud-init.templates b/debian/cloud-init.templates index 2b3a4b0a..dbe6d9ed 100644 --- a/debian/cloud-init.templates +++ b/debian/cloud-init.templates @@ -1,8 +1,8 @@ Template: cloud-init/datasources Type: multiselect -Default: NoCloud, ConfigDrive, OVF -Choices-C: NoCloud, ConfigDrive, OVF, Ec2 -Choices: NoCloud: Reads info from /var/lib/cloud/seed only, ConfigDrive: Reads data from Openstack Config Drive, OVF: Reads data from OVF Transports, Ec2: reads data from EC2 Metadata service +Default: NoCloud, ConfigDrive, OVF, MaaS +Choices-C: NoCloud, ConfigDrive, OVF, MaaS, Ec2 +Choices: NoCloud: Reads info from /var/lib/cloud/seed only, ConfigDrive: Reads data from Openstack Config Drive, OVF: Reads data from OVF Transports, MaaS: Reads data from Ubuntu MaaS, Ec2: reads data from EC2 Metadata service Description: Which data sources should be searched? Cloud-init supports searching different "Data Sources" for information that it uses to configure a cloud instance. |