0

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:

  1. I'm trying to get a cleaner machine image
  2. 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.

0

The postfix service uses an init script, so I am guessing they are calling the init script directly (instead of through invoke-rc.d). Try creating a file called /lib/lsb/init-functions.d/00-policy-rc.d:

if test -e /usr/sbin/policy-rc.d; then
    /usr/sbin/policy-rc.d || exit $?
fi
  • This worked well for postfix, thank you. I am still having issues with unmounting the block device after chef run in the chroot, but that's a whole different issue – shevron Nov 18 '14 at 10:40

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.