diff --git a/proxmox/terraform/README.md b/proxmox/terraform/README.md --- a/proxmox/terraform/README.md +++ b/proxmox/terraform/README.md @@ -4,8 +4,6 @@ a (non-official so far) plugin, we can provision vm the same way for our rocq infra (proxmox) -# The road so far - ## Prepare workstation See prepare-workstation.md @@ -25,7 +23,7 @@ source setup.sh ``` -## provision new vm +## provision infra ``` terraform init @@ -34,11 +32,14 @@ # Details -The provisioning is bootstraping vm declared in ".tf" files. It's using a base -template (debian-9-template, debian-10-template) installed in the hypervisor. -Instructions are detailed in the `init-template.md` file. +The provisioning is bootstraping vms declared in ".tf" files (in dependency +order if any). + +It's using a base template (either debian-9-template, debian-10-template) +installed in the hypervisor. Instructions are detailed in the +`init-template.md` file. -# Init +## Init This initializes your local copy with the necessary: @@ -46,16 +47,15 @@ terraform init ``` -# Plan changes +## Plan changes -Compulse all *.tf files present in the folder, then compute a -differential plan: +Parse all *.tf files present in the folder, then compute a differential plan: ``` terraform plan ``` -# Apply changes +## Apply changes Propose to apply the plan to the infra (interactively): diff --git a/proxmox/terraform/init-template.md b/proxmox/terraform/init-template.md --- a/proxmox/terraform/init-template.md +++ b/proxmox/terraform/init-template.md @@ -39,11 +39,8 @@ ./init-template.sh 9 ``` -This created a basic vm with basic login/pass as root/test so we can -connect to it. - -Note: Implementation wise, this uses an openstack debian image, -cloud-init ready [1] +This created a basic debian-9 vm (based on the cloud-stack one [1]). We still +need to connect to it to adapt it prior to make it a template (cf. below). [1] https://cdimage.debian.org/cdimage/openstack/ @@ -63,9 +60,22 @@ qm start 9000 ``` -### Checks +### Connect + + +#### ssh + +``` +ssh root@192.168.100.199 +``` + +Note: +Public/Private Keys are stored in the credential store (`pass ls +operations/terraform-proxmox/ssh-key`). -Login through the console web-ui: +#### proxmox console webui + +Providing you set it a "cipassword" and reboot the vm first: - accessible from - View \`datacenter\` @@ -74,7 +84,8 @@ - click the \`console\` menu. - log in as root/test password -Checks: + +### Checks - kernel linux version - debian release diff --git a/proxmox/terraform/init-template.sh b/proxmox/terraform/init-template.sh --- a/proxmox/terraform/init-template.sh +++ b/proxmox/terraform/init-template.sh @@ -1,5 +1,10 @@ #!/usr/bin/env bash +# This scripts automates the vm build to from a cloud-init ready image We can +# then connect to it through its $TMP_IP and adapt the vm the way we want it +# prior to make it a template. +# When satisfied with the vm, execute: `qm template ` + set -x set -e @@ -7,6 +12,8 @@ NAME="template-debian-${VERSION}" IMG="debian-$VERSION/debian-$VERSION-openstack-amd64.qcow2" +TMP_IP=${2-"192.168.100.199"} + VM_ID="${VERSION}000" VM_DISK="vm-$VM_ID-disk-0" @@ -30,7 +37,7 @@ # cloud init temporary setup qm set $VM_ID --ciuser root -qm set $VM_ID --ipconfig0 "ip=192.168.100.125/24,gw=192.168.100.1" +qm set $VM_ID --ipconfig0 "ip=${TMP_IP}/24,gw=192.168.100.1" qm set $VM_ID --nameserver "192.168.100.29" SSH_KEY_PUB=$HOME/.ssh/proxmox-ssh-key.pub diff --git a/proxmox/terraform/prepare-workstation.md b/proxmox/terraform/prepare-workstation.md --- a/proxmox/terraform/prepare-workstation.md +++ b/proxmox/terraform/prepare-workstation.md @@ -14,7 +14,7 @@ make make install -# Install so that terrafor actually sees the plugin +# Install so that terraform actually sees the plugin mkdir -p ~/.terraform.d/plugins/linux_amd64 cp -v ./bin/* ~/.terraform.d/plugins/linux_amd64/ ```