diff options
-rw-r--r-- | packages/redhat/cloud-init.spec.in | 5 | ||||
-rwxr-xr-x | setup.py | 31 | ||||
-rw-r--r-- | systemd/cloud-config.service.tmpl (renamed from systemd/cloud-config.service) | 1 | ||||
-rw-r--r-- | systemd/cloud-final.service.tmpl (renamed from systemd/cloud-final.service) | 6 | ||||
-rw-r--r-- | systemd/cloud-init-local.service.tmpl (renamed from systemd/cloud-init-local.service) | 5 | ||||
-rw-r--r-- | systemd/cloud-init.service.tmpl (renamed from systemd/cloud-init.service) | 10 |
6 files changed, 39 insertions, 19 deletions
diff --git a/packages/redhat/cloud-init.spec.in b/packages/redhat/cloud-init.spec.in index 9f75c4b8..6ab0d20b 100644 --- a/packages/redhat/cloud-init.spec.in +++ b/packages/redhat/cloud-init.spec.in @@ -115,11 +115,6 @@ rm -rf $RPM_BUILD_ROOT%{python_sitelib}/tests mkdir -p $RPM_BUILD_ROOT/%{_sharedstatedir}/cloud mkdir -p $RPM_BUILD_ROOT/%{_libexecdir}/%{name} -%if "%{init_system}" == "systemd" -mkdir -p $RPM_BUILD_ROOT/%{_unitdir} -cp -p systemd/* $RPM_BUILD_ROOT/%{_unitdir} -%endif - %clean rm -rf $RPM_BUILD_ROOT @@ -87,8 +87,8 @@ def read_requires(): return str(deps).splitlines() -def render_cloud_cfg(): - """render cloud.cfg into a tmpdir under same dir as setup.py +def render_tmpl(template): + """render template into a tmpdir under same dir as setup.py This is rendered to a temporary directory under the top level directory with the name 'cloud.cfg'. The reason for not just rendering @@ -99,16 +99,21 @@ def render_cloud_cfg(): # older versions of tox use bdist (xenial), and then install from there. # newer versions just use install. if not (sys.argv[1] == 'install' or sys.argv[1].startswith('bdist*')): - return 'config/cloud.cfg.tmpl' + return template + + tmpl_ext = ".tmpl" + # we may get passed a non-template file, just pass it back + if not template.endswith(tmpl_ext): + return template + topdir = os.path.dirname(sys.argv[0]) tmpd = tempfile.mkdtemp(dir=topdir) atexit.register(shutil.rmtree, tmpd) - fpath = os.path.join(tmpd, 'cloud.cfg') - tiny_p([sys.executable, './tools/render-cloudcfg', - 'config/cloud.cfg.tmpl', fpath]) - # relpath is relative to setup.py - relpath = os.path.join(os.path.basename(tmpd), 'cloud.cfg') - return relpath + bname = os.path.basename(template).rstrip(tmpl_ext) + fpath = os.path.join(tmpd, bname) + tiny_p([sys.executable, './tools/render-cloudcfg', template, fpath]) + # return path relative to setup.py + return os.path.join(os.path.basename(tmpd), bname) INITSYS_FILES = { @@ -116,8 +121,10 @@ INITSYS_FILES = { 'sysvinit_freebsd': [f for f in glob('sysvinit/freebsd/*') if is_f(f)], 'sysvinit_deb': [f for f in glob('sysvinit/debian/*') if is_f(f)], 'sysvinit_openrc': [f for f in glob('sysvinit/gentoo/*') if is_f(f)], - 'systemd': [f for f in (glob('systemd/*.service') + - glob('systemd/*.target')) if is_f(f)], + 'systemd': [render_tmpl(f) + for f in (glob('systemd/*.tmpl') + + glob('systemd/*.service') + + glob('systemd/*.target')) if is_f(f)], 'systemd.generators': [f for f in glob('systemd/*-generator') if is_f(f)], 'upstart': [f for f in glob('upstart/*') if is_f(f)], } @@ -195,7 +202,7 @@ if not in_virtualenv(): INITSYS_ROOTS[k] = "/" + INITSYS_ROOTS[k] data_files = [ - (ETC + '/cloud', [render_cloud_cfg()]), + (ETC + '/cloud', [render_tmpl("config/cloud.cfg.tmpl")]), (ETC + '/cloud/cloud.cfg.d', glob('config/cloud.cfg.d/*')), (ETC + '/cloud/templates', glob('templates/*')), (USR_LIB_EXEC + '/cloud-init', ['tools/ds-identify', diff --git a/systemd/cloud-config.service b/systemd/cloud-config.service.tmpl index 3309e08a..bdee3ce0 100644 --- a/systemd/cloud-config.service +++ b/systemd/cloud-config.service.tmpl @@ -1,3 +1,4 @@ +## template:jinja [Unit] Description=Apply the settings specified in cloud-config After=network-online.target cloud-config.target diff --git a/systemd/cloud-final.service b/systemd/cloud-final.service.tmpl index 66f5b8fc..fc01b891 100644 --- a/systemd/cloud-final.service +++ b/systemd/cloud-final.service.tmpl @@ -1,6 +1,10 @@ +## template:jinja [Unit] Description=Execute cloud user/final scripts -After=network-online.target cloud-config.service rc-local.service multi-user.target +After=network-online.target cloud-config.service rc-local.service +{% if variant in ["ubuntu", "unknown", "debian"] %} +After=multi-user.target +{% endif %} Wants=network-online.target cloud-config.service Before=apt-daily.service diff --git a/systemd/cloud-init-local.service b/systemd/cloud-init-local.service.tmpl index 7ee43eda..ff9c644d 100644 --- a/systemd/cloud-init-local.service +++ b/systemd/cloud-init-local.service.tmpl @@ -1,13 +1,18 @@ +## template:jinja [Unit] Description=Initial cloud-init job (pre-networking) +{% if variant in ["ubuntu", "unknown", "debian"] %} DefaultDependencies=no +{% endif %} Wants=network-pre.target After=systemd-remount-fs.service Before=NetworkManager.service Before=network-pre.target Before=shutdown.target +{% if variant in ["ubuntu", "unknown", "debian"] %} Before=sysinit.target Conflicts=shutdown.target +{% endif %} RequiresMountsFor=/var/lib/cloud [Service] diff --git a/systemd/cloud-init.service b/systemd/cloud-init.service.tmpl index 39acc20a..2c71889d 100644 --- a/systemd/cloud-init.service +++ b/systemd/cloud-init.service.tmpl @@ -1,3 +1,4 @@ +## template:jinja [Unit] Description=Initial cloud-init job (metadata service crawler) DefaultDependencies=no @@ -6,13 +7,20 @@ Wants=sshd-keygen.service Wants=sshd.service After=cloud-init-local.service After=systemd-networkd-wait-online.service +{% if variant in ["ubuntu", "unknown", "debian"] %} After=networking.service +{% endif %} +{% if variant in ["centos", "fedora", "redhat"] %} +After=network.service +{% endif %} Before=network-online.target Before=sshd-keygen.service Before=sshd.service +{% if variant in ["ubuntu", "unknown", "debian"] %} Before=sysinit.target -Before=systemd-user-sessions.service Conflicts=shutdown.target +{% endif %} +Before=systemd-user-sessions.service [Service] Type=oneshot |