I tried that user-data (minus the extra packages: and ssh_authorized_keys: as they are irrelevant) on the current wily cloud image with QEMU, and I get:
[ 13.799851] cloud-init[1010]: Cloud-init v. 0.7.7 running 'modules:config' at Wed, 28 Oct 2015 08:11:33 +0000. Up 13.12 seconds. [ 14.189822] cloud-init[1088]: + mkdir -p /var/lib/juju/init/juju-template-restart [ 14.192818] cloud-init[1088]: + cat [ 14.194669] cloud-init[1088]: + /bin/systemctl link /var/lib/juju/init/juju-template-restart/juju-template-restart.service [ 14.208282] cloud-init[1088]: Created symlink from /etc/systemd/system/juju-template-restart.service to /var/lib/juju/init/juju-template-restart/juju-template-restart.service. [ 14.271740] cloud-init[1088]: + /bin/systemctl daemon-reload [ 14.342206] cloud-init[1088]: + /bin/systemctl enable /var/lib/juju/init/juju-template-restart/juju-template-restart.service [ 14.348218] cloud-init[1088]: Created symlink from /etc/systemd/system/multi-user.target.wants/juju-template-restart.service to /var/lib/juju/init/juju-template-restart/juju-template-restart.service. [ 14.416085] cloud-init[1088]: + /bin/systemctl start juju-template-restart.service Cloud-init 0.7.7 received SIGTERM, exiting... Filename: /usr/lib/python3.4/logging/__init__.py Function: handle Line number: 855 Filename: /usr/lib/python3.4/logging/__init__.py Function: callHandlers Line number: 1486 Filename: /usr/lib/python3.4/logging/__init__.py Function: handle Line number: 1424 [ 16.204669] reboot: Power down So that's a different timing/behaviour than your's, but it shows the race condition with this juju-template-restart.service. Reopening juju task for that. Can you please try to change the runcmd to drop all this and just use - (while [ ! -e /var/lib/cloud/instance/boot-finished ]; do sleep 1; done; shutdown -P now) & ? Note that more recent versions of cloud-init have better support for this (http://cloudinit.readthedocs.org/en/latest/topics/examples.html #reboot-poweroff-when-finished), but I believe that's not yet available on trusty; hence in autopkgtest I use the above while loop in the background instead of "power_state:". ** Changed in: juju-core Status: Invalid => Confirmed ** Summary changed: - Intermittent lxc failures on wily + Intermittent lxc failures on wily, juju-template-restart.service is racy ** Summary changed: - Intermittent lxc failures on wily, juju-template-restart.service is racy + Intermittent lxc failures on wily, juju-template-restart.service race condition -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1509747 Title: Intermittent lxc failures on wily, juju-template-restart.service race condition To manage notifications about this bug go to: https://bugs.launchpad.net/juju-core/+bug/1509747/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs