ansible-playbooks/system/bootloader.ansible.yml
2025-05-01 22:20:09 +02:00

74 lines
2.8 KiB
YAML

- hosts: localhost
vars_files:
- ../map.yml
tasks:
- name: "system/bootloader : Install grub, mkinitfs, efibootmgr"
package:
name:
- grub
- grub-efi
- mkinitfs
- mkinitfs-doc
- efibootmgr
state: present
- name: "system/bootloader : Get current timestamp"
shell: |
CURRENT_SUBVOLUME=$(LC_ALL=C btrfs sub show / | LC_ALL=C grep Name: | tr -d '[:space:]'); TIMESTAMP_FORMAT='[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}_[[:digit:]]{2}-[[:digit:]]{2}-[[:digit:]]{2}'; echo "$CURRENT_SUBVOLUME" | grep -Eo "$TIMESTAMP_FORMAT"
register: CURRENT_SUBVOLUME_TIMESTAMP
run_once: true
- name: "system/bootloader : Get current timestamp human"
shell: |
CURRENT_SUBVOLUME_TIMESTAMP='{{ CURRENT_SUBVOLUME_TIMESTAMP.stdout }}'; echo "${CURRENT_SUBVOLUME_TIMESTAMP:0:10} ${CURRENT_SUBVOLUME_TIMESTAMP:11:2}:${CURRENT_SUBVOLUME_TIMESTAMP:14:2}"
register: CURRENT_SUBVOLUME_TIMESTAMP_HUMAN
run_once: true
- name: "system/bootloader : Get current kernel version"
shell: |
uname -r
register: KERNEL_VERSION
run_once: true
- name: "system/bootloader : Add features to mkinitfs config"
lineinfile:
path: "/etc/mkinitfs/mkinitfs.conf"
regexp: "^features.?=.?"
line: features="ata base btrfs keymap kms mmc nvme scsi usb virtio"
owner: root
group: root
mode: "0644"
- name: "system/bootloader : Generate os-release file"
template:
src: files/bootloader_os-release.j2
dest: "/etc/os-release"
owner: root
group: root
mode: "0644"
vars:
OS_VERSION: "{{ release_version }}"
OS_RELEASE_INFO: '"Timestamp: {{ CURRENT_SUBVOLUME_TIMESTAMP_HUMAN.stdout }} | Kernel: {{ KERNEL_VERSION.stdout }}"'
- name: "system/bootloader : Create motd directory"
file:
name: /etc/motd.d
owner: root
group: root
mode: "0755"
state: directory
- name: "system/bootloader : Place Noveria motd file in motd directory"
template:
src: files/bootloader_00_noveria.motd.j2
dest: /etc/motd.d/00_noveria.motd
owner: root
group: root
mode: "0644"
vars:
OS_NAME: "Novos {{ release_version }}"
OS_RELEASE_INFO: "Timestamp: {{ CURRENT_SUBVOLUME_TIMESTAMP_HUMAN.stdout }} | Kernel: {{ KERNEL_VERSION.stdout }}"
OS_ISSUE_URL: "https://git.noveria.org/Novos/ISO/issues"
- name: "system/bootloader : Place issue file"
template:
src: files/bootloader_issue.j2
dest: /etc/issue
owner: root
group: root
mode: "0644"
vars:
OS_NAME: "Novos {{ release_version }}"
OS_RELEASE_INFO: "{{ CURRENT_SUBVOLUME_TIMESTAMP_HUMAN.stdout }}"