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.

Misha Brukman
  • 768
  • 8
  • 22
shevron
  • 326
  • 2
  • 4
  • 10

1 Answers1

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
CameronNemo
  • 399
  • 1
  • 6
  • 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