Skip to content

Commit 62f38c0

Browse files
committed
allow bootstrapping digital ocean droplets
you must specify `boostrapi = digitalocean` in your `ez-master` definition
1 parent e33cc3e commit 62f38c0

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

bsdploy/fabfile_digitalocean.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# coding: utf-8
2+
from bsdploy.bootstrap_utils import BootstrapUtils
3+
from fabric.api import env, run, sudo
4+
from time import sleep
5+
6+
# a plain, default fabfile for jailhosts on digital ocean
7+
8+
9+
env.shell = '/bin/sh -c'
10+
11+
12+
def bootstrap(**kwargs):
13+
"""Digital Oceans FreeBSD droplets are pretty much already pre-bootstrapped,
14+
including having python2.7 and sudo etc. pre-installed.
15+
the only thing we need to change is to allow root to login (without a password)
16+
"""
17+
original_host = env.host_string
18+
env.host_string = 'freebsd@%s' % env.instance.uid
19+
sudo("""sysrc pf_enable=YES""")
20+
sudo("""sysrc -f /boot/loader.conf pfload=YES""")
21+
sudo('kldload pf', warn_only=True)
22+
sudo('service pf start')
23+
sudo("""echo 'PermitRootLogin without-password' > /etc/ssh/sshd_config""")
24+
sudo("""service sshd fastreload""")
25+
# revert back to root
26+
env.host_string = original_host
27+
# give sshd a chance to restart
28+
sleep(2)
29+
30+
# allow overwrites from the commandline
31+
env.instance.config.update(kwargs)
32+
33+
bu = BootstrapUtils()
34+
bu.ssh_keys = None
35+
bu.upload_authorized_keys = False

0 commit comments

Comments
 (0)