summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Watkins <oddbloke@ubuntu.com>2021-01-13 10:26:32 -0500
committerGitHub <noreply@github.com>2021-01-13 10:26:32 -0500
commit37abbc43334d522cfbda595fcee2e52592b4d354 (patch)
tree38a8e873b16eb94711845bdf2258c60950346b2f
parent503435d1b2deb648c3cfc436f1e40b8ad86260fc (diff)
downloadvyos-cloud-init-37abbc43334d522cfbda595fcee2e52592b4d354.tar.gz
vyos-cloud-init-37abbc43334d522cfbda595fcee2e52592b4d354.zip
cc_seed_random: update documentation and fix integration test (#771)
The documentation did not mention that the given data may not be the exact string written: the cloud's random data may be added to it. Additionally, the documentation of the command key was incorrect. test_seed_random_data was updated to check that the given data is a prefix of the written data, to match cloud-init's expected (and, now, documented) behaviour. LP: #1911227
-rw-r--r--cloudinit/config/cc_seed_random.py12
-rw-r--r--tests/integration_tests/modules/test_seed_random_data.py2
2 files changed, 9 insertions, 5 deletions
diff --git a/cloudinit/config/cc_seed_random.py b/cloudinit/config/cc_seed_random.py
index 4fb9b44e..911789c7 100644
--- a/cloudinit/config/cc_seed_random.py
+++ b/cloudinit/config/cc_seed_random.py
@@ -24,15 +24,19 @@ Configuration for this module is under the ``random_seed`` config key. The
optionally be specified in encoded form, with the encoding specified in
``encoding``.
+If the cloud provides its own random seed data, it will be appended to ``data``
+before it is written to ``file``.
+
.. note::
when using a multiline value for ``data`` or specifying binary data, be
sure to follow yaml syntax and use the ``|`` and ``!binary`` yaml format
specifiers when appropriate
-Instead of specifying a data string, a command can be run to generate/collect
-the data to be written. The command should be specified as a list of args in
-the ``command`` key. If a command is specified that cannot be run, no error
-will be reported unless ``command_required`` is set to true.
+If the ``command`` key is specified, the given command will be executed. This
+will happen after ``file`` has been populated. That command's environment will
+contain the value of the ``file`` key as ``RANDOM_SEED_FILE``. If a command is
+specified that cannot be run, no error will be reported unless
+``command_required`` is set to true.
For example, to use ``pollinate`` to gather data from a
remote entropy server and write it to ``/dev/urandom``, the following could be
diff --git a/tests/integration_tests/modules/test_seed_random_data.py b/tests/integration_tests/modules/test_seed_random_data.py
index b365fa98..f6a67c19 100644
--- a/tests/integration_tests/modules/test_seed_random_data.py
+++ b/tests/integration_tests/modules/test_seed_random_data.py
@@ -25,4 +25,4 @@ class TestSeedRandomData:
@pytest.mark.user_data(USER_DATA)
def test_seed_random_data(self, client):
seed_output = client.read_from_file("/root/seed")
- assert seed_output.strip() == "MYUb34023nD:LFDK10913jk;dfnk:Df"
+ assert seed_output.startswith("MYUb34023nD:LFDK10913jk;dfnk:Df")