Terraform

From UVOO Tech Wiki
Jump to navigation Jump to search

One source of config for many providers

https://www.techbeatly.com/terraform-cheat-sheet/

https://www.2ndwatch.com/blog/how-we-organize-terraform-code-at-2nd-watch/

Terraform Providers

https://jonathan.bergknoff.com/journal/terraform-pain-points/

Terraform 3rd-Party Providers

terraform-provider-libvirt

Basic Base Buster Prep Script

#!/bin/bash
# For Base install of Ubuntu Bionic or Debian Buster.
set -exo pipefail
TERRAFORM_VERSION="0.11.11"

# Prep with gitlab-runner
# curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
# sudo gitlab-runner register

sudo apt-get install -y qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virt-manager
sudo apt-get install -y golang-go libvirt-dev unzip

echo "security_driver=\"none\"" >> /etc/libvirt/qemu.conf
sudo systemctl restart libvirt-bin
# ref: https://github.com/dmacvicar/terraform-provider-libvirt/commit/22f096d9 

cd /tmp
wget https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip
unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip
cp terraform /usr/local/bin/

sudo -iu gitlab-runner -- <<EOF
cd /tmp
go get github.com/dmacvicar/terraform-provider-libvirt
go install github.com/dmacvicar/terraform-provider-libvirt
sudo -u gitlab-runner mkdir -p ~/.terraform.d
cp ~/go/bin/terraform-provider-libvirt ~/.terraform.d/
EOF

USER="gitlab-runner"
sudo adduser $USER sudo
sudo adduser $USER libvirt

terraform-provider-libvirt Issues or Quirks

echo "security_driver=\"none\"" >> /etc/libvirt/qemu.conf 
sudo systemctl restart libvirt-bin

Disabling vm guest security without modifying security profile updates

To disable sVirt, and revert to the basic level of SELinux protection (host protection only), the /etc/libvirt/qemu.conf file can be used to change the setting to security_driver="none"

To disable sVirt, and revert to the basic level of AppArmor protection (host protection only), the /etc/libvirt/qemu.conf file can be used to change the setting to security_driver="none".

Source

Other HowTos