Ok, here is what is happening: a.) dpkg (or apt) install of apache2 (or just about any service) starts services by calling to /usr/sbin/invoke-rc.d (like 'invoke-rc.d apache2 start'). b.) invoke-rc.d calls 'runlevel' to get the current runlevel and see if this service should be started. c.) runlevel during systemd boot writes 'unknown' (single token rather than previous and current runlevel) and exits 1 the test for failure of RUNLEVELHELPER is bogus in at least 2 ways ('test ! $?' will return 0 for 0 or 1, and additionally it actually only checks the return code of 'sed' which is going to be 0 anyway as sed did its job). d.) output of runlevel is stored in RL and then it goes looking for an SLINK or SSLINK (/etc/rc$RL.d/S??apache2 or /etc/rcS.d/S??apache2). Neither of these exist so it exits without starting the service.
The problem seems to be that any package install during systemd boot of a package that only provides sysvinit scripts will fail. Reading invoke-rc.d, i'm not really sure why a proper systemd service woudlnt fail also. ** Changed in: cloud-init (Ubuntu) Importance: Undecided => Medium ** Also affects: init-system-helpers (Ubuntu) Importance: Undecided Status: New ** Changed in: init-system-helpers (Ubuntu) Importance: Undecided => High ** Changed in: init-system-helpers (Ubuntu) Status: New => Confirmed -- You received this bug notification because you are a member of Ubuntu Touch seeded packages, which is subscribed to init-system-helpers in Ubuntu. https://bugs.launchpad.net/bugs/1575572 Title: apache2 fails to start if installed via cloud config (on Xenial) Status in cloud-init package in Ubuntu: Confirmed Status in init-system-helpers package in Ubuntu: Confirmed Bug description: Using the following cloud config, apache2 will fail to start on installation on Xenial: #cloud-config packages: - apache2 See for example: $ gcloud compute instances create xenial-$(date +%y%m%d-%H%M) --image ubuntu-1604-xenial-v20160420c --image-project ubuntu-os-cloud --metadata-from-file user-data=cloud-config NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS xenial-160427-1050 europe-west1-d n1-standard-1 10.240.0.7 104.155.86.94 RUNNING $ ssh ubuntu@104.155.86.94 systemctl status apache2.service ● apache2.service - LSB: Apache2 web server Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled) Drop-In: /lib/systemd/system/apache2.service.d └─apache2-systemd.conf Active: inactive (dead) Docs: man:systemd-sysv-generator(8) To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1575572/+subscriptions -- Mailing list: https://launchpad.net/~touch-packages Post to : touch-packages@lists.launchpad.net Unsubscribe : https://launchpad.net/~touch-packages More help : https://help.launchpad.net/ListHelp