Skip to content
name: "Deploy Vagrant Server"
on:
push:
branches:
- '**'
workflow_dispatch:
env:
VIRTUALBOX_VERSION: "7.0"
VAGRANT_VERSION: "2.4.1-1"
UBUNTU_VERSION: "24.04.1"
jobs:
tests:
strategy:
fail-fast: false
matrix:
proxmox_version: [ 8 ]
runs-on: ubuntu-22.04
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Establish WireGuard connection"
run: |
sudo apt-get -qq update
sudo apt-get -qq install wireguard resolvconf
echo "[Interface]
PrivateKey = ${{ secrets.WIREGUARD_PRIVATE_KEY }}
Address = ${{ vars.WIREGUARD_IP }}
DNS = ${{ vars.WIREGUARD_DNS }}
[Peer]
PublicKey = ${{ secrets.WIREGUARD_PUBLIC_KEY }}
PresharedKey = ${{ secrets.WIREGUARD_PRESHARED_KEY }}
Endpoint = ${{ vars.WIREGUARD_ENDPOINT }}
AllowedIPs = ${{ vars.WIREGUARD_ALLOWED_IPS }}
PersistentKeepalive = 25" | sudo tee /etc/wireguard/wg0.conf
sudo wg-quick up wg0
- name: "Setup a user for login"
run:
useradd -m clincha
mkdir /home/clincha/.ssh
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIq6GsW5VG34q/SOzGKZpo+pevmpj9O+CjWDo+wOjqTO" > /home/clincha/.ssh/authorized_keys
chown clincha:clincha /home/clincha/.ssh/authorized_keys
chmod 600 /home/clincha/.ssh/authorized_keys
- name: "Install VirtualBox"
run: |
wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --dearmor -o /usr/share/keyrings/oracle-virtualbox-2016.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
sudo apt-get -qq update
sudo apt-get -qq install virtualbox-${{ env.VIRTUALBOX_VERSION }}
- name: "Install Vagrant"
run: |
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt-get update -qq
sudo apt-get -qq install vagrant=${{ env.VAGRANT_VERSION }}
- name: "Load the Ubuntu ISO into the Vagrant box"
working-directory: vagrant/proxmox-${{ matrix.proxmox_version }}
run: |
mkdir iso
sudo wget -q --content-disposition -P ./iso https://releases.ubuntu.com/${{ env.UBUNTU_VERSION }}/ubuntu-${{ env.UBUNTU_VERSION }}-live-server-amd64.iso
- name: "Start Vagrant box"
working-directory: vagrant/proxmox-${{ matrix.proxmox_version }}
run: |
sudo vagrant up --no-tty
- name: "Initialize Packer"
working-directory: packer
run: |
packer init .
- name: "Create log directory"
run: |
mkdir /tmp/logs
- name: "Build template with Packer"
working-directory: packer
env:
PACKER_LOG: 1
# PACKER_LOG_PATH: /tmp/logs/packer-proxmox-${{ matrix.proxmox_version }}.log
run: |
packer build -var "ssh_password=${{ secrets.ANSIBLE_PASSWORD }}" .
# > /tmp/logs/packer-proxmox-process-${{ matrix.proxmox_version }}.log \
# &
# echo "Packer build started, sleeping."
# sleep 10
# echo "Sleep concluded"
#
# - name: "Start a container and read the terminal output"
# working-directory: vagrant/proxmox-${{ matrix.proxmox_version }}
# shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
# run: |
# sudo vagrant ssh -c 'sudo qm status 100'
# sudo vagrant ssh -c 'sudo qm terminal 100'
# mv typescript /tmp/logs/vagrant-proxmox-${{ matrix.proxmox_version }}.log
#
- name: "Change permissions of the log files"
if: always()
run: |
sudo chown $USER:$USER /tmp/logs
- name: "Upload log files"
if: always()
uses: actions/[email protected]
with:
name: packer-proxmox-${{ matrix.proxmox_version }} logs
path: /tmp/logs