aboutsummaryrefslogtreecommitdiff
path: root/contrib/cirrus/packer/image-builder-image_base-setup.sh
blob: 26fbe2903caf4802d12b04c4bf97015a594b92c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash

# This script is called by packer on a vanilla CentOS VM, to setup the image
# used for building images FROM base images. It's not intended to be used
# outside of this context.

set -e

[[ "$1" == "post" ]] || exit 0  # pre stage not needed

# Load in library (copied by packer, before this script was run)
source $GOSRC/$SCRIPT_BASE/lib.sh

req_env_var TIMESTAMP GOSRC SCRIPT_BASE PACKER_BASE

install_ooe

echo "Updating packages"
ooe.sh sudo yum -y update

echo "Configuring repositories"
ooe.sh sudo yum -y install centos-release-scl epel-release

echo "Installing packages"
ooe.sh sudo yum -y install \
    genisoimage \
    golang \
    google-cloud-sdk \
    libvirt \
    libvirt-admin \
    libvirt-client \
    libvirt-daemon \
    make \
    python36 \
    python36-PyYAML \
    qemu-img \
    qemu-kvm \
    qemu-kvm-tools \
    qemu-user \
    rsync \
    rng-tools \
    unzip \
    util-linux \
    vim

sudo systemctl enable rngd

sudo ln -s /usr/libexec/qemu-kvm /usr/bin/

sudo tee /etc/modprobe.d/kvm-nested.conf <<EOF
options kvm-intel nested=1
options kvm-intel enable_shadow_vmcs=1
options kvm-intel enable_apicv=1
options kvm-intel ept=1
EOF

echo "Installing packer"
sudo mkdir -p /root/$(basename $PACKER_BASE)
sudo cp $GOSRC/$PACKER_BASE/*packer* /root/$(basename $PACKER_BASE)
sudo mkdir -p /root/$(basename $SCRIPT_BASE)
sudo cp $GOSRC/$SCRIPT_BASE/*.sh /root/$(basename $SCRIPT_BASE)

install_scl_git

echo "Cleaning up"
cd /
rm -rf $GOSRC

rh_finalize

echo "SUCCESS!"