summaryrefslogtreecommitdiff
path: root/tests/unittests/test_handler
diff options
context:
space:
mode:
authorAndrew Bogott <Andrewbogott@gmail.com>2021-09-01 09:50:37 -0500
committerGitHub <noreply@github.com>2021-09-01 09:50:37 -0500
commitdb72c841c2ec0d94d366df7fa623e82e91e2201c (patch)
tree368a8c65b87e93a02418c99c1b7e3a455373f205 /tests/unittests/test_handler
parent58c2de4c97de6cfa6edbf5319641f2ef71284895 (diff)
downloadvyos-cloud-init-db72c841c2ec0d94d366df7fa623e82e91e2201c.tar.gz
vyos-cloud-init-db72c841c2ec0d94d366df7fa623e82e91e2201c.zip
puppet config: add the start_agent option (#1002)
The current code starts the puppet agent and also sets autostart in all cases. This conflicts with a common pattern where puppet itself manages the agent and autostart state. For example, in my deploy puppet disables the puppet agent and replaces it with a cron. This causes various races both within this cloud-init unit and within puppet itself while cloud-init and puppet fight over whether or not to enable the service.
Diffstat (limited to 'tests/unittests/test_handler')
-rw-r--r--tests/unittests/test_handler/test_handler_puppet.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/unittests/test_handler/test_handler_puppet.py b/tests/unittests/test_handler/test_handler_puppet.py
index b7891ab4..19f72a0c 100644
--- a/tests/unittests/test_handler/test_handler_puppet.py
+++ b/tests/unittests/test_handler/test_handler_puppet.py
@@ -278,6 +278,28 @@ class TestPuppetHandle(CiTestCase):
m_subp.call_args_list)
@mock.patch('cloudinit.config.cc_puppet.subp.subp', return_value=("", ""))
+ def test_puppet_starts_puppetd(self, m_subp, m_auto):
+ """Run puppet with default args if 'exec' is set to True."""
+ mycloud = self._get_cloud('ubuntu')
+ cfg = {'puppet': {}}
+ cc_puppet.handle('notimportant', cfg, mycloud, LOG, None)
+ self.assertEqual(1, m_auto.call_count)
+ self.assertIn(
+ [mock.call(['service', 'puppet', 'start'], capture=False)],
+ m_subp.call_args_list)
+
+ @mock.patch('cloudinit.config.cc_puppet.subp.subp', return_value=("", ""))
+ def test_puppet_skips_puppetd(self, m_subp, m_auto):
+ """Run puppet with default args if 'exec' is set to True."""
+ mycloud = self._get_cloud('ubuntu')
+ cfg = {'puppet': {'start_service': False}}
+ cc_puppet.handle('notimportant', cfg, mycloud, LOG, None)
+ self.assertEqual(0, m_auto.call_count)
+ self.assertNotIn(
+ [mock.call(['service', 'puppet', 'start'], capture=False)],
+ m_subp.call_args_list)
+
+ @mock.patch('cloudinit.config.cc_puppet.subp.subp', return_value=("", ""))
def test_puppet_runs_puppet_with_args_list_if_requested(self,
m_subp, m_auto):
"""Run puppet with 'exec_args' list if 'exec' is set to True."""