From a6282380814750851c0dc2ac2d4d3386eb6fcce4 Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Thu, 12 May 2016 09:26:27 +0200 Subject: update doc/examples/cloud-config.txt with new key-without-source cases --- doc/examples/cloud-config.txt | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt index 1236796c..f84d526d 100644 --- a/doc/examples/cloud-config.txt +++ b/doc/examples/cloud-config.txt @@ -111,12 +111,14 @@ apt_sources: keyid: F430BBA5 # GPG key ID published on a key server filename: byobu-ppa.list + # this would only import the key without adding a ppa or other source spec + - keyid: F430BBA5 # GPG key ID published on a key server + # Custom apt repository: # * The apt signing key can also be specified # by providing a pgp public key block # * Providing the PBG key here is the most robust method for # specifying a key, as it removes dependency on a remote key server - - source: deb http://ppa.launchpad.net/alestic/ppa/ubuntu karmic main key: | # The value needs to start with -----BEGIN PGP PUBLIC KEY BLOCK----- -----BEGIN PGP PUBLIC KEY BLOCK----- @@ -132,6 +134,24 @@ apt_sources: =Y2oI -----END PGP PUBLIC KEY BLOCK----- + # Custom gpg key: + # * As the keyid also a key can be specified withut a related source + # * all other facts mentioned above still apply + - key: | # The value needs to start with -----BEGIN PGP PUBLIC KEY BLOCK----- + -----BEGIN PGP PUBLIC KEY BLOCK----- + Version: SKS 1.0.10 + + mI0ESpA3UQEEALdZKVIMq0j6qWAXAyxSlF63SvPVIgxHPb9Nk0DZUixn+akqytxG4zKCONz6 + qLjoBBfHnynyVLfT4ihg9an1PqxRnTO+JKQxl8NgKGz6Pon569GtAOdWNKw15XKinJTDLjnj + 9y96ljJqRcpV9t/WsIcdJPcKFR5voHTEoABE2aEXABEBAAG0GUxhdW5jaHBhZCBQUEEgZm9y + IEFsZXN0aWOItgQTAQIAIAUCSpA3UQIbAwYLCQgHAwIEFQIIAwQWAgMBAh4BAheAAAoJEA7H + 5Qi+CcVxWZ8D/1MyYvfj3FJPZUm2Yo1zZsQ657vHI9+pPouqflWOayRR9jbiyUFIn0VdQBrP + t0FwvnOFArUovUWoKAEdqR8hPy3M3APUZjl5K4cMZR/xaMQeQRZ5CHpS4DBKURKAHC0ltS5o + uBJKQOZm5iltJp15cgyIkBkGe8Mx18VFyVglAZey + =Y2oI + -----END PGP PUBLIC KEY BLOCK----- + + ## apt config via system_info: # under the 'system_info', you can further customize cloud-init's interaction # with apt. -- cgit v1.2.3 From 3be3e7452410d97ef9f9d4b525fa828de1f57bc0 Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Thu, 12 May 2016 16:27:50 +0200 Subject: Document apt_custom_sources_list in examples --- doc/examples/cloud-config.txt | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'doc') diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt index f84d526d..75a4b6d4 100644 --- a/doc/examples/cloud-config.txt +++ b/doc/examples/cloud-config.txt @@ -72,6 +72,36 @@ apt_pipelining: False # then apt_mirror above will have no effect apt_preserve_sources_list: true +# Provide a custom template for rednering sources.list +# Default: a default template for Ubuntu/Debain will be used as packaged in +# Ubuntu: /etc/cloud/templates/sources.list.ubuntu.tmpl +# Debian: /etc/cloud/templates/sources.list.debian.tmpl +# Others: n/a +# This will follow the normal mirror/codename replacement rules before +# being written to disk. +apt_custom_sources_list: | + ## template:jinja + ## Note, this file is written by cloud-init on first boot of an instance + ## modifications made here will not survive a re-bundle. + ## if you wish to make changes you can: + ## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg + ## or do the same in user-data + ## b.) add sources in /etc/apt/sources.list.d + ## c.) make changes to template file /etc/cloud/templates/sources.list.tmpl + deb {{mirror}} {{codename}} main restricted + deb-src {{mirror}} {{codename}} main restricted + + # could drop some of the usually used entries + + # could refer to other mirrors + deb http://ddebs.ubuntu.com {{codename}} main restricted universe multiverse + deb http://ddebs.ubuntu.com {{codename}}-updates main restricted universe multiverse + deb http://ddebs.ubuntu.com {{codename}}-proposed main restricted universe multiverse + + # or even more uncommon examples like local or NFS mounted repos, + # eventually whatever is compatible with sources.list syntax + deb file:/home/apt/debian unstable main contrib non-free + # 'source' entries in apt-sources that match this python regex # expression will be passed to add-apt-repository add_apt_repo_match: '^[\w-]+:\w' -- cgit v1.2.3 From 3ece03a2df95bdb40851b9d629b39c43a233868b Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Thu, 12 May 2016 21:03:51 +0200 Subject: alphabetical import order --- doc/examples/cloud-config.txt | 3 +++ tests/unittests/test_handler/test_handler_apt_source.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt index 75a4b6d4..8adc5a96 100644 --- a/doc/examples/cloud-config.txt +++ b/doc/examples/cloud-config.txt @@ -144,6 +144,9 @@ apt_sources: # this would only import the key without adding a ppa or other source spec - keyid: F430BBA5 # GPG key ID published on a key server + # In general keyid's can also be specified via their long fingerprints + - keyid: B59D 5F15 97A5 04B7 E230 6DCA 0620 BBCF 0368 3F77 + # Custom apt repository: # * The apt signing key can also be specified # by providing a pgp public key block diff --git a/tests/unittests/test_handler/test_handler_apt_source.py b/tests/unittests/test_handler/test_handler_apt_source.py index 88b4ccc6..439bd038 100644 --- a/tests/unittests/test_handler/test_handler_apt_source.py +++ b/tests/unittests/test_handler/test_handler_apt_source.py @@ -2,17 +2,17 @@ Testing various config variations of the apt_source config """ import os +import re import shutil import tempfile -import re try: from unittest import mock except ImportError: import mock -from cloudinit import util from cloudinit.config import cc_apt_configure +from cloudinit import util from ..helpers import TestCase -- cgit v1.2.3 From 3c2c85a7c152c5026ff3122a7e134c5db4cfdce7 Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Thu, 12 May 2016 21:09:34 +0200 Subject: fix old typo in example --- doc/examples/cloud-config.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt index 8adc5a96..31b791b6 100644 --- a/doc/examples/cloud-config.txt +++ b/doc/examples/cloud-config.txt @@ -150,7 +150,7 @@ apt_sources: # Custom apt repository: # * The apt signing key can also be specified # by providing a pgp public key block - # * Providing the PBG key here is the most robust method for + # * Providing the PGP key here is the most robust method for # specifying a key, as it removes dependency on a remote key server - source: deb http://ppa.launchpad.net/alestic/ppa/ubuntu karmic main key: | # The value needs to start with -----BEGIN PGP PUBLIC KEY BLOCK----- -- cgit v1.2.3 From ea4bc2c603a9d964a918e01d00e39a851e979830 Mon Sep 17 00:00:00 2001 From: Matt Fischer Date: Tue, 17 May 2016 20:55:32 +0000 Subject: Document improvements for runcmd/bootcmd Note that runcmd runs only on first boot. Note that strings need to be quoted, not escaped. Switch bootcmd list text to use - not * like everything else. --- doc/examples/cloud-config-boot-cmds.txt | 6 +++--- doc/examples/cloud-config-run-cmds.txt | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'doc') diff --git a/doc/examples/cloud-config-boot-cmds.txt b/doc/examples/cloud-config-boot-cmds.txt index b281d327..3e59755d 100644 --- a/doc/examples/cloud-config-boot-cmds.txt +++ b/doc/examples/cloud-config-boot-cmds.txt @@ -7,9 +7,9 @@ # bootcmd should really only be used for things that could not be # done later in the boot process. bootcmd is very much like # boothook, but possibly with more friendly. -# * bootcmd will run on every boot -# * the INSTANCE_ID variable will be set to the current instance id. -# * you can use 'cloud-init-boot-per' command to help only run once +# - bootcmd will run on every boot +# - the INSTANCE_ID variable will be set to the current instance id. +# - you can use 'cloud-init-boot-per' command to help only run once bootcmd: - echo 192.168.1.130 us.archive.ubuntu.com > /etc/hosts - [ cloud-init-per, once, mymkfs, mkfs, /dev/vdb ] diff --git a/doc/examples/cloud-config-run-cmds.txt b/doc/examples/cloud-config-run-cmds.txt index 61b3bd63..3bb06864 100644 --- a/doc/examples/cloud-config-run-cmds.txt +++ b/doc/examples/cloud-config-run-cmds.txt @@ -5,12 +5,13 @@ # runcmd contains a list of either lists or a string # each item will be executed in order at rc.local like level with # output to the console +# - runcmd only runs during the first boot # - if the item is a list, the items will be properly executed as if # passed to execve(3) (with the first arg as the command). # - if the item is a string, it will be simply written to the file and # will be interpreted by 'sh' # -# Note, that the list has to be proper yaml, so you have to escape +# Note, that the list has to be proper yaml, so you have to quote # any characters yaml would eat (':' can be problematic) runcmd: - [ ls, -l, / ] -- cgit v1.2.3 From 1df451e76d98371cf54e7a474c4d46fa3a96361a Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Fri, 20 May 2016 13:03:42 +0100 Subject: Clean up merging.rst formatting --- doc/merging.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'doc') diff --git a/doc/merging.rst b/doc/merging.rst index d4d5cd05..4046338b 100644 --- a/doc/merging.rst +++ b/doc/merging.rst @@ -19,13 +19,13 @@ For example. run_cmd: - bash1 - bash2 - + #cloud-config (2) run_cmd: - bash3 - bash4 -The previous way of merging the following 2 objects would result in a final +The previous way of merging the following 2 objects would result in a final cloud-config object that contains the following. .. code-block:: yaml @@ -56,7 +56,7 @@ Customizability Since the above merging algorithm may not always be the desired merging algorithm (like how the previous merging algorithm was not always the preferred one) the concept of customizing how merging can be done was introduced through -a new concept call 'merge classes'. +a new concept call 'merge classes'. A merge class is a class defintion which provides functions that can be used to merge a given type with another given type. @@ -69,7 +69,7 @@ An example of one of these merging classes is the following: def __init__(self, merger, opts): self._merger = merger self._overwrite = 'overwrite' in opts - + # This merging algorithm will attempt to merge with # another dictionary, on encountering any other type of object # it will not merge with said object, but will instead return @@ -129,12 +129,12 @@ for your own usage. definition are the following (in order), 'merge_how', 'merge_type'. String format -******** +************* The string format that is expected is the following. :: - + classname1(option1,option2)+classname2(option3,option4).... The class name there will be connected to class names used when looking for the @@ -144,11 +144,11 @@ on construction of that class. For example, the default string that is used when none is provided is the following: :: - + list()+dict()+str() Dictionary format -******** +***************** In cases where a dictionary can be used to specify the same information as the string format (ie option #2 of above) it can be used, for example. @@ -171,7 +171,7 @@ for every cloud-config that I provide, what exactly happens? The answer is that when merging, a stack of 'merging classes' is kept, the first one on that stack is the default merging classes, this set of mergers will be used when the first cloud-config is merged with the initial empty -cloud-config dictionary. If the cloud-config that was just merged provided a +cloud-config dictionary. If the cloud-config that was just merged provided a set of merging classes (via the above formats) then those merging classes will be pushed onto the stack. Now if there is a second cloud-config to be merged then the merging classes from the cloud-config before the first will be used (not the -- cgit v1.2.3 From b699df642dec996c517a94ea44f5e763c08570d0 Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Fri, 20 May 2016 13:13:08 +0100 Subject: Update merging documentation to make its application clearer Currently, some users think that user-data and conf.d configuration will be merged together[0]. This has never been the case, and we should make it clear that this is not currently supported to avoid user confusion. [0] https://bugs.launchpad.net/cloud-init/+bug/1532234 --- doc/merging.rst | 24 +++++++++++++++--------- doc/rtd/topics/merging.rst | 6 +++--- 2 files changed, 18 insertions(+), 12 deletions(-) (limited to 'doc') diff --git a/doc/merging.rst b/doc/merging.rst index 4046338b..2967ca9d 100644 --- a/doc/merging.rst +++ b/doc/merging.rst @@ -1,15 +1,16 @@ Overview -------- -This was done because it has been a common feature request that there be a -way to specify how cloud-config yaml "dictionaries" are merged together when -there are multiple yamls to merge together (say when performing an #include). +This was implemented because it has been a common feature request that there be +a way to specify how cloud-config yaml "dictionaries" provided as user-data are +merged together when there are multiple yamls to merge together (say when +performing an #include). Since previously the merging algorithm was very simple and would only overwrite and not append lists, or strings, and so on it was decided to create a new and improved way to merge dictionaries (and there contained objects) together in a -way that is customizable, thus allowing for users who provide cloud-config data -to determine exactly how there objects will be merged. +way that is customizable, thus allowing for users who provide cloud-config +user-data to determine exactly how there objects will be merged. For example. @@ -181,8 +182,13 @@ cloud-config dictionary coming after it. Other uses ---------- -The default merging algorithm for merging 'conf.d' yaml files (which form a initial -yaml config for cloud-init) was also changed to use this mechanism so its full +In addition to being used for merging user-data sections, the default merging +algorithm for merging 'conf.d' yaml files (which form an initial yaml config +for cloud-init) was also changed to use this mechanism so its full benefits (and customization) can also be used there as well. Other places that -used the previous merging are also similar now extensible (metadata merging for -example). +used the previous merging are also, similarly, now extensible (metadata +merging, for example). + +Note, however, that merge algorithms are not used *across* types of +configuration. As was previously the case, merged user-data will still +overwrite conf.d configuration. diff --git a/doc/rtd/topics/merging.rst b/doc/rtd/topics/merging.rst index 8a03f3c7..2bd87b16 100644 --- a/doc/rtd/topics/merging.rst +++ b/doc/rtd/topics/merging.rst @@ -1,5 +1,5 @@ -========= -Merging -========= +========================== +Merging User-Data Sections +========================== .. include:: ../../merging.rst -- cgit v1.2.3 From 65ad82bec66ea3379a20785b1932ed1dc3c17b67 Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Mon, 23 May 2016 16:46:30 +0200 Subject: modify cloud-config examples to match the new apt_source format --- doc/examples/cloud-config.txt | 76 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 11 deletions(-) (limited to 'doc') diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt index 31b791b6..50c6d282 100644 --- a/doc/examples/cloud-config.txt +++ b/doc/examples/cloud-config.txt @@ -106,10 +106,52 @@ apt_custom_sources_list: | # expression will be passed to add-apt-repository add_apt_repo_match: '^[\w-]+:\w' +# 'apt_sources' is a dictionary +# The key is the filename and will be prepended by /etc/apt/sources.list.d/ if +# it doesn't start with a '/'. +# There are certain cases - where no content is written into a source.list file +# where the filename will be ignored - yet it can still be used as index for +# merging. +# The value it maps to is a dictionary with the following optional entries: +# 'source': a sources.list entry (some variable replacements apply) +# 'keyid': providing a key to import via shortid or fingerprint +# 'key': providing a raw PGP key +# 'filename': for compatibility with the older format (now the key to this +# dictionary is the filename). If specified this overwrites the +# filename given as key. + +# the new "filename: {specification-dictionary}, filename2: ..." format allows +# better merging between multiple input files than a list like: +# cloud-config1 +# sources: + s1: {'key': 'key1', 'source': 'source1'} +# cloud-config2 +# sources: + s2: {'key': 'key2'} + s1: {filename: 'foo'} +# this would be merged to +#sources: +# s1: +# filename: foo +# key: key1 +# source: source1 +# s2: +# key: key2 +# Be aware that this style of merging is not the default (for backward +# compatibility reasons). You should specify the following merge_how to get +# this more complete and modern merging behaviour: +# merge_how: "list()+dict()+str()" +# This would then also be equivalent to the config merging used in curtin +# (https://launchpad.net/curtin). + +# for more details see below in the various examples + apt_sources: - - source: "deb http://ppa.launchpad.net/byobu/ppa/ubuntu karmic main" + byobu-ppa.list: + source: "deb http://ppa.launchpad.net/byobu/ppa/ubuntu karmic main" keyid: F430BBA5 # GPG key ID published on a key server - filename: byobu-ppa.list + # adding a source.list line, importing a gpg key for a given key id and + # storing it in the file /etc/apt/sources.list.d/byobu-ppa.list # PPA shortcut: # * Setup correct apt sources.list line @@ -117,7 +159,9 @@ apt_sources: # # See https://help.launchpad.net/Packaging/PPA for more information # this requires 'add-apt-repository' - - source: "ppa:smoser/ppa" # Quote the string + # due to that the filename key is ignored in this case + ignored1: + source: "ppa:smoser/ppa" # Quote the string # Custom apt repository: # * all that is required is 'source' @@ -128,31 +172,39 @@ apt_sources: # + filename: cloud_config_sources.list # # See sources.list man page for more information about the format - - source: deb http://archive.ubuntu.com/ubuntu karmic-backports main universe multiverse restricted + my-repo.list: + source: deb http://archive.ubuntu.com/ubuntu karmic-backports main universe multiverse restricted # sources can use $MIRROR and $RELEASE and they will be replaced # with the local mirror for this cloud, and the running release # the entry below would be possibly turned into: - # - source: deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu natty multiverse - - source: deb $MIRROR $RELEASE multiverse + # source: deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu natty multiverse + my-repo.list: + source: deb $MIRROR $RELEASE multiverse # this would have the same end effect as 'ppa:byobu/ppa' - - source: "deb http://ppa.launchpad.net/byobu/ppa/ubuntu karmic main" + my-repo.list: + source: "deb http://ppa.launchpad.net/byobu/ppa/ubuntu karmic main" keyid: F430BBA5 # GPG key ID published on a key server filename: byobu-ppa.list # this would only import the key without adding a ppa or other source spec - - keyid: F430BBA5 # GPG key ID published on a key server + # since this doesn't generate a source.list file the filename key is ignored + ignored2: + keyid: F430BBA5 # GPG key ID published on a key server # In general keyid's can also be specified via their long fingerprints - - keyid: B59D 5F15 97A5 04B7 E230 6DCA 0620 BBCF 0368 3F77 + # since this doesn't generate a source.list file the filename key is ignored + ignored3: + keyid: B59D 5F15 97A5 04B7 E230 6DCA 0620 BBCF 0368 3F77 # Custom apt repository: # * The apt signing key can also be specified # by providing a pgp public key block # * Providing the PGP key here is the most robust method for # specifying a key, as it removes dependency on a remote key server - - source: deb http://ppa.launchpad.net/alestic/ppa/ubuntu karmic main + my-repo.list: + source: deb http://ppa.launchpad.net/alestic/ppa/ubuntu karmic main key: | # The value needs to start with -----BEGIN PGP PUBLIC KEY BLOCK----- -----BEGIN PGP PUBLIC KEY BLOCK----- Version: SKS 1.0.10 @@ -170,7 +222,9 @@ apt_sources: # Custom gpg key: # * As the keyid also a key can be specified withut a related source # * all other facts mentioned above still apply - - key: | # The value needs to start with -----BEGIN PGP PUBLIC KEY BLOCK----- + # since this doesn't generate a source.list file the filename key is ignored + ignored4: + key: | # The value needs to start with -----BEGIN PGP PUBLIC KEY BLOCK----- -----BEGIN PGP PUBLIC KEY BLOCK----- Version: SKS 1.0.10 -- cgit v1.2.3 From 1b418ef2db337e9f8bea7462f18f58ee41dea3b2 Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Tue, 24 May 2016 16:27:24 +0200 Subject: fix typo in examples doc --- doc/examples/cloud-config.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt index 50c6d282..60457093 100644 --- a/doc/examples/cloud-config.txt +++ b/doc/examples/cloud-config.txt @@ -72,7 +72,7 @@ apt_pipelining: False # then apt_mirror above will have no effect apt_preserve_sources_list: true -# Provide a custom template for rednering sources.list +# Provide a custom template for rendering sources.list # Default: a default template for Ubuntu/Debain will be used as packaged in # Ubuntu: /etc/cloud/templates/sources.list.ubuntu.tmpl # Debian: /etc/cloud/templates/sources.list.debian.tmpl -- cgit v1.2.3 From 14040a9c8df6e8406acb79fd653873bb05cb4d40 Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Tue, 24 May 2016 16:29:31 +0200 Subject: improve examples of ap_source --- doc/examples/cloud-config.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'doc') diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt index 60457093..df59ff57 100644 --- a/doc/examples/cloud-config.txt +++ b/doc/examples/cloud-config.txt @@ -113,10 +113,11 @@ add_apt_repo_match: '^[\w-]+:\w' # where the filename will be ignored - yet it can still be used as index for # merging. # The value it maps to is a dictionary with the following optional entries: -# 'source': a sources.list entry (some variable replacements apply) -# 'keyid': providing a key to import via shortid or fingerprint -# 'key': providing a raw PGP key -# 'filename': for compatibility with the older format (now the key to this +# source: a sources.list entry (some variable replacements apply) +# keyid: providing a key to import via shortid or fingerprint +# key: providing a raw PGP key +# keyserver: keyserver to fetch keys from, default is keyserver.ubuntu.com +# filename: for compatibility with the older format (now the key to this # dictionary is the filename). If specified this overwrites the # filename given as key. @@ -169,7 +170,6 @@ apt_sources: # * [optional] Import the apt signing key from the keyserver # * Defaults: # + keyserver: keyserver.ubuntu.com - # + filename: cloud_config_sources.list # # See sources.list man page for more information about the format my-repo.list: -- cgit v1.2.3 From 964ec3ae45c27cf55e0c1349138294ff11debab8 Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Mon, 30 May 2016 12:53:29 +0200 Subject: improve wording in the examples --- doc/examples/cloud-config.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt index df59ff57..62b297bc 100644 --- a/doc/examples/cloud-config.txt +++ b/doc/examples/cloud-config.txt @@ -220,7 +220,7 @@ apt_sources: -----END PGP PUBLIC KEY BLOCK----- # Custom gpg key: - # * As the keyid also a key can be specified withut a related source + # * As with keyid, a key may also be specified without a related source. # * all other facts mentioned above still apply # since this doesn't generate a source.list file the filename key is ignored ignored4: -- cgit v1.2.3 From 75907ec96181599dc0282aac989ce02a88c3b39d Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Thu, 2 Jun 2016 16:20:18 +0100 Subject: Integrate MP feedback --- doc/merging.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/merging.rst b/doc/merging.rst index 2967ca9d..afe1a6dd 100644 --- a/doc/merging.rst +++ b/doc/merging.rst @@ -190,5 +190,5 @@ used the previous merging are also, similarly, now extensible (metadata merging, for example). Note, however, that merge algorithms are not used *across* types of -configuration. As was previously the case, merged user-data will still -overwrite conf.d configuration. +configuration. As was the case before merging was implemented, +user-data will overwrite conf.d configuration without merging. -- cgit v1.2.3 From 6c0fc6df1cc332dc3d322961297f8219a3a3048b Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Fri, 3 Jun 2016 22:56:45 -0400 Subject: tests: fix apt tests to run inside ubuntu build environment This just mocks out use of lsb_release as it is not available in a build environment. Additionally mocks out use of getkeybyid. This admittedly makes the test for a long key fingerprint not useful as it was broken only inside getkeybyid. Also fix 'make yaml' for cloud-config.txt --- doc/examples/cloud-config.txt | 6 +++--- .../test_handler_apt_configure_sources_list.py | 5 +++-- .../test_handler/test_handler_apt_source.py | 20 +++++++++++++++----- 3 files changed, 21 insertions(+), 10 deletions(-) (limited to 'doc') diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt index 62b297bc..3cc9c055 100644 --- a/doc/examples/cloud-config.txt +++ b/doc/examples/cloud-config.txt @@ -125,11 +125,11 @@ add_apt_repo_match: '^[\w-]+:\w' # better merging between multiple input files than a list like: # cloud-config1 # sources: - s1: {'key': 'key1', 'source': 'source1'} +# s1: {'key': 'key1', 'source': 'source1'} # cloud-config2 # sources: - s2: {'key': 'key2'} - s1: {filename: 'foo'} +# s2: {'key': 'key2'} +# s1: {filename: 'foo'} # this would be merged to #sources: # s1: diff --git a/tests/unittests/test_handler/test_handler_apt_configure_sources_list.py b/tests/unittests/test_handler/test_handler_apt_configure_sources_list.py index 5d0417a2..5f1dd427 100644 --- a/tests/unittests/test_handler/test_handler_apt_configure_sources_list.py +++ b/tests/unittests/test_handler/test_handler_apt_configure_sources_list.py @@ -103,8 +103,9 @@ class TestAptSourceConfigSourceList(t_help.FilesystemMockingTestCase): with mock.patch.object(templater, 'render_to_file') as mocktmpl: with mock.patch.object(os.path, 'isfile', return_value=True) as mockisfile: - cc_apt_configure.handle("notimportant", cfg, mycloud, - LOG, None) + with mock.patch.object(util, 'rename'): + cc_apt_configure.handle("notimportant", cfg, mycloud, + LOG, None) mockisfile.assert_any_call( ('/etc/cloud/templates/sources.list.%s.tmpl' % distro)) diff --git a/tests/unittests/test_handler/test_handler_apt_source.py b/tests/unittests/test_handler/test_handler_apt_source.py index 4dbe69f0..fa28c916 100644 --- a/tests/unittests/test_handler/test_handler_apt_source.py +++ b/tests/unittests/test_handler/test_handler_apt_source.py @@ -43,6 +43,8 @@ class TestAptSourceConfig(TestCase): """TestAptSourceConfig Main Class to test apt_source configs """ + release = "fantastic" + def setUp(self): super(TestAptSourceConfig, self).setUp() self.tmp = tempfile.mkdtemp() @@ -55,8 +57,12 @@ class TestAptSourceConfig(TestCase): self.fallbackfn = os.path.join(self.tmp, "etc/apt/sources.list.d/", "cloud_config_sources.list") - @staticmethod - def _get_default_params(): + patcher = mock.patch("cloudinit.config.cc_apt_configure.get_release") + get_rel = patcher.start() + get_rel.return_value = self.release + self.addCleanup(patcher.stop) + + def _get_default_params(self): """get_default_params Get the most basic default mrror and release info to be used in tests """ @@ -438,7 +444,7 @@ class TestAptSourceConfig(TestCase): def test_apt_src_keyid_real(self): """test_apt_src_keyid_real Test specification of a keyid without source incl - up to addition of the key (nothing but add_key_raw mocked) + up to addition of the key (add_key_raw, getkeybyid mocked) """ keyid = "03683F77" params = self._get_default_params() @@ -446,7 +452,9 @@ class TestAptSourceConfig(TestCase): 'filename': self.aptlistfile} with mock.patch.object(cc_apt_configure, 'add_key_raw') as mockobj: - cc_apt_configure.add_sources([cfg], params) + with mock.patch.object(cc_apt_configure, 'getkeybyid') as gkbi: + gkbi.return_value = EXPECTEDKEY + cc_apt_configure.add_sources([cfg], params) mockobj.assert_called_with(EXPECTEDKEY) @@ -464,7 +472,9 @@ class TestAptSourceConfig(TestCase): 'filename': self.aptlistfile} with mock.patch.object(cc_apt_configure, 'add_key_raw') as mockobj: - cc_apt_configure.add_sources([cfg], params) + with mock.patch.object(cc_apt_configure, 'getkeybyid') as gkbi: + gkbi.return_value = EXPECTEDKEY + cc_apt_configure.add_sources([cfg], params) mockobj.assert_called_with(EXPECTEDKEY) -- cgit v1.2.3