summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rwxr-xr-xcloud-init.py13
-rw-r--r--cloudinit/__init__.py5
-rw-r--r--doc/examples/cloud-config.txt12
4 files changed, 23 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 0da5f92b..e0739531 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,7 @@
- make prefix for keys added to /root/.ssh/authorized_keys configurable
and add 'no-port-forwarding,no-agent-forwarding,no-X11-forwarding'
to the default (LP: #798505)
+ - make 'cloud-config ready' command configurable (LP: #785551)
0.6.1:
- fix bug in fixing permission on /var/log/cloud-init.log (LP: #704509)
- improve comment strings in rsyslog file tools/21-cloudinit.conf
diff --git a/cloud-init.py b/cloud-init.py
index ee08c191..09c537f1 100755
--- a/cloud-init.py
+++ b/cloud-init.py
@@ -146,9 +146,6 @@ def main():
warn("consuming user data failed!\n")
raise
- # finish, send the cloud-config event
- cloud.initctl_emit()
-
cfg_path = cloudinit.get_ipath_cur("cloud_config")
cc = CC.CloudConfig(cfg_path, cloud)
@@ -163,6 +160,16 @@ def main():
except Exception as e:
warn("Failed to get and set output config: %s\n" % e)
+ # send the cloud-config ready event
+ cc_path = cloudinit.get_ipath_cur('cloud_config')
+ cc_ready = cc.cfg.get("cc_ready_cmd",
+ ['initctl', 'emit', 'cloud-config',
+ '%s=%s' % (cloudinit.cfg_env_name, cc_path) ])
+ if cc_ready:
+ if isinstance(cc_ready,str):
+ cc_ready = [ 'sh', '-c', cc_ready]
+ subprocess.Popen(cc_ready).communicate()
+
module_list = CC.read_cc_modules(cc.cfg,"cloud_init_modules")
failures = []
diff --git a/cloudinit/__init__.py b/cloudinit/__init__.py
index ab0a834a..82dfaa8f 100644
--- a/cloudinit/__init__.py
+++ b/cloudinit/__init__.py
@@ -243,11 +243,6 @@ class CloudInit:
util.write_file(self.get_ipath('userdata'),
self.datasource.get_userdata(), 0600)
- def initctl_emit(self):
- cc_path = get_ipath_cur('cloud_config')
- subprocess.Popen(['initctl', 'emit', 'cloud-config',
- '%s=%s' % (cfg_env_name,cc_path)]).communicate()
-
def sem_getpath(self,name,freq):
if freq == 'once-per-instance':
return("%s/%s" % (self.get_ipath("sem"),name))
diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt
index b72cab48..eaedabeb 100644
--- a/doc/examples/cloud-config.txt
+++ b/doc/examples/cloud-config.txt
@@ -422,3 +422,15 @@ manual_cache_clean: False
# on a per-always basis (to account for ebs stop/start), then set
# manage_etc_hosts to True. The default is 'False'
manage_etc_hosts: False
+
+# When cloud-init is finished running including having run
+# cloud_init_modules, then it will run this command. The default
+# is to emit an upstart signal as shown below. If the value is a
+# list, it will be passed to Popen. If it is a string, it will be
+# invoked through 'sh -c'.
+#
+# default value:
+# cc_ready_cmd: [ initctl, emit, cloud-config, CLOUD_CFG=/var/lib/instance//cloud-config.txt ]
+# example:
+# cc_ready_cmd: [ sh, -c, 'echo HI MOM > /tmp/file' ]
+