WIP: nixos-anywhere for virtual machines
This commit is contained in:
parent
cc809942ef
commit
0bf113fa25
16 changed files with 282 additions and 7 deletions
15
terraform/modules/debian/files/cloud_init.cfg.tftpl
Normal file
15
terraform/modules/debian/files/cloud_init.cfg.tftpl
Normal file
|
@ -0,0 +1,15 @@
|
|||
#cloud-config
|
||||
hostname: "${hostname}"
|
||||
manage_etc_hosts: true
|
||||
disable_root: false
|
||||
|
||||
ssh_authorized_keys:
|
||||
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOodpLr+FDRyKyHjucHizNLVFHZ5AQmE9GmxMnOsSoaw pimkunis@thinkpadpim"
|
||||
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINUZp4BCxf7uLa1QWonx/Crf8tYZ5MKIZ+EuaBa82LrV user@user-laptop"
|
||||
|
||||
ssh_pwauth: false
|
||||
|
||||
# TODO: Do we need this?
|
||||
runcmd:
|
||||
- dhclient -r
|
||||
- dhclient
|
17
terraform/modules/debian/files/get_cert.sh
Executable file
17
terraform/modules/debian/files/get_cert.sh
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
eval "$(jq -r '@sh "PUBKEY=\(.pubkey) HOST=\(.host) CAHOST=\(.cahost) CASCRIPT=\(.cascript) CAKEY=\(.cakey)"')"
|
||||
|
||||
# TODO: Can this be done more eye-pleasingly?
|
||||
set +e
|
||||
CERT=$(ssh -o ConnectTimeout=3 -o ConnectionAttempts=1 root@$CAHOST '"'"$CASCRIPT"'" host "'"$CAKEY"'" "'"$PUBKEY"'" "'"$HOST"'".dmz')
|
||||
retval=$?
|
||||
set -e
|
||||
|
||||
if [ retval -neq 0 ]; then
|
||||
CERT=""
|
||||
fi
|
||||
|
||||
jq -n --arg cert "$CERT" '{"cert":$cert}'
|
9
terraform/modules/debian/files/network_config.cfg
Normal file
9
terraform/modules/debian/files/network_config.cfg
Normal file
|
@ -0,0 +1,9 @@
|
|||
version: 2
|
||||
ethernets:
|
||||
ens:
|
||||
match:
|
||||
name: ens*
|
||||
dhcp4: true
|
||||
routes:
|
||||
- to: 0.0.0.0/0
|
||||
via: 192.168.30.1
|
Reference in a new issue