← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~default50/cloud-init/puppet_run_agent into lp:cloud-init

 

Sebastian Cruz has proposed merging lp:~default50/cloud-init/puppet_run_agent into lp:cloud-init.

Commit message:
Add run_agent option

Requested reviews:
  cloud init development team (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~default50/cloud-init/puppet_run_agent/+merge/268192

Add a config option to avoid running the puppet daemon (agent) after installing and configuring, also disabling dpgk trigger with policy-rc.d and later removing it.

Useful when only trying to install and configure, as when creating virtual machine images.
-- 
Your team cloud init development team is requested to review the proposed merge of lp:~default50/cloud-init/puppet_run_agent into lp:cloud-init.
=== modified file 'cloudinit/config/cc_puppet.py'
--- cloudinit/config/cc_puppet.py	2015-01-27 19:24:22 +0000
+++ cloudinit/config/cc_puppet.py	2015-08-17 08:16:05 +0000
@@ -60,6 +60,17 @@
     # Start by installing the puppet package if necessary...
     install = util.get_cfg_option_bool(puppet_cfg, 'install', True)
     version = util.get_cfg_option_str(puppet_cfg, 'version', None)
+    run_agent = util.get_cfg_option_bool(puppet_cfg, 'run_agent', True)
+
+    if not run_agent:
+        umask_original = os.umask(0)
+        try:
+            handle = os.fdopen(os.open('/usr/sbin/policy-rc.d', os.O_WRONLY | os.O_CREAT, 0o755), 'w')
+        finally:
+            os.umask(umask_original)
+        handle.write("[ \"$1\" = puppet ] && exit 101 || exit 0")
+        handle.close()
+
     if not install and version:
         log.warn(("Puppet install set false but version supplied,"
                   " doing nothing."))
@@ -115,4 +126,7 @@
     _autostart_puppet(log)
 
     # Start puppetd
-    util.subp(['service', 'puppet', 'start'], capture=False)
+    if run_agent:
+        util.subp(['service', 'puppet', 'start'], capture=False)
+    else:
+        os.remove('/usr/sbin/policy-rc.d')


Follow ups