From 43709420a3a932f12804080038ab3c89fe018927 Mon Sep 17 00:00:00 2001 From: Derek Nola Date: Tue, 1 Nov 2022 14:47:10 -0700 Subject: [PATCH] Remove vagrant dev env (#6395) Signed-off-by: Derek Nola --- Vagrantfile | 59 ---------- scripts/provision/generic/alpine312/vagrant | 32 ------ .../provision/generic/centos7/gen-gpg-keys | 37 ------- scripts/provision/generic/centos7/vagrant | 45 -------- .../generic/centos7/yum-install-rpm-tools | 7 -- scripts/provision/generic/centos8 | 1 - scripts/provision/generic/opensuse15/vagrant | 23 ---- scripts/provision/generic/ubuntu1804/vagrant | 40 ------- scripts/provision/generic/ubuntu2004 | 1 - scripts/provision/generic/ubuntu2104 | 1 - scripts/provision/vagrant | 102 ------------------ 11 files changed, 348 deletions(-) delete mode 100644 Vagrantfile delete mode 100755 scripts/provision/generic/alpine312/vagrant delete mode 100755 scripts/provision/generic/centos7/gen-gpg-keys delete mode 100755 scripts/provision/generic/centos7/vagrant delete mode 100755 scripts/provision/generic/centos7/yum-install-rpm-tools delete mode 120000 scripts/provision/generic/centos8 delete mode 100755 scripts/provision/generic/opensuse15/vagrant delete mode 100755 scripts/provision/generic/ubuntu1804/vagrant delete mode 120000 scripts/provision/generic/ubuntu2004 delete mode 120000 scripts/provision/generic/ubuntu2104 delete mode 100755 scripts/provision/vagrant diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index 9d5d70e601..0000000000 --- a/Vagrantfile +++ /dev/null @@ -1,59 +0,0 @@ -DISTRO = (ENV['DISTRO'] || "alpine312") -BOX_REPO = (ENV['BOX_REPO'] || "generic") -HOME = ENV['HOME'] -PROJ_HOME = File.dirname(__FILE__) -PROJECT = File.basename(PROJ_HOME) -NUM_NODES = (ENV['NUM_NODES'] || 0).to_i -NODE_CPUS = (ENV['NODE_CPUS'] || 4).to_i -NODE_MEMORY = (ENV['NODE_MEMORY'] || 8192).to_i -NETWORK_PREFIX = ENV['NETWORK_PREFIX'] || "10.135.135" -VAGRANT_PROVISION = ENV['VAGRANT_PROVISION'] || "./scripts/provision/vagrant" -MOUNT_TYPE = ENV['MOUNT_TYPE'] || "virtualbox" - -# --- Rules for /etc/sudoers to avoid password entry configuring NFS: -# %admin ALL = (root) NOPASSWD: /usr/bin/sed -E -e * -ibak /etc/exports -# %admin ALL = (root) NOPASSWD: /usr/bin/tee -a /etc/exports -# %admin ALL = (root) NOPASSWD: /sbin/nfsd restart -# --- May need to add terminal to System Preferences -> Security & Privacy -> Privacy -> Full Disk Access - -def provision(vm, node_num) - node_os = (ENV["DISTRO_#{node_num}"] || DISTRO) - vm.box = (ENV["BOX_#{node_num}"] || ENV["BOX"] || "#{BOX_REPO}/#{node_os}") - vm.hostname = "#{PROJECT}-#{node_num}-#{vm.box.gsub(/^.*\//,"")}" - vm.network "private_network", ip: "#{NETWORK_PREFIX}.#{100+node_num}" - vm.provision "shell", - path: VAGRANT_PROVISION, - env: { 'HOME' => PROJ_HOME, 'GOPATH' => ENV['GOPATH'], 'BOX' => vm.box } -end - -Vagrant.configure("2") do |config| - - config.vm.provider "virtualbox" do |v| - v.cpus = NODE_CPUS - v.memory = NODE_MEMORY - v.customize ["modifyvm", :id, "--audio", "none"] - end - config.vm.provider "libvirt" do |v| - v.cpus = NODE_CPUS - v.memory = NODE_MEMORY - end - if Vagrant.has_plugin?("vagrant-timezone") - config.timezone.value = :host - end - if "#{MOUNT_TYPE}" == "nfs" - config.vm.synced_folder HOME, HOME, type: "nfs", mount_options: ["vers=3,tcp"] - else - config.vm.synced_folder HOME, HOME, type: MOUNT_TYPE - end - - if NUM_NODES==0 - provision(config.vm, 0) - else - (1..NUM_NODES).each do |i| - config.vm.define ".#{i}" do |node| - provision(node.vm, i) - end - end - end - -end diff --git a/scripts/provision/generic/alpine312/vagrant b/scripts/provision/generic/alpine312/vagrant deleted file mode 100755 index ee06985383..0000000000 --- a/scripts/provision/generic/alpine312/vagrant +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -set -ve - -apk add -q -f curl libc6-compat tzdata -download_go -# --- -rc-update add cgroups default -/etc/init.d/cgroups start -# --- -cat </etc/profile.d/build.sh -export SELINUX=true -export STATIC_BUILD=true -EOF -. /etc/profile.d/build.sh -# --- -. /tmp/docker-run -# --- -go install -u github.com/go-delve/delve/cmd/dlv -# --- -cat </etc/profile.d/docker.sh -export DOCKER_HOST=tcp://10.0.2.2:2375 -EOF -. /etc/profile.d/docker.sh -# --- -( - if ! docker version --format '{{.Server.Version}}' >/tmp/docker-server-version; then - echo "WARNING: Unable to connect to the docker socket, to enable docker in vagrant run the following command on the host:" - echo "docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 127.0.0.1:2375:2375 alpine/socat TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock" - else - echo "Using host docker server v$(cat /tmp/docker-server-version)" - fi -) diff --git a/scripts/provision/generic/centos7/gen-gpg-keys b/scripts/provision/generic/centos7/gen-gpg-keys deleted file mode 100755 index 71bb94ebb8..0000000000 --- a/scripts/provision/generic/centos7/gen-gpg-keys +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -set -e -x - -TMPDIR=$(mktemp -d) -cleanup() { - exit_code=$? - trap - EXIT INT - rm -rf ${TMPDIR} - exit ${exit_code} -} -trap cleanup EXIT INT - -export HOME=${TMPDIR} - -gpg --batch --gen-key - <public.key -gpg --armor --export-secret-key ci@rancher.com >private.key diff --git a/scripts/provision/generic/centos7/vagrant b/scripts/provision/generic/centos7/vagrant deleted file mode 100755 index 45ec5e6eee..0000000000 --- a/scripts/provision/generic/centos7/vagrant +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -set -ve - -download_go -# --- -cat </etc/profile.d/build.sh -export SELINUX=true -# export STATIC_BUILD=true -EOF -. /etc/profile.d/build.sh -# --- -sed -E 's|apk( -U)?( --no-cache)?( --repository [^ ]*)? add|yum install -y|g' -i /tmp/docker-run -sed -E 's/-dev/-devel/g' -i /tmp/docker-run -. /tmp/docker-run -# --- -go install -u github.com/go-delve/delve/cmd/dlv -# --- -# docker install instructions slightly changed from https://kubernetes.io/docs/setup/production-environment/container-runtimes/ -# default "exec-opts": ["native.cgroupdriver=cgroupfs"], and set "selinux-enabled": true -yum remove -y docker docker-common -yum install -y yum-utils device-mapper-persistent-data lvm2 -yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo -yum update -y && yum install -y containerd.io-1.2.10 docker-ce-19.03.4 docker-ce-cli-19.03.4 -mkdir -p /etc/docker -cat > /etc/docker/daemon.json </etc/profile.d/build.sh -export SELINUX=true -# export STATIC_BUILD=true -EOF -. /etc/profile.d/build.sh -# --- -zypper -q install -y \ - git \ - libseccomp-devel \ - libselinux-devel \ - zstd \ - -# --- -sed -E 's|apk( -U)?( --no-cache)?( --repository [^ ]*)? add .*||g' -i /tmp/docker-run -. /tmp/docker-run -# --- -go install -u github.com/go-delve/delve/cmd/dlv -# --- diff --git a/scripts/provision/generic/ubuntu1804/vagrant b/scripts/provision/generic/ubuntu1804/vagrant deleted file mode 100755 index c0b1c735ce..0000000000 --- a/scripts/provision/generic/ubuntu1804/vagrant +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -set -ve - -download_go -# --- -cat </etc/profile.d/build.sh -export SELINUX=true -# export STATIC_BUILD=true -EOF -. /etc/profile.d/build.sh -# --- -apt-get update -apt-get install -y \ - build-essential \ - ca-certificates \ - curl \ - docker.io \ - gcc \ - git \ - jq \ - libffi-dev \ - libseccomp-dev \ - libsqlite3-dev \ - libselinux1-dev \ - libuv1-dev \ - make \ - npm \ - pkg-config \ - python3 \ - squashfs-tools \ - tar \ - wget \ - vim \ - zip \ - zlib1g-dev \ - zstd - -# --- -go install -u github.com/go-delve/delve/cmd/dlv -# --- diff --git a/scripts/provision/generic/ubuntu2004 b/scripts/provision/generic/ubuntu2004 deleted file mode 120000 index 967c57335e..0000000000 --- a/scripts/provision/generic/ubuntu2004 +++ /dev/null @@ -1 +0,0 @@ -ubuntu1804 \ No newline at end of file diff --git a/scripts/provision/generic/ubuntu2104 b/scripts/provision/generic/ubuntu2104 deleted file mode 120000 index 967c57335e..0000000000 --- a/scripts/provision/generic/ubuntu2104 +++ /dev/null @@ -1 +0,0 @@ -ubuntu1804 \ No newline at end of file diff --git a/scripts/provision/vagrant b/scripts/provision/vagrant deleted file mode 100755 index b637d475eb..0000000000 --- a/scripts/provision/vagrant +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/bash -set -ve - -PROVISION="scripts/provision/$BOX/vagrant" - -if [ ! -f /etc/vagrant_box_build_time ]; then - echo 'This script should only be called during vagrant provisioning' - exit 1 -fi - -if [[ $HOME = /go/* ]]; then - echo 'Must not launch vagrant from /go/' - exit 1 -fi -cd - -# --- Default to root user for vagrant ssh -cat <<\EOF >/etc/profile.d/root.sh -[ $EUID -ne 0 ] && exec sudo -i -EOF - -# --- Setup go version -if [ -z "${GOPATH}" ]; then - GOPATH=$(realpath $HOME/../../../..) - echo "WARNING: Assuming GOPATH=$GOPATH" -else - echo "Using parent GOPATH=$GOPATH" -fi - -# --- Setup basic env -cat </etc/profile.d/env.sh -export ARCH=amd64 -export GO111MODULE=off -export GOPATH=$GOPATH -export PATH=/usr/local/bin:$PATH:/usr/local/go/bin:$GOPATH/bin -export HOME=$HOME && cd -EOF -. /etc/profile.d/env.sh - -# --- Clean go cache -rm -rf .cache/go-build || true - -# --- Set color prompt -sed -i 's|:/bin/ash$|:/bin/bash|g' /etc/passwd -cat <<\EOF >/etc/profile.d/color.sh -alias ls='ls --color=auto' -export PS1='\033[31m[ \033[90m\D{%F 🐮 %T}\033[31m ]\n\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h\[\033[35m\]:\[\033[33;1m\]\w\[\033[m\]\$ ' -EOF - -# --- Setup install script from docker run commands -mkdir -p ${GOPATH}/bin -mkdir -p /go -ln -sf $GOPATH/bin /go/bin -sed ':a;N;$!ba;s/\\\n/ /g' /tmp/docker-run -export BINDIR=/go/bin -export GOPATH=/go -export HOME=/tmp - -# --- Add k3s motd -cat <<\EOF >/etc/motd - , , - ,-----------|'------'| |\ ____ - /. '-'@ o|-' | | /___ \ - |/| | .. | | | __ __) | ____ - | .________.'----' | |/ /|__ < / __/ - | || | || | < ___) |\__ \ - \__|' \__|' |_|\_\_____/____/ - -EOF - -# --- Enable IPv6 and IP forwarding -sysctl -w net.ipv4.ip_forward=1 -sysctl -w net.ipv6.conf.all.disable_ipv6=0 -sysctl -w net.ipv6.conf.all.forwarding=1 -sed -i \ - -e "/^net.ipv6.conf.all.disable_ipv6 = 1/d" \ - /etc/sysctl.conf -cat <>/etc/sysctl.conf -net.ipv4.ip_forward = 1 -net.ipv6.conf.all.disable_ipv6 = 0 -net.ipv6.conf.all.forwarding = 1 -EOF - -# --- Utility function to download go -download_go() { - goversion=$(grep "golang:" Dockerfile.dapper | sed -e 's/.*golang:\(.*\)-.*/\1/') - if [ -z "$goversion" ]; then - echo 'Cannot find version of go to fetch' - return 1 - fi - echo "Installing go $goversion" - curl -sL https://storage.googleapis.com/golang/go${goversion}.linux-${ARCH}.tar.gz | tar -xzf - -C /usr/local -} - -# --- Run vagrant provision script if available -if [ ! -f "${PROVISION}" ]; then - echo "WARNING: Unable to execute provision script \"${PROVISION}\"" - exit -fi -echo "running '${PROVISION}'..." && \ - . ${PROVISION} && \ - echo "finished '${PROVISION}'!"