From 137c9b0e56bf2a9d4651aeb4ceb210d85a630923 Mon Sep 17 00:00:00 2001 From: John Chittum Date: Tue, 4 Jan 2022 12:14:19 -0600 Subject: Update cc_ubuntu_advantage calls to assume-yes (#1158) cloud-init currently makes calls to ubuntu_advantage without assume-yes. some ua enable commands, such as ua enable fips, have prompts. In an automated environment, calling ua enable without --assume-yes will result in errors and not applying the change. This sets --assume-yes by default for all enable commands. This capability was added two years ago in ua commit 576e605ceb5f so should be safe for use in all systems at this time. LP: #1954842 --- cloudinit/config/cc_ubuntu_advantage.py | 2 +- tests/unittests/config/test_cc_ubuntu_advantage.py | 24 ++++++++++++++++------ tools/.github-cla-signers | 1 + 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/cloudinit/config/cc_ubuntu_advantage.py b/cloudinit/config/cc_ubuntu_advantage.py index 413fd3c1..9239f7de 100644 --- a/cloudinit/config/cc_ubuntu_advantage.py +++ b/cloudinit/config/cc_ubuntu_advantage.py @@ -137,7 +137,7 @@ def configure_ua(token=None, enable=None): enable_errors = [] for service in enable: try: - cmd = ["ua", "enable", service] + cmd = ["ua", "enable", "--assume-yes", service] subp.subp(cmd, capture=True) except subp.ProcessExecutionError as e: enable_errors.append((service, e)) diff --git a/tests/unittests/config/test_cc_ubuntu_advantage.py b/tests/unittests/config/test_cc_ubuntu_advantage.py index d7519a1b..c39e421f 100644 --- a/tests/unittests/config/test_cc_ubuntu_advantage.py +++ b/tests/unittests/config/test_cc_ubuntu_advantage.py @@ -63,7 +63,9 @@ class TestConfigureUA(CiTestCase): """all services should be enabled and then any failures raised""" def fake_subp(cmd, capture=None): - fail_cmds = [["ua", "enable", svc] for svc in ["esm", "cc"]] + fail_cmds = [ + ["ua", "enable", "--assume-yes", svc] for svc in ["esm", "cc"] + ] if cmd in fail_cmds and capture: svc = cmd[-1] raise subp.ProcessExecutionError( @@ -78,9 +80,15 @@ class TestConfigureUA(CiTestCase): m_subp.call_args_list, [ mock.call(["ua", "attach", "SomeToken"]), - mock.call(["ua", "enable", "esm"], capture=True), - mock.call(["ua", "enable", "cc"], capture=True), - mock.call(["ua", "enable", "fips"], capture=True), + mock.call( + ["ua", "enable", "--assume-yes", "esm"], capture=True + ), + mock.call( + ["ua", "enable", "--assume-yes", "cc"], capture=True + ), + mock.call( + ["ua", "enable", "--assume-yes", "fips"], capture=True + ), ], ) self.assertIn( @@ -118,7 +126,9 @@ class TestConfigureUA(CiTestCase): m_subp.call_args_list, [ mock.call(["ua", "attach", "SomeToken"]), - mock.call(["ua", "enable", "fips"], capture=True), + mock.call( + ["ua", "enable", "--assume-yes", "fips"], capture=True + ), ], ) self.assertEqual( @@ -135,7 +145,9 @@ class TestConfigureUA(CiTestCase): m_subp.call_args_list, [ mock.call(["ua", "attach", "SomeToken"]), - mock.call(["ua", "enable", "fips"], capture=True), + mock.call( + ["ua", "enable", "--assume-yes", "fips"], capture=True + ), ], ) self.assertEqual( diff --git a/tools/.github-cla-signers b/tools/.github-cla-signers index aed7b4d0..e4b64b0d 100644 --- a/tools/.github-cla-signers +++ b/tools/.github-cla-signers @@ -33,6 +33,7 @@ holmanb impl irishgordo izzyleung +j5awry Jille JohnKepplers johnsonshi -- cgit v1.2.3