Update cloud image
[releng/builder.git] / packer / provision / gbp.sh
1 #!/bin/bash
2
3 # vim: sw=4 ts=4 sts=4 et tw=72 :
4
5 # force any errors to cause the script and job to end in failure
6 set -xeu -o pipefail
7
8 # Ensure that necessary variables are set to enable noninteractive mode in
9 # commands.
10 export DEBIAN_FRONTEND=noninteractive
11
12 # additional kernel packages required for docker to fix
13 # aufs failed: driver not supported
14 echo "---> Installing Additional kernel packages required for docker"
15 apt-get update
16 apt-get install "linux-image-extra-$(uname -r)" linux-image-extra-virtual
17 modprobe aufs
18
19 # Install and configure docker. Use puppetlabs docker which supports
20 # Ubuntu 16.04
21 puppet module install puppetlabs-docker_platform --version 2.2.1
22
23 # do the package install via puppet so that we know it actually installs
24 # properly and it also makes it quieter but with better error reporting
25 echo "---> Installing Group Based Policy requirements"
26 puppet apply /tmp/packer/gbp_packages.pp
27
28 # configure docker networking so that it does not conflict with LF internal networks
29 # configure docker daemon to listen on port 5555 enabling remote managment
30 # This has to happen before docker gets installed or things go sideways
31 # badly
32 cat <<EOL > /etc/default/docker
33 # /etc/default/docker
34 DOCKER_OPTS='-H unix:///var/run/docker.sock -H tcp://0.0.0.0:5555 --bip=10.250.0.254/24'
35 EOL
36
37 # docker
38 echo "---> Installing docker"
39 puppet apply /tmp/packer/docker_setup.pp
40
41 echo "---> stopping docker"
42 puppet apply -e "service { 'docker': ensure => stopped }"
43
44 echo "---> cleaning docker configs that break after snapshotting"
45 rm -f /var/lib/docker/repositories-aufs /etc/docker/key.json
46
47 # OVS
48 echo "---> Installing ovs"
49 puppet module install puppetlabs-vcsrepo
50 puppet apply /tmp/packer/ovs_setup.pp
51
52 pushd /root/ovs
53 DEB_BUILD_OPTIONS='parallel=8 nocheck' fakeroot debian/rules binary | \
54  grep 'dpkg-deb: building package'
55 popd
56
57 # Note this does not actually install OVS. Everytime we've tried to do
58 # that the snapshot system hangs on spin-up for some reason. As such the
59 # final installation will have to be left as a spin-up task
60
61 # The following is what should be used in the spin-up task
62 # dpkg --install /root/openvswitch-datapath-dkms* && dpkg --install /root/openvswitch-{common,switch}*