ansible-playbooks/system/bootloader.ansible.yml
2024-06-27 19:43:34 +02:00

74 lines
2.5 KiB
YAML

- hosts: localhost
vars_files:
- /map.yml
tasks:
- name: Install bootloader pkgs
package:
name:
- grub
- grub-efi
- mkinitfs
- mkinitfs-doc
- efibootmgr
state: present
- name: Get current timestamp
command: |
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: Get current timestamp human
command: |
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: Get current kernel version
command: |
uname -r
register: KERNEL_VERSION
run_once: true
- name: 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: os-release file
template:
src: files/bootloader_os-release.j2
dest: "/etc/os-release"
owner: root
group: root
mode: '0644'
vars:
OS_VERSION: "2406"
OS_RELEASE_INFO: '"Timestamp: {{ CURRENT_SUBVOLUME_TIMESTAMP_HUMAN.stdout }} | Kernel: {{ KERNEL_VERSION.stdout }}"'
- name: Motd Directory
file:
name: /etc/motd.d
owner: root
group: root
mode: '0755'
state: directory
- name: Motd
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 2406'
OS_RELEASE_INFO: 'Timestamp: {{ CURRENT_SUBVOLUME_TIMESTAMP_HUMAN.stdout }} | Kernel: {{ KERNEL_VERSION.stdout }}'
OS_ISSUE_URL: 'https://git.noveria.org/NoveriaOS/ISO/issues'
- name: Issue
template:
src: files/bootloader_issue.j2
dest: /etc/issue
owner: root
group: root
mode: '0644'
vars:
OS_NAME: 'Novos 2406'
OS_RELEASE_INFO: "{{ CURRENT_SUBVOLUME_TIMESTAMP_HUMAN.stdout }}"