cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #00171
[Merge] lp:~craigtracey/cloud-init/puppet-service-restart into lp:cloud-init
Craig Tracey has proposed merging lp:~craigtracey/cloud-init/puppet-service-restart into lp:cloud-init.
Requested reviews:
cloud init development team (cloud-init-dev)
Related bugs:
Bug #1090218 in cloud-init: "Check puppet run state before starting/restarting"
https://bugs.launchpad.net/cloud-init/+bug/1090218
For more details, see:
https://code.launchpad.net/~craigtracey/cloud-init/puppet-service-restart/+merge/139832
Conditionally start or restart depending upon puppet's run state
Check the current run state of puppet before calling start and/or
restart. If puppet is not started, start it and if the configuration
has changed and puppet is already running, attempt a restart.
--
https://code.launchpad.net/~craigtracey/cloud-init/puppet-service-restart/+merge/139832
Your team cloud init development team is requested to review the proposed merge of lp:~craigtracey/cloud-init/puppet-service-restart into lp:cloud-init.
=== modified file 'cloudinit/config/cc_puppet.py'
--- cloudinit/config/cc_puppet.py 2012-10-28 02:25:48 +0000
+++ cloudinit/config/cc_puppet.py 2012-12-14 04:00:25 +0000
@@ -61,6 +61,7 @@
cloud.distro.install_packages(["puppet"])
# ... and then update the puppet configuration
+ conf_modified = False
if 'conf' in puppet_cfg:
# Add all sections from the conf object to puppet.conf
contents = util.load_file(PUPPET_CONF_PATH)
@@ -102,9 +103,23 @@
# the previous puppet.conf and create our new one
util.rename(PUPPET_CONF_PATH, "%s.old" % (PUPPET_CONF_PATH))
util.write_file(PUPPET_CONF_PATH, puppet_config.stringify())
+ conf_modified = True
# Set it up so it autostarts
_autostart_puppet(log)
+ # Check to see if puppet is already started
+ service_started = True
+ try:
+ util.subp(['service', 'puppet', 'status'], capture=False)
+ except ProcessExecutionError as err:
+ if not err.exit_code == 0:
+ service_started = False
+ else:
+ raise err
+
# Start puppetd
- util.subp(['service', 'puppet', 'start'], capture=False)
+ if not service_started:
+ util.subp(['service', 'puppet', 'start'], capture=False)
+ elif conf_modified and service_started:
+ util.subp(['service', 'puppet', 'restart'], capture=False)