diff options
author | Andrew Bogott <Andrewbogott@gmail.com> | 2021-09-01 09:50:37 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-01 09:50:37 -0500 |
commit | db72c841c2ec0d94d366df7fa623e82e91e2201c (patch) | |
tree | 368a8c65b87e93a02418c99c1b7e3a455373f205 /cloudinit/config | |
parent | 58c2de4c97de6cfa6edbf5319641f2ef71284895 (diff) | |
download | vyos-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 'cloudinit/config')
-rw-r--r-- | cloudinit/config/cc_puppet.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/cloudinit/config/cc_puppet.py b/cloudinit/config/cc_puppet.py index a0779eb0..dc20fc44 100644 --- a/cloudinit/config/cc_puppet.py +++ b/cloudinit/config/cc_puppet.py @@ -59,10 +59,13 @@ Additionally it's possible to create a ``csr_attributes.yaml`` file for CSR attributes and certificate extension requests. See https://puppet.com/docs/puppet/latest/config_file_csr_attributes.html -The puppet service will be automatically enabled after installation. A manual -run can also be triggered by setting ``exec`` to ``true``, and additional -arguments can be passed to ``puppet agent`` via the ``exec_args`` key (by -default the agent will execute with the ``--test`` flag). +By default, the puppet service will be automatically enabled after installation +and set to automatically start on boot. To override this in favor of manual +puppet execution set ``start_service`` to ``false``. + +A single manual run can be triggered by setting ``exec`` to ``true``, and +additional arguments can be passed to ``puppet agent`` via the ``exec_args`` +key (by default the agent will execute with the ``--test`` flag). **Internal name:** ``cc_puppet`` @@ -85,6 +88,7 @@ default the agent will execute with the ``--test`` flag). package_name: 'puppet' exec: <true/false> exec_args: ['--test'] + start_service: <true/false> conf: agent: server: "puppetserver.example.org" @@ -197,6 +201,9 @@ def handle(name, cfg, cloud, log, _args): puppet_cfg, 'install_type', 'packages') cleanup = util.get_cfg_option_bool(puppet_cfg, 'cleanup', True) run = util.get_cfg_option_bool(puppet_cfg, 'exec', default=False) + start_puppetd = util.get_cfg_option_bool(puppet_cfg, + 'start_service', + default=True) aio_install_url = util.get_cfg_option_str( puppet_cfg, 'aio_install_url', default=AIO_INSTALL_URL) @@ -291,7 +298,8 @@ def handle(name, cfg, cloud, log, _args): default_flow_style=False)) # Set it up so it autostarts - _autostart_puppet(log) + if start_puppetd: + _autostart_puppet(log) # Run the agent if needed if run: @@ -312,7 +320,8 @@ def handle(name, cfg, cloud, log, _args): cmd.extend(PUPPET_AGENT_DEFAULT_ARGS) subp.subp(cmd, capture=False) - # Start puppetd - subp.subp(['service', 'puppet', 'start'], capture=False) + if start_puppetd: + # Start puppetd + subp.subp(['service', 'puppet', 'start'], capture=False) # vi: ts=4 expandtab |