install debootstrap hooks
This commit is contained in:
parent
ba9b005829
commit
e9ef837381
@ -54,7 +54,7 @@ instance_debootstrap:
|
||||
- name: default
|
||||
arch: amd64
|
||||
suite: bookworm
|
||||
extra_pkgs: "acpi-support-base,udev,linux-image-amd64,sudo,vim,grub-pc,openssh-server"
|
||||
extra_pkgs: "linux-image-amd64"
|
||||
|
||||
rapi:
|
||||
- name: admin
|
||||
|
21
roles/node/files/ganeti/instance-debootstrap/hooks/clear-root-password
Executable file
21
roles/node/files/ganeti/instance-debootstrap/hooks/clear-root-password
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
# Make sure we're not working on the root directory
|
||||
if [ -z "$TARGET" -o "$TARGET" = "/" ]; then
|
||||
echo "Invalid target directory '$TARGET', aborting." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$(mountpoint -d /)" = "$(mountpoint -d "$TARGET")" ]; then
|
||||
echo "The target directory seems to be the root dir, aborting." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Disable root's password, as the switch to enable shadow by default
|
||||
# has left root with a disabled password, preventing the initial login
|
||||
echo "Disabling root's password"
|
||||
chroot "$TARGET" passwd -d root
|
||||
|
||||
exit 0
|
57
roles/node/files/ganeti/instance-debootstrap/hooks/grub-pc
Executable file
57
roles/node/files/ganeti/instance-debootstrap/hooks/grub-pc
Executable file
@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This is an example script that install and configure grub after installation.
|
||||
# To use it put it in your CUSTOMIZE_DIR and make it executable.
|
||||
#
|
||||
# Do not include grub in EXTRA_PKGS of
|
||||
# $sysconfdir/default/ganeti-instance-debootstrap because it will
|
||||
# cause error of debootstrap.
|
||||
|
||||
set -e
|
||||
|
||||
. common.sh
|
||||
|
||||
CLEANUP=( )
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
if [ -z "$TARGET" -o ! -d "$TARGET" ]; then
|
||||
echo "Missing target directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# install grub
|
||||
export LANG=C
|
||||
if [ "$PROXY" ]; then
|
||||
export http_proxy="$PROXY"
|
||||
export https_proxy="$PROXY"
|
||||
fi
|
||||
|
||||
umount_sys_fuse()
|
||||
{
|
||||
umount $TARGET/sys/fs/fuse/connections 2>/dev/null || true
|
||||
}
|
||||
|
||||
mount --bind /dev $TARGET/dev
|
||||
CLEANUP+=("umount $TARGET/dev")
|
||||
mount --bind /proc $TARGET/proc
|
||||
CLEANUP+=("umount $TARGET/proc")
|
||||
mount --bind /sys $TARGET/sys
|
||||
CLEANUP+=("umount $TARGET/sys")
|
||||
CLEANUP+=("umount_sys_fuse")
|
||||
|
||||
DEBIAN_FRONTEND=noninteractive chroot "$TARGET" apt-get -y install grub-pc grub-common
|
||||
|
||||
echo "(hd0) $BLOCKDEV" > $TARGET/boot/grub/device.map
|
||||
CLEANUP+=("rm $TARGET/boot/grub/device.map")
|
||||
|
||||
chroot "$TARGET" sed -Ei 's/^(GRUB_CMDLINE_LINUX=\".*)\"$/\1 net.ifnames=0"/' /etc/default/grub
|
||||
chroot "$TARGET" grub-install "(hd0)"
|
||||
GRUB_DISABLE_OS_PROBER=true chroot "$TARGET" update-grub
|
||||
echo 'grub-pc grub-pc/install_devices multiselect /dev/xvda' | chroot "$TARGET" debconf-set-selections
|
||||
|
||||
# execute cleanups
|
||||
cleanup
|
||||
trap - EXIT
|
||||
|
||||
exit 0
|
@ -10,3 +10,16 @@
|
||||
src: etc-ganeti-instance-debootstrap-variants.list.j2
|
||||
dest: "/etc/ganeti/instance-debootstrap/variants.list"
|
||||
mode: "0644"
|
||||
|
||||
- name: Install hooks
|
||||
ansible.builtin.copy:
|
||||
src: ganeti/
|
||||
dest: /etc/ganeti
|
||||
mode: "0755"
|
||||
|
||||
- name: Fix hook permissions
|
||||
ansible.builtin.file:
|
||||
path: "/etc/ganeti/instance-debootstrap/hooks/"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
recurse: true
|
||||
|
@ -20,3 +20,7 @@
|
||||
ansible.builtin.file:
|
||||
path: /etc/ganeti/vnc-cluster-password
|
||||
mode: "0644"
|
||||
|
||||
- name: Include debootstrap
|
||||
ansible.builtin.include_tasks:
|
||||
file: debootstrap.yml
|
@ -30,10 +30,6 @@
|
||||
ansible.builtin.include_tasks:
|
||||
file: keys.yml
|
||||
|
||||
- name: Configure debootstrap
|
||||
ansible.builtin.include_tasks:
|
||||
file: debootstrap.yml
|
||||
|
||||
- name: Configure Ganeti
|
||||
ansible.builtin.include_tasks:
|
||||
file: ganeti.yml
|
||||
|
Loading…
Reference in New Issue
Block a user