I'm trying to use packer.io to create a machine image for a server who's deployment I already have automated using Chef (
chef-solo specifically), using the
amazon-chroot builder and the
chef-solo provisioner (with a few shell provisining steps wrapped around it for init / cleanup stuff).
This method mounts an EBS volume somewhere on the system and then
chroots into it and runs the Chef provisioning process there. Problem is, some of the Chef recipes create and start services and I was unable to get them not to start in the chroot. I would like them not to start for two reasons:
- I'm trying to get a cleaner machine image
- At the end of the build process, running services in the chroot prevent Packer from unmounting the EBS volume and thus completing the process
I've already created
/usr/sbin/policy-rc.d properly (as documented in the Packer docs) and am also doing the following to stop
initctl from working:
dpkg-divert --local --rename --add /sbin/initctl ln -s /bin/true /sbin/initctl
(Of course I'm reverting this at the end of the build process). However, some services - specifically the Chef-installed
postfix service, still manages to start itself after installation.
Any suggestions on additional measures I should take to keep services from starting?
Debian / Ubuntu specific solutions are welcome.