mirror of
https://github.com/Noratrieb/vmlab.git
synced 2026-01-14 16:45:11 +01:00
things
This commit is contained in:
parent
c27807e86f
commit
64cb1dd6df
7 changed files with 39 additions and 5 deletions
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"ansible.python.interpreterPath": "/etc/profiles/per-user/nils/bin/python"
|
||||||
|
}
|
||||||
6
ansible/debian.yml
Normal file
6
ansible/debian.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
- name: Install Debian
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
roles:
|
||||||
|
- update
|
||||||
6
ansible/roles/update/tasks/main.yml
Normal file
6
ansible/roles/update/tasks/main.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
- name: Update
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
|
- name: Upgrade
|
||||||
|
ansible.builtin.apt:
|
||||||
|
upgrade: true
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
DIR="$(dirname "$(realpath "$0")")"
|
|
||||||
|
|
||||||
NAME="$1"
|
NAME="$1"
|
||||||
|
|
||||||
mkdir -p tmp
|
mkdir -p tmp
|
||||||
|
|
@ -33,11 +31,20 @@ virt-install -n "$NAME" \
|
||||||
--import --disk "path=$DISK,bus=virtio" \
|
--import --disk "path=$DISK,bus=virtio" \
|
||||||
--network network=default,model=virtio \
|
--network network=default,model=virtio \
|
||||||
--graphics=none --rng /dev/urandom \
|
--graphics=none --rng /dev/urandom \
|
||||||
"--cloud-init=user-data=$DIR/user-data,meta-data=$meta_data" \
|
"--cloud-init=user-data=user-data,meta-data=$meta_data" \
|
||||||
--noautoconsole
|
--noautoconsole
|
||||||
|
|
||||||
rm "$meta_data"
|
rm "$meta_data"
|
||||||
|
|
||||||
echo "Successfully created $NAME"
|
echo "Successfully created $NAME"
|
||||||
|
|
||||||
virsh domifaddr "$NAME"
|
until virsh domifaddr "$NAME" | grep ipv4 >/dev/null; do
|
||||||
|
echo "waiting for VM to start up and get an IP"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
ip=$(virsh domifaddr "$NAME" | grep ipv4 | awk '{print $4}' | cut -d/ -f1)
|
||||||
|
|
||||||
|
echo "IP: $ip"
|
||||||
|
|
||||||
|
echo "$ip" >> vm-state/inventory.ini
|
||||||
7
init.sh
Normal file
7
init.sh
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
mkdir -p vm-state
|
||||||
|
|
||||||
|
cat >vm-state/inventory-ini <<EOF
|
||||||
|
[myhosts]
|
||||||
|
EOF
|
||||||
5
install-vms-ansible.sh
Normal file
5
install-vms-ansible.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ansible-playbook -u chef -i vm-state/inventory.ini ansible/debian.yml
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
{ pkgs ? import <nixpkgs> { } }: pkgs.mkShell {
|
{ pkgs ? import <nixpkgs> { } }: pkgs.mkShell {
|
||||||
packages = with pkgs; [ debootstrap ];
|
packages = with pkgs; [ debootstrap ansible ansible-lint ];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue