Customizing bootstrap

Currently the bootstrap API isn’t ready for documentation and general use. In case you want to mess with it anyway, here are some things which will be safe to do.

mfsBSD http proxy example

If you are setting up many virtual machines for testing, then a caching http proxy to reduce the downloads comes in handy. You can achieve that by using polipo on the VM host and the following changes.

First you need a custom fabfile:

from bsdploy.fabfile_mfsbsd import _bootstrap, _mfsbsd
from fabric.api import env, hide, run, settings
from ploy.config import value_asbool

def bootstrap(**kwargs):
    with _mfsbsd(env, kwargs):
        reboot = value_asbool(env.instance.config.get('bootstrap-reboot', 'true'))
        env.instance.config['bootstrap-reboot'] = False
        run('echo setenv http_proxy >> /etc/csh.cshrc')
        run('echo http_proxy= >> /etc/profile')
        run('echo export http_proxy >> /etc/profile')
        run('echo setenv http_proxy >> /mnt/etc/csh.cshrc')
        run('echo http_proxy= >> /mnt/etc/profile')
        run('echo export http_proxy >> /mnt/etc/profile')
        if reboot:
            with settings(hide('warnings'), warn_only=True):

For the ezjail initialization you have to add the following setting with a FreeBSD http mirror of your choice to your jail host config in ploy.conf:

ansible-ploy_ezjail_install_host =

The _mfsbsd context manager takes care of setting the bootstrap-host-keys etc for mfsBSD. The _bootstrap function then runs the regular bootstrapping.

For the jails you can use a startup script like this:

exec 1>/var/log/startup.log 2>&1
chmod 0600 /var/log/startup.log
set -e
set -x
echo setenv http_proxy >> /etc/csh.cshrc
echo http_proxy= >> /etc/profile
echo export http_proxy >> /etc/profile
export http_proxy
pkg install python27