summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Chittum <john.chittum@gmail.com>2022-01-04 12:14:19 -0600
committerGitHub <noreply@github.com>2022-01-04 11:14:19 -0700
commit137c9b0e56bf2a9d4651aeb4ceb210d85a630923 (patch)
tree476294c8599b58f76f82be17494ee63644e1df6d
parentd4bea4a44a0405aaf0d181d4bffff6c07d2fb5ba (diff)
downloadcloud-init-git-137c9b0e56bf2a9d4651aeb4ceb210d85a630923.tar.gz
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
-rw-r--r--cloudinit/config/cc_ubuntu_advantage.py2
-rw-r--r--tests/unittests/config/test_cc_ubuntu_advantage.py24
-rw-r--r--tools/.github-cla-signers1
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