Skip to content

Instantly share code, notes, and snippets.

@7error
Forked from avthart/Vagrantfile
Created December 24, 2019 10:18
Show Gist options
  • Save 7error/ca86a893329a2f8df84276273a61e8a8 to your computer and use it in GitHub Desktop.
Save 7error/ca86a893329a2f8df84276273a61e8a8 to your computer and use it in GitHub Desktop.
Vagrantfile for running Harbor. https://goharbor.io/
# -*- mode: ruby -*-
# vi: set ft=ruby :
# This script to install Kubernetes will get executed after we have provisioned the box
$script = <<-SCRIPT
apt-get update
apt-get install -y docker.io docker-compose python
curl -s https://storage.googleapis.com/harbor-releases/release-1.7.0/harbor-online-installer-v1.7.1.tgz | tar zxv
cd harbor
export IPADDR=`ifconfig enp0s8 | grep Mask | awk '{print $2}'| cut -f2 -d:`
sed -i "s/^hostname = .*$/hostname = ${IPADDR}.xip.io/g" harbor.cfg
sed -i "s/^ui_url_protocol = http$/ui_url_protocol = https/g" harbor.cfg
mkdir -p /data/cert
pushd /data/cert
openssl genrsa -out ca.key 4096
openssl req -x509 -new -nodes -sha512 -days 3650 \
-subj "/C=TW/ST=Taipei/L=Taipei/O=example/OU=Personal/CN=$IPADDR.xip.io" \
-key ca.key \
-out ca.crt
openssl genrsa -out server.key 4096
openssl req -sha512 -new \
-subj "/C=TW/ST=Taipei/L=Taipei/O=example/OU=Personal/CN=$IPADDR.xip.io" \
-key server.key \
-out server.csr
cat > v3.ext <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1=$IPADDR.xip.io
DNS.2=$IPADDR
EOF
openssl x509 -req -sha512 -days 3650 \
-extfile v3.ext \
-CA ca.crt -CAkey ca.key -CAcreateserial \
-in server.csr \
-out server.crt
popd
./prepare
./install.sh --with-notary --with-clair
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.hostname = "harbor"
config.vm.network "private_network", type: "dhcp"
config.vm.provision "shell", inline: $script
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment