libvirt_cloud/roles/ansible-gentoo_install/tasks/bootloader.yml

223 lines
7.4 KiB
YAML
Raw Normal View History

2023-12-29 19:40:31 +00:00
# -*- mode: yaml; indent-tabs-mode: nil; tab-width: 2; coding: utf-8-unix -*-
---
- name: "DEBUG: ansible-gentoo_install bootloader"
debug:
verbosity: 1
msg: "DEBUG: ansible-gentoo_install bootloader"
- name: test we are in the chroot
shell: |
2024-01-02 02:13:28 +00:00
df | grep {{AGI_install_disk}} && exit 1
2023-12-29 19:40:31 +00:00
check_mode: false
2024-01-02 02:13:28 +00:00
- name: install grub or syslinx
2023-12-29 19:40:31 +00:00
portage:
2024-01-02 02:13:28 +00:00
package: sys-boot/{{AGI_install_bootloader}}
2023-12-29 19:40:31 +00:00
state: installed
2024-01-02 02:13:28 +00:00
- block:
- name: setup syslinux
shell: |
[ -d /boot/syslinux ] || mkdir /boot/syslinux
[ ! -d /usr/share/syslinux/ ] || \
for elt in {{' '.join(AGI_install_syslinux_c32)}}; do
[ -f /boot/syslinux/$elt ] && continue
cp -np /usr/share/syslinux/$elt /boot/syslinux
done
exit 0
2024-01-08 12:51:06 +00:00
- name: setup syslinux.cfg
template: |
dest: /boot/syslinux/syslinux.cfg
src: boot/syslinux/syslinux.cfg
force: no
newline_sequence: '\r\n'
owner: root
mode: '0644'
2024-01-02 02:13:28 +00:00
- name: do syslinux install manually
shell: |
df | grep {{AGI_install_disk}} && \
echo ERROR: somethings wrong - {{AGI_install_disk}} isnt mounted
&& exit 1
# should unmount it?
dd if={{AGI_install_disk}}p1 count=440 bs=1|strings|grep SYSLINUX
[ $? -eq 0 ] && exit 0
echo HALT: YOU MUST INSTALL THE MBR YOURSELF - do this
echo dd if=/usr/share/syslinux/mbr.bin of={{AGI_install_disk}}p1 count=440 bs=1 conv=notrunc
echo HALT: YOU MUST INSTALL SYSLINUX YOURSELF - do this
syslinux -d syslinux --install {{AGI_install_disk}}p1
exit 999
register: syslinux_out
failed_when: false
- name: install syslinux install manually
fail:
msg: "HALT: install syslinux install manually"
when: syslinux_out.rc != 0
when: AGI_install_bootloader == 'syslinux'
- block:
- name: install grub to MBR
command: grub-install {{ AGI_install_disk }}
args:
creates: /boot/grub
- name: generate grub config
shell: grub-mkconfig -o /boot/grub/grub.cfg
args:
creates: /boot/grub/grub.cfg
- name: edit grub config
shell: |
[ -f /etc/default/grub.dst ] || cp -p /etc/default/grub /etc/default/grub.dst
a=$(cat /proc/cmdline | sed -e 's/ BOOT_IMAGE=[^ ]*/ /' \
-e 's/ initrd=[^ ]*/ /'
-e 's/ resume=[^ ]*/ /'
-e 's/ root=[^ ]*/ /')
sed -e "s/^#*GRUB_CMDLINE_LINUX=\"\"/GRUB_CMDLINE_LINUX=\"$a\"/" \
-i /etc/default/grub
grub-script-check /etc/default/grub
2024-01-05 11:12:55 +00:00
- name: roles/ansible-gentoo_install/tasks/
shell: |
LINE="rd.skipfsck=1 ipv6.disable=1 console=ttys0 lang=en keymap=us "
# LINE="$LINE pti=on doscsi iommu=pt amd_iommu=on debugfs=off efi=disable_early_pci_dma extra_latent_entropy init_on_free=1 kvm.nx_huge_pages=force l1tf=full,force mce=0 mds=full,nosmt nosmt=force page_alloc.shuffle=1 pti=on random.trust_cpu=off slab_nomerge slub_debug=FZ spec_store_bypass_disable=on spectre_v2=on tsx_async_abort=full,nosmt vsyscall=none "
LINE="$LINE intel_iommu=on vga=0x315 text
df | grep /boot || mount /dev/vda1 /boot
[ -d /boot/grub ] || exit 2
[ -f /boot/grub/grub.cfg ] || exit 3
cd /
# boot/initramfs-pentoo-x86_64-6.1.52-pentoo_2023_09_30.img
- name: /etc/default/grub
lineinfile:
dest: /etc/default/grub
line: '{{item.from}}="{{item.to}}"'
regexp: '^#*{{item.from}}=.*'
2024-01-08 12:51:06 +00:00
owner: root
mode: '0644'
2024-01-05 11:12:55 +00:00
with_items:
# Append parameters to the linux kernel command line for non-recovery entries
- from: GRUB_CMDLINE_LINUX_DEFAULT
to: " rd.skipfsck=1 ipv6.disable=1 console=ttyS0 lang=en keymap=us intel_iommu=on vga=0x315 text"
# The resolution used on graphical terminal.
# Note that you can use only modes which your graphic card supports via VBE.
# You can see them in real GRUB with the command `vbeinfo'.
- from: GRUB_GFXMODE
to: 640x480
# Set to 'text' to force the Linux kernel to boot in normal text
- from: GRUB_GFXPAYLOAD_LINUX
to: text
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to kernel
- from: GRUB_DISABLE_LINUX_UUID
to: true
2024-02-02 09:09:08 +00:00
- name: grub.cfg from roles/ansible-gentoo_install/tasks/
shell: |
LINE="{{' '.join(AGI_install_syslinux_kernel_line)}}"
# LINE="$LINE pti=on doscsi iommu=pt amd_iommu=on debugfs=off efi=disable_early_pci_dma extra_latent_entropy init_on_free=1 kvm.nx_huge_pages=force l1tf=full,force mce=0 mds=full,nosmt nosmt=force page_alloc.shuffle=1 pti=on random.trust_cpu=off slab_nomerge slub_debug=FZ spec_store_bypass_disable=on spectre_v2=on tsx_async_abort=full,nosmt vsyscall=none "
grep /boot /etc/fstab || exit 1
df | grep /boot || mount /boot || exit 2
[ -d /boot/grub ] || exit 3
[ -f /boot/grub/grub.cfg ] || exit 4
[ -f /boot/grub/grub.cfg.dst ] || cp -p /boot/grub/grub.cfg /boot/grub/grub.cfg.dst
sed -e 's@ ro *$@ '"$LINE"' ro@' -i /boot/grub/grub.cfg
ignore_errors: true
2024-01-08 12:51:06 +00:00
2024-02-02 09:09:08 +00:00
when: AGI_install_bootloader == 'grub:2'
2024-01-02 02:13:28 +00:00
2023-12-29 19:40:31 +00:00
- name: fstab root
lineinfile:
dest: /etc/fstab
line: '{{AGI_container_disk}}3 / ext4 defaults,noatime 0 1'
regexp: '^{{AGI_container_disk}}3'
2024-01-08 12:51:06 +00:00
owner: root
mode: '0644'
2023-12-29 19:40:31 +00:00
- name: fstab boot
lineinfile:
dest: /etc/fstab
line: '{{AGI_container_disk}}1 /boot ext3 defaults,noatime 0 1'
regexp: '^{{AGI_container_disk}}3'
2024-01-08 12:51:06 +00:00
owner: root
mode: '0644'
2023-12-29 19:40:31 +00:00
- name: fstab swap
lineinfile:
dest: /etc/fstab
line: '{{AGI_container_disk}}2 none swap nofail,sw 0 0'
regexp: '^{{AGI_container_disk}}2'
2024-01-08 12:51:06 +00:00
owner: root
mode: '0644'
2023-12-29 19:40:31 +00:00
- name: fstab shm
lineinfile:
dest: /etc/fstab
line: 'tmpfs /run/shm tmpfs defaults,noexec,size=5% 0 0'
regexp: '^tmpfs */run/shm'
2024-01-08 12:51:06 +00:00
owner: root
mode: '0644'
2023-12-29 19:40:31 +00:00
# linuxPen19 /mnt/linuxPen19 virtiofs defaults,dirsync 0 0
- name: /etc/security/passwdqc.conf
lineinfile:
dest: /etc/security/passwdqc.conf
line: 'enforce=none'
regexp: '^enforce=.*'
2024-01-08 12:51:06 +00:00
owner: root
mode: '0644'
2023-12-29 19:40:31 +00:00
- name: /etc/security/passwdqc.conf
lineinfile:
dest: /etc/security/passwdqc.conf
line: 'enforce=none'
regexp: '^enforce=.*'
2024-01-08 12:51:06 +00:00
owner: root
mode: '0644'
2023-12-29 19:40:31 +00:00
- name: /etc/conf.d/consolefont
lineinfile:
dest: /etc/conf.d/consolefont
line: 'consolefont="ter-v{{AGI_consolefont_font_size}}b"'
regexp: '^consolefont=.*'
2024-01-08 12:51:06 +00:00
owner: root
mode: '0644'
2024-01-05 11:12:55 +00:00
2023-12-29 19:40:31 +00:00
- name: consolefont
shell: |
2024-01-05 11:12:55 +00:00
grep -q /etc/init.d/consolefont /etc/rc.local || \
cat >> /etc/rc.local << EOF
#!/bin/sh
2023-12-29 19:40:31 +00:00
/etc/init.d consolefont stop
/etc/init.d consolefont start
2024-01-05 11:12:55 +00:00
# these are right for ter-v28b consolefont
if tty|grep -q /dev/ttyS0 ; then
2024-01-08 12:51:06 +00:00
stty cols 80 rows 34
2024-01-05 11:12:55 +00:00
elif tty|grep -q /dev/tty[1-6] ; then
stty cols 80 rows 22
fi
2023-12-29 19:40:31 +00:00
EOF
2024-01-05 11:12:55 +00:00
chmod 755 /etc/rc.local
2023-12-29 19:40:31 +00:00
ignore_errors: true
2023-12-30 22:09:49 +00:00
2023-12-29 19:40:31 +00:00
- name: rc-update add bootlogd boot
shell: |
2024-01-05 11:12:55 +00:00
[ -d /etc/modules-load.d ] || mkdir /etc/modules-load.d
[ -f /etc/modules-load.d/virtio.conf ] || \
echo "{{'\n'.join(AGI_bootstrap_modules)}}" \
> /etc/modules-load.d/virtio.conf
2024-01-02 02:13:28 +00:00
rc-update add consolefont
2023-12-29 19:40:31 +00:00
rc-update | grep -q 'bootlogd .* boot' || \
rc-update add bootlogd boot
2024-01-05 11:12:55 +00:00
grep -q '^s0:' /etc/inittab || \
sed -e 's/^#s0:/s0:/' /etc/inittab
2023-12-29 19:40:31 +00:00
exit 0
2024-01-05 11:12:55 +00:00