Merge ~smoser/cloud-init:feature/curtin-centos3 into cloud-init:master

Proposed by Scott Moser
Status: Merged
Merged at revision: dcbe479575fac9f293c5c4089f4bcb46ab887206
Proposed branch: ~smoser/cloud-init:feature/curtin-centos3
Merge into: cloud-init:master
Diff against target: 318 lines (+122/-44)
7 files modified
dev/null (+0/-27)
packages/redhat/cloud-init.spec.in (+0/-5)
setup.py (+19/-12)
systemd/cloud-config.service.tmpl (+17/-0)
systemd/cloud-final.service.tmpl (+22/-0)
systemd/cloud-init-local.service.tmpl (+29/-0)
systemd/cloud-init.service.tmpl (+35/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Ryan Harper Approve
Review via email: mp+327743@code.launchpad.net

Commit message

templatize systemd unit files for cross distro deltas

Under el7, cloud-init systemd files need some unit tweaks to ensure they
run at the right time. Pull in current el7 downstream systemd unit changes.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:790306385ad922e83517fcbdf6394c3363b52006
https://jenkins.ubuntu.com/server/job/cloud-init-ci/58/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: CentOS 6 & 7: Build & Test
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/58/rebuild

review: Approve (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :

I checked out this branch, created an srpm , built it in a cent7 container, installed in container.

review: Approve
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:dcbe479575fac9f293c5c4089f4bcb46ab887206
https://jenkins.ubuntu.com/server/job/cloud-init-ci/59/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: CentOS 6 & 7: Build & Test
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/59/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/packages/redhat/cloud-init.spec.in b/packages/redhat/cloud-init.spec.in
2index 9f75c4b..6ab0d20 100644
3--- a/packages/redhat/cloud-init.spec.in
4+++ b/packages/redhat/cloud-init.spec.in
5@@ -115,11 +115,6 @@ rm -rf $RPM_BUILD_ROOT%{python_sitelib}/tests
6 mkdir -p $RPM_BUILD_ROOT/%{_sharedstatedir}/cloud
7 mkdir -p $RPM_BUILD_ROOT/%{_libexecdir}/%{name}
8
9-%if "%{init_system}" == "systemd"
10-mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
11-cp -p systemd/* $RPM_BUILD_ROOT/%{_unitdir}
12-%endif
13-
14 %clean
15 rm -rf $RPM_BUILD_ROOT
16
17diff --git a/setup.py b/setup.py
18index bce06ad..1197ece 100755
19--- a/setup.py
20+++ b/setup.py
21@@ -87,8 +87,8 @@ def read_requires():
22 return str(deps).splitlines()
23
24
25-def render_cloud_cfg():
26- """render cloud.cfg into a tmpdir under same dir as setup.py
27+def render_tmpl(template):
28+ """render template into a tmpdir under same dir as setup.py
29
30 This is rendered to a temporary directory under the top level
31 directory with the name 'cloud.cfg'. The reason for not just rendering
32@@ -99,16 +99,21 @@ def render_cloud_cfg():
33 # older versions of tox use bdist (xenial), and then install from there.
34 # newer versions just use install.
35 if not (sys.argv[1] == 'install' or sys.argv[1].startswith('bdist*')):
36- return 'config/cloud.cfg.tmpl'
37+ return template
38+
39+ tmpl_ext = ".tmpl"
40+ # we may get passed a non-template file, just pass it back
41+ if not template.endswith(tmpl_ext):
42+ return template
43+
44 topdir = os.path.dirname(sys.argv[0])
45 tmpd = tempfile.mkdtemp(dir=topdir)
46 atexit.register(shutil.rmtree, tmpd)
47- fpath = os.path.join(tmpd, 'cloud.cfg')
48- tiny_p([sys.executable, './tools/render-cloudcfg',
49- 'config/cloud.cfg.tmpl', fpath])
50- # relpath is relative to setup.py
51- relpath = os.path.join(os.path.basename(tmpd), 'cloud.cfg')
52- return relpath
53+ bname = os.path.basename(template).rstrip(tmpl_ext)
54+ fpath = os.path.join(tmpd, bname)
55+ tiny_p([sys.executable, './tools/render-cloudcfg', template, fpath])
56+ # return path relative to setup.py
57+ return os.path.join(os.path.basename(tmpd), bname)
58
59
60 INITSYS_FILES = {
61@@ -116,8 +121,10 @@ INITSYS_FILES = {
62 'sysvinit_freebsd': [f for f in glob('sysvinit/freebsd/*') if is_f(f)],
63 'sysvinit_deb': [f for f in glob('sysvinit/debian/*') if is_f(f)],
64 'sysvinit_openrc': [f for f in glob('sysvinit/gentoo/*') if is_f(f)],
65- 'systemd': [f for f in (glob('systemd/*.service') +
66- glob('systemd/*.target')) if is_f(f)],
67+ 'systemd': [render_tmpl(f)
68+ for f in (glob('systemd/*.tmpl') +
69+ glob('systemd/*.service') +
70+ glob('systemd/*.target')) if is_f(f)],
71 'systemd.generators': [f for f in glob('systemd/*-generator') if is_f(f)],
72 'upstart': [f for f in glob('upstart/*') if is_f(f)],
73 }
74@@ -195,7 +202,7 @@ if not in_virtualenv():
75 INITSYS_ROOTS[k] = "/" + INITSYS_ROOTS[k]
76
77 data_files = [
78- (ETC + '/cloud', [render_cloud_cfg()]),
79+ (ETC + '/cloud', [render_tmpl("config/cloud.cfg.tmpl")]),
80 (ETC + '/cloud/cloud.cfg.d', glob('config/cloud.cfg.d/*')),
81 (ETC + '/cloud/templates', glob('templates/*')),
82 (USR_LIB_EXEC + '/cloud-init', ['tools/ds-identify',
83diff --git a/systemd/cloud-config.service b/systemd/cloud-config.service
84deleted file mode 100644
85index 3309e08..0000000
86--- a/systemd/cloud-config.service
87+++ /dev/null
88@@ -1,16 +0,0 @@
89-[Unit]
90-Description=Apply the settings specified in cloud-config
91-After=network-online.target cloud-config.target
92-Wants=network-online.target cloud-config.target
93-
94-[Service]
95-Type=oneshot
96-ExecStart=/usr/bin/cloud-init modules --mode=config
97-RemainAfterExit=yes
98-TimeoutSec=0
99-
100-# Output needs to appear in instance console output
101-StandardOutput=journal+console
102-
103-[Install]
104-WantedBy=cloud-init.target
105diff --git a/systemd/cloud-config.service.tmpl b/systemd/cloud-config.service.tmpl
106new file mode 100644
107index 0000000..bdee3ce
108--- /dev/null
109+++ b/systemd/cloud-config.service.tmpl
110@@ -0,0 +1,17 @@
111+## template:jinja
112+[Unit]
113+Description=Apply the settings specified in cloud-config
114+After=network-online.target cloud-config.target
115+Wants=network-online.target cloud-config.target
116+
117+[Service]
118+Type=oneshot
119+ExecStart=/usr/bin/cloud-init modules --mode=config
120+RemainAfterExit=yes
121+TimeoutSec=0
122+
123+# Output needs to appear in instance console output
124+StandardOutput=journal+console
125+
126+[Install]
127+WantedBy=cloud-init.target
128diff --git a/systemd/cloud-final.service b/systemd/cloud-final.service
129deleted file mode 100644
130index 66f5b8f..0000000
131--- a/systemd/cloud-final.service
132+++ /dev/null
133@@ -1,18 +0,0 @@
134-[Unit]
135-Description=Execute cloud user/final scripts
136-After=network-online.target cloud-config.service rc-local.service multi-user.target
137-Wants=network-online.target cloud-config.service
138-Before=apt-daily.service
139-
140-[Service]
141-Type=oneshot
142-ExecStart=/usr/bin/cloud-init modules --mode=final
143-RemainAfterExit=yes
144-TimeoutSec=0
145-KillMode=process
146-
147-# Output needs to appear in instance console output
148-StandardOutput=journal+console
149-
150-[Install]
151-WantedBy=cloud-init.target
152diff --git a/systemd/cloud-final.service.tmpl b/systemd/cloud-final.service.tmpl
153new file mode 100644
154index 0000000..fc01b89
155--- /dev/null
156+++ b/systemd/cloud-final.service.tmpl
157@@ -0,0 +1,22 @@
158+## template:jinja
159+[Unit]
160+Description=Execute cloud user/final scripts
161+After=network-online.target cloud-config.service rc-local.service
162+{% if variant in ["ubuntu", "unknown", "debian"] %}
163+After=multi-user.target
164+{% endif %}
165+Wants=network-online.target cloud-config.service
166+Before=apt-daily.service
167+
168+[Service]
169+Type=oneshot
170+ExecStart=/usr/bin/cloud-init modules --mode=final
171+RemainAfterExit=yes
172+TimeoutSec=0
173+KillMode=process
174+
175+# Output needs to appear in instance console output
176+StandardOutput=journal+console
177+
178+[Install]
179+WantedBy=cloud-init.target
180diff --git a/systemd/cloud-init-local.service b/systemd/cloud-init-local.service
181deleted file mode 100644
182index 7ee43ed..0000000
183--- a/systemd/cloud-init-local.service
184+++ /dev/null
185@@ -1,24 +0,0 @@
186-[Unit]
187-Description=Initial cloud-init job (pre-networking)
188-DefaultDependencies=no
189-Wants=network-pre.target
190-After=systemd-remount-fs.service
191-Before=NetworkManager.service
192-Before=network-pre.target
193-Before=shutdown.target
194-Before=sysinit.target
195-Conflicts=shutdown.target
196-RequiresMountsFor=/var/lib/cloud
197-
198-[Service]
199-Type=oneshot
200-ExecStart=/usr/bin/cloud-init init --local
201-ExecStart=/bin/touch /run/cloud-init/network-config-ready
202-RemainAfterExit=yes
203-TimeoutSec=0
204-
205-# Output needs to appear in instance console output
206-StandardOutput=journal+console
207-
208-[Install]
209-WantedBy=cloud-init.target
210diff --git a/systemd/cloud-init-local.service.tmpl b/systemd/cloud-init-local.service.tmpl
211new file mode 100644
212index 0000000..ff9c644
213--- /dev/null
214+++ b/systemd/cloud-init-local.service.tmpl
215@@ -0,0 +1,29 @@
216+## template:jinja
217+[Unit]
218+Description=Initial cloud-init job (pre-networking)
219+{% if variant in ["ubuntu", "unknown", "debian"] %}
220+DefaultDependencies=no
221+{% endif %}
222+Wants=network-pre.target
223+After=systemd-remount-fs.service
224+Before=NetworkManager.service
225+Before=network-pre.target
226+Before=shutdown.target
227+{% if variant in ["ubuntu", "unknown", "debian"] %}
228+Before=sysinit.target
229+Conflicts=shutdown.target
230+{% endif %}
231+RequiresMountsFor=/var/lib/cloud
232+
233+[Service]
234+Type=oneshot
235+ExecStart=/usr/bin/cloud-init init --local
236+ExecStart=/bin/touch /run/cloud-init/network-config-ready
237+RemainAfterExit=yes
238+TimeoutSec=0
239+
240+# Output needs to appear in instance console output
241+StandardOutput=journal+console
242+
243+[Install]
244+WantedBy=cloud-init.target
245diff --git a/systemd/cloud-init.service b/systemd/cloud-init.service
246deleted file mode 100644
247index 39acc20..0000000
248--- a/systemd/cloud-init.service
249+++ /dev/null
250@@ -1,27 +0,0 @@
251-[Unit]
252-Description=Initial cloud-init job (metadata service crawler)
253-DefaultDependencies=no
254-Wants=cloud-init-local.service
255-Wants=sshd-keygen.service
256-Wants=sshd.service
257-After=cloud-init-local.service
258-After=systemd-networkd-wait-online.service
259-After=networking.service
260-Before=network-online.target
261-Before=sshd-keygen.service
262-Before=sshd.service
263-Before=sysinit.target
264-Before=systemd-user-sessions.service
265-Conflicts=shutdown.target
266-
267-[Service]
268-Type=oneshot
269-ExecStart=/usr/bin/cloud-init init
270-RemainAfterExit=yes
271-TimeoutSec=0
272-
273-# Output needs to appear in instance console output
274-StandardOutput=journal+console
275-
276-[Install]
277-WantedBy=cloud-init.target
278diff --git a/systemd/cloud-init.service.tmpl b/systemd/cloud-init.service.tmpl
279new file mode 100644
280index 0000000..2c71889
281--- /dev/null
282+++ b/systemd/cloud-init.service.tmpl
283@@ -0,0 +1,35 @@
284+## template:jinja
285+[Unit]
286+Description=Initial cloud-init job (metadata service crawler)
287+DefaultDependencies=no
288+Wants=cloud-init-local.service
289+Wants=sshd-keygen.service
290+Wants=sshd.service
291+After=cloud-init-local.service
292+After=systemd-networkd-wait-online.service
293+{% if variant in ["ubuntu", "unknown", "debian"] %}
294+After=networking.service
295+{% endif %}
296+{% if variant in ["centos", "fedora", "redhat"] %}
297+After=network.service
298+{% endif %}
299+Before=network-online.target
300+Before=sshd-keygen.service
301+Before=sshd.service
302+{% if variant in ["ubuntu", "unknown", "debian"] %}
303+Before=sysinit.target
304+Conflicts=shutdown.target
305+{% endif %}
306+Before=systemd-user-sessions.service
307+
308+[Service]
309+Type=oneshot
310+ExecStart=/usr/bin/cloud-init init
311+RemainAfterExit=yes
312+TimeoutSec=0
313+
314+# Output needs to appear in instance console output
315+StandardOutput=journal+console
316+
317+[Install]
318+WantedBy=cloud-init.target

Subscribers

People subscribed via source and target branches