1
------------------------------------------------------------
3
committer: Scott Moser <smoser@ubuntu.com>
5
timestamp: Fri 2011-03-04 11:06:51 -0500
7
add mcollective to cloud.cfg
8
------------------------------------------------------------
10
committer: Scott Moser <smoser@ubuntu.com>
12
timestamp: Thu 2011-03-03 20:37:30 -0500
14
add 'timezone' cloud-config module to cloud.cfg
15
------------------------------------------------------------
17
fixes bug(s): https://launchpad.net/bugs/728167
18
committer: Scott Moser <smoser@ubuntu.com>
20
timestamp: Thu 2011-03-03 20:04:24 -0500
22
make update of sources not prevent installation attempt (LP: #728167)
23
------------------------------------------------------------
25
committer: Scott Moser <smoser@ubuntu.com>
27
timestamp: Thu 2011-03-03 17:15:12 -0500
29
cc_resizefs.py: log output of failed resizefs or blkid commands
30
------------------------------------------------------------
32
committer: Scott Moser <smoser@ubuntu.com>
34
timestamp: Thu 2011-03-03 17:12:27 -0500
36
in subp, put output and stderr into the raised error
37
------------------------------------------------------------
39
committer: Scott Moser <smoser@ubuntu.com>
41
timestamp: Wed 2011-03-02 17:08:46 -0500
43
fix bug preventing early exit of cloud-init on 'no-net' path
44
------------------------------------------------------------
46
committer: Scott Moser <smoser@ubuntu.com>
48
timestamp: Tue 2011-02-22 12:18:23 -0500
50
merge mcollective fixes from Marc. Changes to indentation and added comments
51
------------------------------------------------------------
54
committer: Scott Moser <smoser@ubuntu.com>
56
timestamp: Sat 2011-02-19 00:42:32 -0500
58
add examples of kernel command line cloud-config
59
------------------------------------------------------------
60
Use --include-merges or -n0 to see merged revisions.
61
=== modified file 'cloud-init.py'
65
# most sense to exit early and silently
68
- fp = open("/var/lib/cloud/instance/obj.pkl","r")
73
--- a/cloudinit/CloudConfig/cc_apt_update_upgrade.py
74
+++ b/cloudinit/CloudConfig/cc_apt_update_upgrade.py
76
log.error("Failed to run debconf-set-selections")
77
log.debug(traceback.format_exc())
81
- cc.update_package_sources()
83
+ cc.update_package_sources()
84
+ except subprocess.CalledProcessError as e:
85
+ log.warn("apt-get update failed")
86
+ log.debug(traceback.format_exc())
90
- cc.apt_get("upgrade")
92
+ cc.apt_get("upgrade")
93
+ except subprocess.CalledProcessError as e:
94
+ log.warn("apt upgrade failed")
95
+ log.debug(traceback.format_exc())
98
pkglist = util.get_cfg_option_list_or_str(cfg,'packages',[])
100
- cc.install_packages(pkglist)
102
+ cc.install_packages(pkglist)
103
+ except subprocess.CalledProcessError as e:
104
+ log.warn("Failed to install packages: %s " % pkglist)
105
+ log.debug(traceback.format_exc())
113
--- a/cloudinit/CloudConfig/cc_mcollective.py
114
+++ b/cloudinit/CloudConfig/cc_mcollective.py
122
import cloudinit.CloudConfig as cc
124
# Our fake header section
125
class FakeSecHead(object):
126
- def __init__(self, fp):
128
- self.sechead = '[nullsection]\n'
129
- def readline(self):
131
- try: return self.sechead
132
- finally: self.sechead = None
133
- else: return self.fp.readline()
134
+ def __init__(self, fp):
136
+ self.sechead = '[nullsection]\n'
137
+ def readline(self):
139
+ try: return self.sechead
140
+ finally: self.sechead = None
141
+ else: return self.fp.readline()
143
def handle(name,cfg,cloud,log,args):
144
# If there isn't a mcollective key in the configuration don't do anything
146
# to overwrite or create new items as needed
147
for o, v in cfg.iteritems():
148
mcollective_config.set(cfg_name,o,v)
149
- # We got all our config as wanted we'll rename
150
- # the previous server.cfg and create our new one
151
- os.rename('/etc/mcollective/server.cfg','/etc/mcollective/server.cfg.old')
152
- with open('/etc/mcollective/server.cfg', 'wb') as configfile:
153
- mcollective_config.write(configfile)
154
+ # We got all our config as wanted we'll rename
155
+ # the previous server.cfg and create our new one
156
+ os.rename('/etc/mcollective/server.cfg','/etc/mcollective/server.cfg.old')
157
+ outputfile = StringIO.StringIO()
158
+ mcollective_config.write(outputfile)
159
+ # Now we got the whole file, write to disk except first line
160
+ final_configfile = open('/etc/mcollective/server.cfg', 'wb')
161
+ # Note below, that we've just used ConfigParser because it generally
162
+ # works. Below, we remove the initial 'nullsection' header
163
+ # and then change 'key = value' to 'key: value'. The global
164
+ # search and replace of '=' with ':' could be problematic though.
165
+ # this most likely needs fixing.
166
+ final_configfile.write(outputfile.getvalue().replace('[nullsection]\n','').replace(' =',':'))
167
+ final_configfile.close()
170
subprocess.check_call(['service', 'mcollective', 'start'])
172
--- a/cloudinit/CloudConfig/cc_resizefs.py
173
+++ b/cloudinit/CloudConfig/cc_resizefs.py
175
cmd = ['blkid', '-c', '/dev/null', '-sTYPE', '-ovalue', '/dev/root']
177
(fstype,err) = util.subp(cmd)
178
- except Exception as e:
179
+ except subprocess.CalledProcessError as e:
180
log.warn("Failed to get filesystem type via %s" % cmd)
181
+ log.warn("output=%s\nerror=%s\n", e.output[0], e.output[1])
184
if fstype.startswith("ext"):
188
(out,err) = util.subp(resize_cmd)
189
- except Exception as e:
190
+ except subprocess.CalledProcessError as e:
191
log.warn("Failed to resize filesystem (%s)" % resize_cmd)
192
+ log.warn("output=%s\nerror=%s\n", e.output[0], e.output[1])
195
--- a/cloudinit/util.py
196
+++ b/cloudinit/util.py
198
sp = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=s_in)
199
out,err = sp.communicate(input)
200
if sp.returncode is not 0:
201
- raise subprocess.CalledProcessError(sp.returncode,args)
202
+ raise subprocess.CalledProcessError(sp.returncode,args, (out,err))
205
def render_to_file(template, outfile, searchList):
206
--- a/config/cloud.cfg
207
+++ b/config/cloud.cfg
215
- disable-ec2-metadata
219
+++ b/doc/examples/cloud-config-mcollective.txt
223
+# This is an example file to automatically setup and run mcollective
224
+# when the instance boots for the first time.
225
+# Make sure that this file is valid yaml before starting instances.
226
+# It should be passed as user-data when starting the instance.
228
+ # Every key present in the conf object will be added to server.cfg:
231
+ # For example the configuration below will have the following key
232
+ # added to server.cfg:
233
+ # plugin.stomp.host: dbhost
235
+ plugin.stomp.host: dbhost