Merge ~smoser/cloud-init:feature/tpl-cloud-cfg into cloud-init:master
- Git
- lp:~smoser/cloud-init
- feature/tpl-cloud-cfg
- Merge into master
Status: | Merged |
---|---|
Merged at revision: | 41d46bfb85929c79dabcec3cf21c8d71401fd2b8 |
Proposed branch: | ~smoser/cloud-init:feature/tpl-cloud-cfg |
Merge into: | cloud-init:master |
Diff against target: |
753 lines (+379/-157) 7 files modified
MANIFEST.in (+10/-1) Makefile (+3/-0) cloudinit/util.py (+28/-1) config/cloud.cfg.tmpl (+194/-0) dev/null (+0/-88) setup.py (+101/-67) tools/render-cloudcfg (+43/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Server Team CI bot | continuous-integration | Approve | |
Ryan Harper | Approve | ||
Review via email: mp+325192@code.launchpad.net |
Commit message
Make config/cloud.cfg a template and setup.py fixes
Currently there is no real way to have a single 'cloud.cfg' file that
works everywhere. Certain modules are routinely being not applied by
various downstream distributors. Other differences include default user.
This changes cloud.cfg to be a template that we can render per-distro
versions as needed. This makes it easier to identify common themes and
differences and resolve those.
Additionally, we add some fixes to setup.py.
- sdist now collects all the files.
- install can now be done into a virtual env, and all the data files
to with it.
We have also included some config changes that were found in the
redhat distro spec.
* include some config changes from the redhat distro spec.
Description of the change
Server Team CI bot (server-team-bot) wrote : | # |
Server Team CI bot (server-team-bot) wrote : | # |
FAILED: Continuous integration, rev:d1d93cc523c
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Server Team CI bot (server-team-bot) wrote : | # |
FAILED: Continuous integration, rev:fc986d5fbfd
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Server Team CI bot (server-team-bot) wrote : | # |
FAILED: Continuous integration, rev:9ed06a64cd7
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Server Team CI bot (server-team-bot) wrote : | # |
FAILED: Continuous integration, rev:139aa7bdcce
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Server Team CI bot (server-team-bot) wrote : | # |
FAILED: Continuous integration, rev:dc47c6d0a5d
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Server Team CI bot (server-team-bot) wrote : | # |
FAILED: Continuous integration, rev:cce63478399
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Server Team CI bot (server-team-bot) wrote : | # |
FAILED: Continuous integration, rev:9e6ff73cdb6
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Server Team CI bot (server-team-bot) wrote : | # |
FAILED: Continuous integration, rev:ebfb84991b2
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Server Team CI bot (server-team-bot) wrote : | # |
FAILED: Continuous integration, rev:cfe67100c17
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Server Team CI bot (server-team-bot) wrote : | # |
FAILED: Continuous integration, rev:c082cb70229
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Server Team CI bot (server-team-bot) wrote : | # |
FAILED: Continuous integration, rev:fa22e178294
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Server Team CI bot (server-team-bot) wrote : | # |
FAILED: Continuous integration, rev:15f8e174fb9
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Ryan Harper (raharper) wrote : | # |
After many retries, both cent6 and cent7 packages install and run.
https:/
Server Team CI bot (server-team-bot) wrote : | # |
FAILED: Continuous integration, rev:9f28ea05e8b
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Ryan Harper (raharper) : | # |
Server Team CI bot (server-team-bot) wrote : | # |
PASSED: Continuous integration, rev:cddb12952b2
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Server Team CI bot (server-team-bot) wrote : | # |
PASSED: Continuous integration, rev:2f3a5989c7b
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Server Team CI bot (server-team-bot) wrote : | # |
PASSED: Continuous integration, rev:bda19c91836
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Server Team CI bot (server-team-bot) wrote : | # |
PASSED: Continuous integration, rev:f02784484a8
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Ryan Harper (raharper) : | # |
Ryan Harper (raharper) wrote : | # |
Couple of nits, otherwise looks fine.
Scott Moser (smoser) wrote : | # |
addressed all.
Server Team CI bot (server-team-bot) wrote : | # |
PASSED: Continuous integration, rev:d74c0b261ec
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Ryan Harper (raharper) wrote : | # |
missed one (see inline), fix and I approve
Server Team CI bot (server-team-bot) wrote : | # |
PASSED: Continuous integration, rev:ec511f15dfc
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | diff --git a/MANIFEST.in b/MANIFEST.in |
2 | index 9426464..1a4d771 100644 |
3 | --- a/MANIFEST.in |
4 | +++ b/MANIFEST.in |
5 | @@ -1,6 +1,15 @@ |
6 | -include *.py MANIFEST.in ChangeLog |
7 | +include *.py MANIFEST.in LICENSE* ChangeLog |
8 | global-include *.txt *.rst *.ini *.in *.conf *.cfg *.sh |
9 | +graft config |
10 | +graft doc |
11 | +graft packages |
12 | +graft systemd |
13 | +graft sysvinit |
14 | +graft templates |
15 | +graft tests |
16 | graft tools |
17 | +graft udev |
18 | +graft upstart |
19 | prune build |
20 | prune dist |
21 | prune .tox |
22 | diff --git a/Makefile b/Makefile |
23 | index 66d1dca..a3bfaf7 100644 |
24 | --- a/Makefile |
25 | +++ b/Makefile |
26 | @@ -69,6 +69,9 @@ check_version: |
27 | "not equal to code version '$(CODE_VERSION)'"; exit 2; \ |
28 | else true; fi |
29 | |
30 | +config/cloud.cfg: |
31 | + $(PYVER) ./tools/render-cloudcfg config/cloud.cfg.tmpl config/cloud.cfg |
32 | + |
33 | clean_pyc: |
34 | @find . -type f -name "*.pyc" -delete |
35 | |
36 | diff --git a/cloudinit/util.py b/cloudinit/util.py |
37 | index 135e460..b8c3e4e 100644 |
38 | --- a/cloudinit/util.py |
39 | +++ b/cloudinit/util.py |
40 | @@ -592,13 +592,40 @@ def get_cfg_option_int(yobj, key, default=0): |
41 | |
42 | |
43 | def system_info(): |
44 | - return { |
45 | + info = { |
46 | 'platform': platform.platform(), |
47 | 'release': platform.release(), |
48 | 'python': platform.python_version(), |
49 | 'uname': platform.uname(), |
50 | 'dist': platform.linux_distribution(), # pylint: disable=W1505 |
51 | } |
52 | + plat = info['platform'].lower() |
53 | + # Try to get more info about what it actually is, in a format |
54 | + # that we can easily use across linux and variants... |
55 | + if plat.startswith('darwin'): |
56 | + info['variant'] = 'darwin' |
57 | + elif plat.endswith("bsd"): |
58 | + info['variant'] = 'bsd' |
59 | + elif plat.startswith('win'): |
60 | + info['variant'] = 'windows' |
61 | + elif 'linux' in plat: |
62 | + # Try to get a single string out of these... |
63 | + linux_dist, _version, _id = info['dist'] |
64 | + linux_dist = linux_dist.lower() |
65 | + if linux_dist in ('ubuntu', 'linuxmint', 'mint'): |
66 | + info['variant'] = 'ubuntu' |
67 | + else: |
68 | + for prefix, variant in [('redhat', 'rhel'), |
69 | + ('centos', 'centos'), |
70 | + ('fedora', 'fedora'), |
71 | + ('debian', 'debian')]: |
72 | + if linux_dist.startswith(prefix): |
73 | + info['variant'] = variant |
74 | + if 'variant' not in info: |
75 | + info['variant'] = 'linux' |
76 | + if 'variant' not in info: |
77 | + info['variant'] = 'unknown' |
78 | + return info |
79 | |
80 | |
81 | def get_cfg_option_list(yobj, key, default=None): |
82 | diff --git a/config/cloud.cfg b/config/cloud.cfg |
83 | deleted file mode 100644 |
84 | index 1b93e7f..0000000 |
85 | --- a/config/cloud.cfg |
86 | +++ /dev/null |
87 | @@ -1,117 +0,0 @@ |
88 | -# The top level settings are used as module |
89 | -# and system configuration. |
90 | - |
91 | -# A set of users which may be applied and/or used by various modules |
92 | -# when a 'default' entry is found it will reference the 'default_user' |
93 | -# from the distro configuration specified below |
94 | -users: |
95 | - - default |
96 | - |
97 | -# If this is set, 'root' will not be able to ssh in and they |
98 | -# will get a message to login instead as the above $user (ubuntu) |
99 | -disable_root: true |
100 | - |
101 | -# This will cause the set+update hostname module to not operate (if true) |
102 | -preserve_hostname: false |
103 | - |
104 | -# Example datasource config |
105 | -# datasource: |
106 | -# Ec2: |
107 | -# metadata_urls: [ 'blah.com' ] |
108 | -# timeout: 5 # (defaults to 50 seconds) |
109 | -# max_wait: 10 # (defaults to 120 seconds) |
110 | - |
111 | -# The modules that run in the 'init' stage |
112 | -cloud_init_modules: |
113 | - - migrator |
114 | - - ubuntu-init-switch |
115 | - - seed_random |
116 | - - bootcmd |
117 | - - write-files |
118 | - - growpart |
119 | - - resizefs |
120 | - - disk_setup |
121 | - - mounts |
122 | - - set_hostname |
123 | - - update_hostname |
124 | - - update_etc_hosts |
125 | - - ca-certs |
126 | - - rsyslog |
127 | - - users-groups |
128 | - - ssh |
129 | - |
130 | -# The modules that run in the 'config' stage |
131 | -cloud_config_modules: |
132 | -# Emit the cloud config ready event |
133 | -# this can be used by upstart jobs for 'start on cloud-config'. |
134 | - - emit_upstart |
135 | - - snap_config |
136 | - - ssh-import-id |
137 | - - locale |
138 | - - set-passwords |
139 | - - grub-dpkg |
140 | - - apt-pipelining |
141 | - - apt-configure |
142 | - - ntp |
143 | - - timezone |
144 | - - disable-ec2-metadata |
145 | - - runcmd |
146 | - - byobu |
147 | - |
148 | -# The modules that run in the 'final' stage |
149 | -cloud_final_modules: |
150 | - - snappy |
151 | - - package-update-upgrade-install |
152 | - - fan |
153 | - - landscape |
154 | - - lxd |
155 | - - puppet |
156 | - - chef |
157 | - - salt-minion |
158 | - - mcollective |
159 | - - rightscale_userdata |
160 | - - scripts-vendor |
161 | - - scripts-per-once |
162 | - - scripts-per-boot |
163 | - - scripts-per-instance |
164 | - - scripts-user |
165 | - - ssh-authkey-fingerprints |
166 | - - keys-to-console |
167 | - - phone-home |
168 | - - final-message |
169 | - - power-state-change |
170 | - |
171 | -# System and/or distro specific settings |
172 | -# (not accessible to handlers/transforms) |
173 | -system_info: |
174 | - # This will affect which distro class gets used |
175 | - distro: ubuntu |
176 | - # Default user name + that default users groups (if added/used) |
177 | - default_user: |
178 | - name: ubuntu |
179 | - lock_passwd: True |
180 | - gecos: Ubuntu |
181 | - groups: [adm, audio, cdrom, dialout, dip, floppy, lxd, netdev, plugdev, sudo, video] |
182 | - sudo: ["ALL=(ALL) NOPASSWD:ALL"] |
183 | - shell: /bin/bash |
184 | - # Other config here will be given to the distro class and/or path classes |
185 | - paths: |
186 | - cloud_dir: /var/lib/cloud/ |
187 | - templates_dir: /etc/cloud/templates/ |
188 | - upstart_dir: /etc/init/ |
189 | - package_mirrors: |
190 | - - arches: [i386, amd64] |
191 | - failsafe: |
192 | - primary: http://archive.ubuntu.com/ubuntu |
193 | - security: http://security.ubuntu.com/ubuntu |
194 | - search: |
195 | - primary: |
196 | - - http://%(ec2_region)s.ec2.archive.ubuntu.com/ubuntu/ |
197 | - - http://%(availability_zone)s.clouds.archive.ubuntu.com/ubuntu/ |
198 | - - http://%(region)s.clouds.archive.ubuntu.com/ubuntu/ |
199 | - security: [] |
200 | - - arches: [armhf, armel, default] |
201 | - failsafe: |
202 | - primary: http://ports.ubuntu.com/ubuntu-ports |
203 | - security: http://ports.ubuntu.com/ubuntu-ports |
204 | - ssh_svcname: ssh |
205 | diff --git a/config/cloud.cfg-freebsd b/config/cloud.cfg-freebsd |
206 | deleted file mode 100644 |
207 | index d666c39..0000000 |
208 | --- a/config/cloud.cfg-freebsd |
209 | +++ /dev/null |
210 | @@ -1,88 +0,0 @@ |
211 | -# The top level settings are used as module |
212 | -# and system configuration. |
213 | - |
214 | -syslog_fix_perms: root:wheel |
215 | - |
216 | -# This should not be required, but leave it in place until the real cause of |
217 | -# not beeing able to find -any- datasources is resolved. |
218 | -datasource_list: ['ConfigDrive', 'Azure', 'OpenStack', 'Ec2'] |
219 | - |
220 | -# A set of users which may be applied and/or used by various modules |
221 | -# when a 'default' entry is found it will reference the 'default_user' |
222 | -# from the distro configuration specified below |
223 | -users: |
224 | - - default |
225 | - |
226 | -# If this is set, 'root' will not be able to ssh in and they |
227 | -# will get a message to login instead as the above $user (ubuntu) |
228 | -disable_root: false |
229 | - |
230 | -# This will cause the set+update hostname module to not operate (if true) |
231 | -preserve_hostname: false |
232 | - |
233 | -# Example datasource config |
234 | -# datasource: |
235 | -# Ec2: |
236 | -# metadata_urls: [ 'blah.com' ] |
237 | -# timeout: 5 # (defaults to 50 seconds) |
238 | -# max_wait: 10 # (defaults to 120 seconds) |
239 | - |
240 | -# The modules that run in the 'init' stage |
241 | -cloud_init_modules: |
242 | -# - migrator |
243 | - - seed_random |
244 | - - bootcmd |
245 | -# - write-files |
246 | - - growpart |
247 | - - resizefs |
248 | - - set_hostname |
249 | - - update_hostname |
250 | -# - update_etc_hosts |
251 | -# - ca-certs |
252 | -# - rsyslog |
253 | - - users-groups |
254 | - - ssh |
255 | - |
256 | -# The modules that run in the 'config' stage |
257 | -cloud_config_modules: |
258 | -# - disk_setup |
259 | -# - mounts |
260 | - - ssh-import-id |
261 | - - locale |
262 | - - set-passwords |
263 | - - package-update-upgrade-install |
264 | -# - landscape |
265 | - - timezone |
266 | -# - puppet |
267 | -# - chef |
268 | -# - salt-minion |
269 | -# - mcollective |
270 | - - disable-ec2-metadata |
271 | - - runcmd |
272 | -# - byobu |
273 | - |
274 | -# The modules that run in the 'final' stage |
275 | -cloud_final_modules: |
276 | - - rightscale_userdata |
277 | - - scripts-vendor |
278 | - - scripts-per-once |
279 | - - scripts-per-boot |
280 | - - scripts-per-instance |
281 | - - scripts-user |
282 | - - ssh-authkey-fingerprints |
283 | - - keys-to-console |
284 | - - phone-home |
285 | - - final-message |
286 | - - power-state-change |
287 | - |
288 | -# System and/or distro specific settings |
289 | -# (not accessible to handlers/transforms) |
290 | -system_info: |
291 | - distro: freebsd |
292 | - default_user: |
293 | - name: freebsd |
294 | - lock_passwd: True |
295 | - gecos: FreeBSD |
296 | - groups: [wheel] |
297 | - sudo: ["ALL=(ALL) NOPASSWD:ALL"] |
298 | - shell: /bin/tcsh |
299 | diff --git a/config/cloud.cfg.tmpl b/config/cloud.cfg.tmpl |
300 | new file mode 100644 |
301 | index 0000000..5af2a88 |
302 | --- /dev/null |
303 | +++ b/config/cloud.cfg.tmpl |
304 | @@ -0,0 +1,194 @@ |
305 | +## template:jinja |
306 | +# The top level settings are used as module |
307 | +# and system configuration. |
308 | + |
309 | +{% if variant in ["bsd"] %} |
310 | +syslog_fix_perms: root:wheel |
311 | +{% endif %} |
312 | +# A set of users which may be applied and/or used by various modules |
313 | +# when a 'default' entry is found it will reference the 'default_user' |
314 | +# from the distro configuration specified below |
315 | +users: |
316 | + - default |
317 | + |
318 | +# If this is set, 'root' will not be able to ssh in and they |
319 | +# will get a message to login instead as the default $user |
320 | +{% if variant in ["bsd"] %} |
321 | +disable_root: false |
322 | +{% else %} |
323 | +disable_root: true |
324 | +{% endif %} |
325 | + |
326 | +{% if variant in ["centos", "fedora", "rhel"] %} |
327 | +mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2'] |
328 | +resize_rootfs_tmp: /dev |
329 | +ssh_deletekeys: 0 |
330 | +ssh_genkeytypes: ~ |
331 | +ssh_pwauth: 0 |
332 | + |
333 | +{% endif %} |
334 | +# This will cause the set+update hostname module to not operate (if true) |
335 | +preserve_hostname: false |
336 | + |
337 | +{% if variant in ["bsd"] %} |
338 | +# This should not be required, but leave it in place until the real cause of |
339 | +# not beeing able to find -any- datasources is resolved. |
340 | +datasource_list: ['ConfigDrive', 'Azure', 'OpenStack', 'Ec2'] |
341 | +{% endif %} |
342 | +# Example datasource config |
343 | +# datasource: |
344 | +# Ec2: |
345 | +# metadata_urls: [ 'blah.com' ] |
346 | +# timeout: 5 # (defaults to 50 seconds) |
347 | +# max_wait: 10 # (defaults to 120 seconds) |
348 | + |
349 | +# The modules that run in the 'init' stage |
350 | +cloud_init_modules: |
351 | + - migrator |
352 | +{% if variant in ["ubuntu", "unknown", "debian"] %} |
353 | + - ubuntu-init-switch |
354 | +{% endif %} |
355 | + - seed_random |
356 | + - bootcmd |
357 | + - write-files |
358 | + - growpart |
359 | + - resizefs |
360 | +{% if variant not in ["bsd"] %} |
361 | + - disk_setup |
362 | + - mounts |
363 | +{% endif %} |
364 | + - set_hostname |
365 | + - update_hostname |
366 | +{% if variant not in ["bsd"] %} |
367 | + - update_etc_hosts |
368 | + - ca-certs |
369 | + - rsyslog |
370 | +{% endif %} |
371 | + - users-groups |
372 | + - ssh |
373 | + |
374 | +# The modules that run in the 'config' stage |
375 | +cloud_config_modules: |
376 | +{% if variant in ["ubuntu", "unknown", "debian"] %} |
377 | +# Emit the cloud config ready event |
378 | +# this can be used by upstart jobs for 'start on cloud-config'. |
379 | + - emit_upstart |
380 | + - snap_config |
381 | +{% endif %} |
382 | + - ssh-import-id |
383 | + - locale |
384 | + - set-passwords |
385 | +{% if variant in ["rhel", "fedora"] %} |
386 | + - spacewalk |
387 | + - yum-add-repo |
388 | +{% endif %} |
389 | +{% if variant in ["ubuntu", "unknown", "debian"] %} |
390 | + - grub-dpkg |
391 | + - apt-pipelining |
392 | + - apt-configure |
393 | +{% endif %} |
394 | +{% if variant not in ["bsd"] %} |
395 | + - ntp |
396 | +{% endif %} |
397 | + - timezone |
398 | + - disable-ec2-metadata |
399 | + - runcmd |
400 | +{% if variant in ["ubuntu", "unknown", "debian"] %} |
401 | + - byobu |
402 | +{% endif %} |
403 | + |
404 | +# The modules that run in the 'final' stage |
405 | +cloud_final_modules: |
406 | +{% if variant in ["ubuntu", "unknown", "debian"] %} |
407 | + - snappy |
408 | +{% endif %} |
409 | + - package-update-upgrade-install |
410 | +{% if variant in ["ubuntu", "unknown", "debian"] %} |
411 | + - fan |
412 | + - landscape |
413 | + - lxd |
414 | +{% endif %} |
415 | +{% if variant not in ["bsd"] %} |
416 | + - puppet |
417 | + - chef |
418 | + - salt-minion |
419 | + - mcollective |
420 | +{% endif %} |
421 | + - rightscale_userdata |
422 | + - scripts-vendor |
423 | + - scripts-per-once |
424 | + - scripts-per-boot |
425 | + - scripts-per-instance |
426 | + - scripts-user |
427 | + - ssh-authkey-fingerprints |
428 | + - keys-to-console |
429 | + - phone-home |
430 | + - final-message |
431 | + - power-state-change |
432 | + |
433 | +# System and/or distro specific settings |
434 | +# (not accessible to handlers/transforms) |
435 | +system_info: |
436 | + # This will affect which distro class gets used |
437 | +{% if variant in ["centos", "debian", "fedora", "rhel", "ubuntu"] %} |
438 | + distro: {{ variant }} |
439 | +{% elif variant in ["bsd"] %} |
440 | + distro: freebsd |
441 | +{% else %} |
442 | + # Unknown/fallback distro. |
443 | + distro: ubuntu |
444 | +{% endif %} |
445 | +{% if variant in ["ubuntu", "unknown", "debian"] %} |
446 | + # Default user name + that default users groups (if added/used) |
447 | + default_user: |
448 | + name: ubuntu |
449 | + lock_passwd: True |
450 | + gecos: Ubuntu |
451 | + groups: [adm, audio, cdrom, dialout, dip, floppy, lxd, netdev, plugdev, sudo, video] |
452 | + sudo: ["ALL=(ALL) NOPASSWD:ALL"] |
453 | + shell: /bin/bash |
454 | + # Other config here will be given to the distro class and/or path classes |
455 | + paths: |
456 | + cloud_dir: /var/lib/cloud/ |
457 | + templates_dir: /etc/cloud/templates/ |
458 | + upstart_dir: /etc/init/ |
459 | + package_mirrors: |
460 | + - arches: [i386, amd64] |
461 | + failsafe: |
462 | + primary: http://archive.ubuntu.com/ubuntu |
463 | + security: http://security.ubuntu.com/ubuntu |
464 | + search: |
465 | + primary: |
466 | + - http://%(ec2_region)s.ec2.archive.ubuntu.com/ubuntu/ |
467 | + - http://%(availability_zone)s.clouds.archive.ubuntu.com/ubuntu/ |
468 | + - http://%(region)s.clouds.archive.ubuntu.com/ubuntu/ |
469 | + security: [] |
470 | + - arches: [armhf, armel, default] |
471 | + failsafe: |
472 | + primary: http://ports.ubuntu.com/ubuntu-ports |
473 | + security: http://ports.ubuntu.com/ubuntu-ports |
474 | + ssh_svcname: ssh |
475 | +{% elif variant in ["centos", "rhel", "fedora"] %} |
476 | + # Default user name + that default users groups (if added/used) |
477 | + default_user: |
478 | + name: {{ variant }} |
479 | + lock_passwd: True |
480 | + gecos: {{ variant }} Cloud User |
481 | + groups: [wheel, adm, systemd-journal] |
482 | + sudo: ["ALL=(ALL) NOPASSWD:ALL"] |
483 | + shell: /bin/bash |
484 | + # Other config here will be given to the distro class and/or path classes |
485 | + paths: |
486 | + cloud_dir: /var/lib/cloud/ |
487 | + templates_dir: /etc/cloud/templates/ |
488 | + ssh_svcname: sshd |
489 | +{% elif variant in ["bsd"] %} |
490 | + # Default user name + that default users groups (if added/used) |
491 | + default_user: |
492 | + name: freebsd |
493 | + lock_passwd: True |
494 | + gecos: FreeBSD |
495 | + groups: [wheel] |
496 | + sudo: ["ALL=(ALL) NOPASSWD:ALL"] |
497 | + shell: /bin/tcsh |
498 | +{% endif %} |
499 | diff --git a/setup.py b/setup.py |
500 | index 4616599..d522328 100755 |
501 | --- a/setup.py |
502 | +++ b/setup.py |
503 | @@ -10,8 +10,11 @@ |
504 | |
505 | from glob import glob |
506 | |
507 | +import atexit |
508 | import os |
509 | +import shutil |
510 | import sys |
511 | +import tempfile |
512 | |
513 | import setuptools |
514 | from setuptools.command.install import install |
515 | @@ -53,47 +56,15 @@ def pkg_config_read(library, var): |
516 | cmd = ['pkg-config', '--variable=%s' % var, library] |
517 | try: |
518 | (path, err) = tiny_p(cmd) |
519 | + path = path.strip() |
520 | except Exception: |
521 | - return fallbacks[library][var] |
522 | - return str(path).strip() |
523 | + path = fallbacks[library][var] |
524 | + if path.startswith("/"): |
525 | + path = path[1:] |
526 | |
527 | + return path |
528 | |
529 | -INITSYS_FILES = { |
530 | - 'sysvinit': [f for f in glob('sysvinit/redhat/*') if is_f(f)], |
531 | - 'sysvinit_freebsd': [f for f in glob('sysvinit/freebsd/*') if is_f(f)], |
532 | - 'sysvinit_deb': [f for f in glob('sysvinit/debian/*') if is_f(f)], |
533 | - 'sysvinit_openrc': [f for f in glob('sysvinit/gentoo/*') if is_f(f)], |
534 | - 'systemd': [f for f in (glob('systemd/*.service') + |
535 | - glob('systemd/*.target')) if is_f(f)], |
536 | - 'systemd.generators': [f for f in glob('systemd/*-generator') if is_f(f)], |
537 | - 'upstart': [f for f in glob('upstart/*') if is_f(f)], |
538 | -} |
539 | -INITSYS_ROOTS = { |
540 | - 'sysvinit': '/etc/rc.d/init.d', |
541 | - 'sysvinit_freebsd': '/usr/local/etc/rc.d', |
542 | - 'sysvinit_deb': '/etc/init.d', |
543 | - 'sysvinit_openrc': '/etc/init.d', |
544 | - 'systemd': pkg_config_read('systemd', 'systemdsystemunitdir'), |
545 | - 'systemd.generators': pkg_config_read('systemd', |
546 | - 'systemdsystemgeneratordir'), |
547 | - 'upstart': '/etc/init/', |
548 | -} |
549 | -INITSYS_TYPES = sorted([f.partition(".")[0] for f in INITSYS_ROOTS.keys()]) |
550 | - |
551 | -# Install everything in the right location and take care of Linux (default) and |
552 | -# FreeBSD systems. |
553 | -USR = "/usr" |
554 | -ETC = "/etc" |
555 | -USR_LIB_EXEC = "/usr/lib" |
556 | -LIB = "/lib" |
557 | -if os.uname()[0] == 'FreeBSD': |
558 | - USR = "/usr/local" |
559 | - USR_LIB_EXEC = "/usr/local/lib" |
560 | -elif os.path.isfile('/etc/redhat-release'): |
561 | - USR_LIB_EXEC = "/usr/libexec" |
562 | |
563 | - |
564 | -# Avoid having datafiles installed in a virtualenv... |
565 | def in_virtualenv(): |
566 | try: |
567 | if sys.real_prefix == sys.prefix: |
568 | @@ -116,6 +87,66 @@ def read_requires(): |
569 | return str(deps).splitlines() |
570 | |
571 | |
572 | +def render_cloud_cfg(): |
573 | + """render cloud.cfg into a tmpdir under same dir as setup.py |
574 | + |
575 | + This is rendered to a temporary directory under the top level |
576 | + directory with the name 'cloud.cfg'. The reason for not just rendering |
577 | + to config/cloud.cfg is for a.) don't want to write over contents |
578 | + in that file if user had something there. b.) debuild will complain |
579 | + that files are different outside of the debian directory.""" |
580 | + |
581 | + # older versions of tox use bdist (xenial), and then install from there. |
582 | + # newer versions just use install. |
583 | + if not (sys.argv[1] == 'install' or sys.argv[1].startswith('bdist*')): |
584 | + return 'config/cloud.cfg.tmpl' |
585 | + topdir = os.path.dirname(sys.argv[0]) |
586 | + tmpd = tempfile.mkdtemp(dir=topdir) |
587 | + atexit.register(shutil.rmtree, tmpd) |
588 | + fpath = os.path.join(tmpd, 'cloud.cfg') |
589 | + tiny_p([sys.executable, './tools/render-cloudcfg', |
590 | + 'config/cloud.cfg.tmpl', fpath]) |
591 | + # relpath is relative to setup.py |
592 | + relpath = os.path.join(os.path.basename(tmpd), 'cloud.cfg') |
593 | + return relpath |
594 | + |
595 | + |
596 | +INITSYS_FILES = { |
597 | + 'sysvinit': [f for f in glob('sysvinit/redhat/*') if is_f(f)], |
598 | + 'sysvinit_freebsd': [f for f in glob('sysvinit/freebsd/*') if is_f(f)], |
599 | + 'sysvinit_deb': [f for f in glob('sysvinit/debian/*') if is_f(f)], |
600 | + 'sysvinit_openrc': [f for f in glob('sysvinit/gentoo/*') if is_f(f)], |
601 | + 'systemd': [f for f in (glob('systemd/*.service') + |
602 | + glob('systemd/*.target')) if is_f(f)], |
603 | + 'systemd.generators': [f for f in glob('systemd/*-generator') if is_f(f)], |
604 | + 'upstart': [f for f in glob('upstart/*') if is_f(f)], |
605 | +} |
606 | +INITSYS_ROOTS = { |
607 | + 'sysvinit': 'etc/rc.d/init.d', |
608 | + 'sysvinit_freebsd': 'usr/local/etc/rc.d', |
609 | + 'sysvinit_deb': 'etc/init.d', |
610 | + 'sysvinit_openrc': 'etc/init.d', |
611 | + 'systemd': pkg_config_read('systemd', 'systemdsystemunitdir'), |
612 | + 'systemd.generators': pkg_config_read('systemd', |
613 | + 'systemdsystemgeneratordir'), |
614 | + 'upstart': 'etc/init/', |
615 | +} |
616 | +INITSYS_TYPES = sorted([f.partition(".")[0] for f in INITSYS_ROOTS.keys()]) |
617 | + |
618 | + |
619 | +# Install everything in the right location and take care of Linux (default) and |
620 | +# FreeBSD systems. |
621 | +USR = "usr" |
622 | +ETC = "etc" |
623 | +USR_LIB_EXEC = "usr/lib" |
624 | +LIB = "lib" |
625 | +if os.uname()[0] == 'FreeBSD': |
626 | + USR = "usr/local" |
627 | + USR_LIB_EXEC = "usr/local/lib" |
628 | +elif os.path.isfile('/etc/redhat-release'): |
629 | + USR_LIB_EXEC = "usr/libexec" |
630 | + |
631 | + |
632 | # TODO: Is there a better way to do this?? |
633 | class InitsysInstallData(install): |
634 | init_system = None |
635 | @@ -155,36 +186,39 @@ class InitsysInstallData(install): |
636 | self.distribution.reinitialize_command('install_data', True) |
637 | |
638 | |
639 | -if in_virtualenv(): |
640 | - data_files = [] |
641 | - cmdclass = {} |
642 | -else: |
643 | - data_files = [ |
644 | - (ETC + '/cloud', glob('config/*.cfg')), |
645 | - (ETC + '/cloud/cloud.cfg.d', glob('config/cloud.cfg.d/*')), |
646 | - (ETC + '/cloud/templates', glob('templates/*')), |
647 | - (USR_LIB_EXEC + '/cloud-init', ['tools/ds-identify', |
648 | - 'tools/uncloud-init', |
649 | - 'tools/write-ssh-key-fingerprints']), |
650 | - (USR + '/share/doc/cloud-init', [f for f in glob('doc/*') if is_f(f)]), |
651 | - (USR + '/share/doc/cloud-init/examples', |
652 | - [f for f in glob('doc/examples/*') if is_f(f)]), |
653 | - (USR + '/share/doc/cloud-init/examples/seed', |
654 | - [f for f in glob('doc/examples/seed/*') if is_f(f)]), |
655 | - ] |
656 | - if os.uname()[0] != 'FreeBSD': |
657 | - data_files.extend([ |
658 | - (ETC + '/NetworkManager/dispatcher.d/', |
659 | - ['tools/hook-network-manager']), |
660 | - (ETC + '/dhcp/dhclient-exit-hooks.d/', ['tools/hook-dhclient']), |
661 | - (LIB + '/udev/rules.d', [f for f in glob('udev/*.rules')]) |
662 | - ]) |
663 | - # Use a subclass for install that handles |
664 | - # adding on the right init system configuration files |
665 | - cmdclass = { |
666 | - 'install': InitsysInstallData, |
667 | - } |
668 | - |
669 | +if not in_virtualenv(): |
670 | + USR = "/" + USR |
671 | + ETC = "/" + ETC |
672 | + USR_LIB_EXEC = "/" + USR_LIB_EXEC |
673 | + LIB = "/" + LIB |
674 | + for k in INITSYS_ROOTS.keys(): |
675 | + INITSYS_ROOTS[k] = "/" + INITSYS_ROOTS[k] |
676 | + |
677 | +data_files = [ |
678 | + (ETC + '/cloud', [render_cloud_cfg()]), |
679 | + (ETC + '/cloud/cloud.cfg.d', glob('config/cloud.cfg.d/*')), |
680 | + (ETC + '/cloud/templates', glob('templates/*')), |
681 | + (USR_LIB_EXEC + '/cloud-init', ['tools/ds-identify', |
682 | + 'tools/uncloud-init', |
683 | + 'tools/write-ssh-key-fingerprints']), |
684 | + (USR + '/share/doc/cloud-init', [f for f in glob('doc/*') if is_f(f)]), |
685 | + (USR + '/share/doc/cloud-init/examples', |
686 | + [f for f in glob('doc/examples/*') if is_f(f)]), |
687 | + (USR + '/share/doc/cloud-init/examples/seed', |
688 | + [f for f in glob('doc/examples/seed/*') if is_f(f)]), |
689 | +] |
690 | +if os.uname()[0] != 'FreeBSD': |
691 | + data_files.extend([ |
692 | + (ETC + '/NetworkManager/dispatcher.d/', |
693 | + ['tools/hook-network-manager']), |
694 | + (ETC + '/dhcp/dhclient-exit-hooks.d/', ['tools/hook-dhclient']), |
695 | + (LIB + '/udev/rules.d', [f for f in glob('udev/*.rules')]) |
696 | + ]) |
697 | +# Use a subclass for install that handles |
698 | +# adding on the right init system configuration files |
699 | +cmdclass = { |
700 | + 'install': InitsysInstallData, |
701 | +} |
702 | |
703 | requirements = read_requires() |
704 | if sys.version_info < (3,): |
705 | diff --git a/tools/render-cloudcfg b/tools/render-cloudcfg |
706 | new file mode 100755 |
707 | index 0000000..e624541 |
708 | --- /dev/null |
709 | +++ b/tools/render-cloudcfg |
710 | @@ -0,0 +1,43 @@ |
711 | +#!/usr/bin/env python3 |
712 | + |
713 | +import argparse |
714 | +import os |
715 | +import sys |
716 | + |
717 | +if "avoid-pep8-E402-import-not-top-of-file": |
718 | + _tdir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) |
719 | + sys.path.insert(0, _tdir) |
720 | + from cloudinit import templater |
721 | + from cloudinit import util |
722 | + from cloudinit.atomic_helper import write_file |
723 | + |
724 | + |
725 | +def main(): |
726 | + parser = argparse.ArgumentParser() |
727 | + variants = ["bsd", "centos", "fedora", "rhel", "ubuntu", "unknown"] |
728 | + platform = util.system_info() |
729 | + parser.add_argument( |
730 | + "--variant", default=platform['variant'], action="store", |
731 | + help="define the variant.", choices=variants) |
732 | + parser.add_argument( |
733 | + "template", nargs="?", action="store", |
734 | + default='./config/cloud.cfg.tmpl', |
735 | + help="Path to the cloud.cfg template") |
736 | + parser.add_argument( |
737 | + "output", nargs="?", action="store", default="-", |
738 | + help="Output file. Use '-' to write to stdout") |
739 | + |
740 | + args = parser.parse_args() |
741 | + |
742 | + with open(args.template, 'r') as fh: |
743 | + contents = fh.read() |
744 | + tpl_params = {'variant': args.variant} |
745 | + contents = (templater.render_string(contents, tpl_params)).rstrip() + "\n" |
746 | + util.load_yaml(contents) |
747 | + if args.output == "-": |
748 | + sys.stdout.write(contents) |
749 | + else: |
750 | + write_file(args.output, contents, omode="w") |
751 | + |
752 | +if __name__ == '__main__': |
753 | + main() |
FAILED: Continuous integration, rev:0a10399df14 0601465029080c0 e2fdf4c4bf6e34 /jenkins. ubuntu. com/server/ job/cloud- init-ci/ 457/ /jenkins. ubuntu. com/server/ job/cloud- init-ci/ nodes=metal- amd64/457/ console /jenkins. ubuntu. com/server/ job/cloud- init-ci/ nodes=metal- arm64/457/ console /jenkins. ubuntu. com/server/ job/cloud- init-ci/ nodes=metal- ppc64el/ 457/console /jenkins. ubuntu. com/server/ job/cloud- init-ci/ nodes=metal- s390x/457/ console /jenkins. ubuntu. com/server/ job/cloud- init-ci/ nodes=vm- i386/457/ console
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild: /jenkins. ubuntu. com/server/ job/cloud- init-ci/ 457/rebuild
https:/