summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2020-10-30 13:57:03 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2020-11-10 10:52:44 +0100
commit81b451f1bd2d4885be56cac928be86ca27ef4d3d (patch)
tree8250a55d18ab06dfea427e77fa88e4aeac8151a2
parent032a4eece0c72a8111efda04766770de93b34cf8 (diff)
downloadinfra-81b451f1bd2d4885be56cac928be86ca27ef4d3d.tar.gz
infra-81b451f1bd2d4885be56cac928be86ca27ef4d3d.tar.bz2
infra-81b451f1bd2d4885be56cac928be86ca27ef4d3d.tar.xz
infra-81b451f1bd2d4885be56cac928be86ca27ef4d3d.zip
hash: virt setup.
-rw-r--r--ansible/inventory-pub.yml10
-rw-r--r--hash/debian10/generate-scripts.yml44
-rw-r--r--hash/debian10/preseed.cfg.j286
-rw-r--r--hash/debian10/vimscore-4/authorized_keys2
-rw-r--r--hash/debian10/vimscore-4/preseed.cfg86
-rwxr-xr-xhash/debian10/vimscore-4/run-install16
6 files changed, 244 insertions, 0 deletions
diff --git a/ansible/inventory-pub.yml b/ansible/inventory-pub.yml
new file mode 100644
index 0000000..2a88d9a
--- /dev/null
+++ b/ansible/inventory-pub.yml
@@ -0,0 +1,10 @@
+all:
+ hosts:
+ knot:
+ ansible_host: trygvis.io
+ birgitte:
+ ansible_host: vs.trygvis.io
+ arius:
+ ansible_host: arius.trygvis.io
+ akili:
+ ansible_host: localhost
diff --git a/hash/debian10/generate-scripts.yml b/hash/debian10/generate-scripts.yml
new file mode 100644
index 0000000..be2976c
--- /dev/null
+++ b/hash/debian10/generate-scripts.yml
@@ -0,0 +1,44 @@
+- hosts: localhost
+ connection: local
+ vars:
+ vm_name: vimscore-4
+ vm_domain: vimscore.com
+ authorized_keys:
+ - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBz/VF9JwHdlYbxoU25UONod8/lB7J81WKXkgcHIZ5up trygvis@hash
+ tasks:
+ - file:
+ path: "{{ vm_name }}"
+ state: directory
+
+ - copy:
+ dest: "{{ vm_name }}/run-install"
+ mode: a+rx
+ content: |
+ #!/bin/bash
+ name={{ vm_name }}
+ virt-install -n "$name" \
+ --memory {{ memory|default(2048) }} \
+ --vcpus=1 \
+ --os-variant=debian10 \
+ --disk path=/var/lib/libvirt/images/"${name}".qcow2,size=10 \
+ --location http://deb.debian.org/debian/dists/stable/main/installer-amd64/ \
+ --extra-args "hostname=${name} interface=auto " \
+ --network network=default \
+ --noautoconsole \
+ --initrd-inject=authorized_keys \
+ --initrd-inject=preseed.cfg \
+ -v \
+ --debug \
+ 2>&1 | tee virt.txt
+
+ - template:
+ dest: "{{ vm_name }}/preseed.cfg"
+ src: preseed.cfg.j2
+
+ - copy:
+ dest: "{{ vm_name }}/authorized_keys"
+ content: |
+ # Generated for virt-install
+ {% for key in authorized_keys %}
+ {{ key }}
+ {% endfor %}
diff --git a/hash/debian10/preseed.cfg.j2 b/hash/debian10/preseed.cfg.j2
new file mode 100644
index 0000000..c262089
--- /dev/null
+++ b/hash/debian10/preseed.cfg.j2
@@ -0,0 +1,86 @@
+#_preseed_V1
+#
+# https://www.debian.org/releases/stable/amd64/apbs04.en.html
+#
+
+d-i debian-installer/country string NO
+d-i debian-installer/keymap select no
+d-i debian-installer/language string en_US:en
+d-i debian-installer/locale string en_US
+
+#d-i localechooser/supported-locales string en_US.UTF-8 nb_NO.UTF-8
+
+d-i keyboard-configuration/layoutcode string no
+d-i keyboard-configuration/variantcode string
+d-i keyboard-configuration/xkb-keymap select no
+
+d-i netcfg/choose_interface select auto
+
+d-i netcfg/get_hostname string {{ vm_hostname|default(vm_name) }}
+d-i netcfg/get_domain string {{ vm_domain }}
+d-i netcfg/hostname string {{ vm_hostname|default(vm_name) }}.{{ vm_domain }}
+
+d-i mirror/country string manual
+d-i mirror/protocol string http
+d-i mirror/http/directory string /debian
+d-i mirror/http/hostname string deb.debian.org
+d-i mirror/http/proxy string
+d-i mirror/suite string stable
+
+d-i hw-detect/load_firmware boolean false
+d-i netcfg/wireless_wep string
+
+# A literal "!" disabled the password for root/the user. Can be hard-coded with a crypt(3) hash.
+d-i passwd/root-login boolean false
+d-i passwd/root-password-crypted password !
+
+d-i passwd/make-user boolean false
+
+d-i passwd/user-fullname string Foo
+d-i passwd/username string foo
+d-i passwd/user-password string foo
+d-i passwd/user-password-again string foo
+#d-i passwd/user-password-crypted password !
+
+d-i time/zone string Europe/Oslo
+d-i clock-setup/ntp boolean true
+
+d-i partman-auto/method string regular
+#d-i partman-auto-lvm/guided_size string max
+d-i partman-auto/choose_recipe select atomic
+
+# https://www.bishnet.net/tim/blog/2015/01/29/understanding-partman-autoexpert_recipe/
+# https://github.com/xobs/debian-installer/blob/master/doc/devel/partman-auto-recipe.txt
+# One single, huge partition. No swap.
+d-i partman-auto/expert_recipe string \
+ root :: \
+ 1024 1000000000 -1 ext4 \
+ $primary{ } $bootable{ } \
+ method{ format } format{ } \
+ use_filesystem{ } filesystem{ ext4 } \
+ mountpoint{ / } \
+ .
+d-i partman-basicfilesystems/no_swap boolean false
+
+d-i partman-partitioning/confirm_write_new_label boolean true
+d-i partman/choose_partition select finish
+d-i partman/confirm boolean true
+d-i partman/confirm_nooverwrite boolean true
+
+popularity-contest popularity-contest/participate boolean true
+tasksel tasksel/first multiselect standard, ssh-server
+
+d-i base-installer/install-recommends boolean false
+d-i apt-setup/non-free boolean true
+d-i apt-setup/contrib boolean true
+
+#d-i grub-installer/only_debian boolean true
+#d-i grub-installer/with_other_os boolean true
+d-i grub-installer/bootdev string default
+
+d-i finish-install/keep-consoles boolean true
+d-i finish-install/reboot_in_progress note
+
+d-i preseed/late_command string \
+ mkdir /target/root/.ssh ;\
+ cp /authorized_keys /target/root/.ssh/
diff --git a/hash/debian10/vimscore-4/authorized_keys b/hash/debian10/vimscore-4/authorized_keys
new file mode 100644
index 0000000..a78e63c
--- /dev/null
+++ b/hash/debian10/vimscore-4/authorized_keys
@@ -0,0 +1,2 @@
+# Generated for virt-install
+ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBz/VF9JwHdlYbxoU25UONod8/lB7J81WKXkgcHIZ5up trygvis@hash
diff --git a/hash/debian10/vimscore-4/preseed.cfg b/hash/debian10/vimscore-4/preseed.cfg
new file mode 100644
index 0000000..143c943
--- /dev/null
+++ b/hash/debian10/vimscore-4/preseed.cfg
@@ -0,0 +1,86 @@
+#_preseed_V1
+#
+# https://www.debian.org/releases/stable/amd64/apbs04.en.html
+#
+
+d-i debian-installer/country string NO
+d-i debian-installer/keymap select no
+d-i debian-installer/language string en_US:en
+d-i debian-installer/locale string en_US
+
+#d-i localechooser/supported-locales string en_US.UTF-8 nb_NO.UTF-8
+
+d-i keyboard-configuration/layoutcode string no
+d-i keyboard-configuration/variantcode string
+d-i keyboard-configuration/xkb-keymap select no
+
+d-i netcfg/choose_interface select auto
+
+d-i netcfg/get_hostname string vimscore-4
+d-i netcfg/get_domain string vimscore.com
+d-i netcfg/hostname string vimscore-4.vimscore.com
+
+d-i mirror/country string manual
+d-i mirror/protocol string http
+d-i mirror/http/directory string /debian
+d-i mirror/http/hostname string deb.debian.org
+d-i mirror/http/proxy string
+d-i mirror/suite string stable
+
+d-i hw-detect/load_firmware boolean false
+d-i netcfg/wireless_wep string
+
+# A literal "!" disabled the password for root/the user. Can be hard-coded with a crypt(3) hash.
+d-i passwd/root-login boolean false
+d-i passwd/root-password-crypted password !
+
+d-i passwd/make-user boolean false
+
+d-i passwd/user-fullname string Foo
+d-i passwd/username string foo
+d-i passwd/user-password string foo
+d-i passwd/user-password-again string foo
+#d-i passwd/user-password-crypted password !
+
+d-i time/zone string Europe/Oslo
+d-i clock-setup/ntp boolean true
+
+d-i partman-auto/method string regular
+#d-i partman-auto-lvm/guided_size string max
+d-i partman-auto/choose_recipe select atomic
+
+# https://www.bishnet.net/tim/blog/2015/01/29/understanding-partman-autoexpert_recipe/
+# https://github.com/xobs/debian-installer/blob/master/doc/devel/partman-auto-recipe.txt
+# One single, huge partition. No swap.
+d-i partman-auto/expert_recipe string \
+ root :: \
+ 1024 1000000000 -1 ext4 \
+ $primary{ } $bootable{ } \
+ method{ format } format{ } \
+ use_filesystem{ } filesystem{ ext4 } \
+ mountpoint{ / } \
+ .
+d-i partman-basicfilesystems/no_swap boolean false
+
+d-i partman-partitioning/confirm_write_new_label boolean true
+d-i partman/choose_partition select finish
+d-i partman/confirm boolean true
+d-i partman/confirm_nooverwrite boolean true
+
+popularity-contest popularity-contest/participate boolean true
+tasksel tasksel/first multiselect standard, ssh-server
+
+d-i base-installer/install-recommends boolean false
+d-i apt-setup/non-free boolean true
+d-i apt-setup/contrib boolean true
+
+#d-i grub-installer/only_debian boolean true
+#d-i grub-installer/with_other_os boolean true
+d-i grub-installer/bootdev string default
+
+d-i finish-install/keep-consoles boolean true
+d-i finish-install/reboot_in_progress note
+
+d-i preseed/late_command string \
+ mkdir /target/root/.ssh ;\
+ cp /authorized_keys /target/root/.ssh/
diff --git a/hash/debian10/vimscore-4/run-install b/hash/debian10/vimscore-4/run-install
new file mode 100755
index 0000000..2b76c64
--- /dev/null
+++ b/hash/debian10/vimscore-4/run-install
@@ -0,0 +1,16 @@
+#!/bin/bash
+name=vimscore-4
+virt-install -n "$name" \
+ --memory 2048 \
+ --vcpus=1 \
+ --os-variant=debian10 \
+ --disk path=/var/lib/libvirt/images/"${name}".qcow2,size=10 \
+ --location http://deb.debian.org/debian/dists/stable/main/installer-amd64/ \
+ --extra-args "hostname=${name} interface=auto " \
+ --network network=default \
+ --noautoconsole \
+ --initrd-inject=authorized_keys \
+ --initrd-inject=preseed.cfg \
+ -v \
+ --debug \
+ 2>&1 | tee virt.txt