tweaks for lint happiness

This commit is contained in:
Mark Riedesel 2024-11-22 13:32:30 -06:00
parent 5d78efcac5
commit c6f5d3546a
12 changed files with 128 additions and 104 deletions

View file

@ -1,2 +1,3 @@
--- ---
- import_playbook: playbooks/install.yaml - name: OS Install
import_playbook: playbooks/install.yaml

View file

@ -1,7 +0,0 @@
---
- hosts: all
become: true
tasks:
- name: Is this a livecd?
ansible.builtin.debug:
msg: "{{ ansible_nodename }} {{ ansible_nodename == 'archiso' }}"

View file

@ -4,8 +4,10 @@
ansible.builtin.command: "blkid {{ item }}" ansible.builtin.command: "blkid {{ item }}"
loop: "{{ base_efi_partitions | default([]) }}" loop: "{{ base_efi_partitions | default([]) }}"
register: blkid register: blkid
changed_when: false
- name: Format EFI partitions fat32 - name: Format EFI partitions fat32
ansible.builtin.command: "mkfs.vfat -v -F 32 -n EFI {{ item.item }}" ansible.builtin.command: "mkfs.vfat -v -F 32 -n EFI {{ item.item }}"
loop: "{{ blkid.results | rejectattr('stdout', 'contains', 'TYPE=\"vfat\"') }}" loop: "{{ blkid.results | rejectattr('stdout', 'contains', 'TYPE=\"vfat\"') }}"
register: mkfs_vfat_efi register: mkfs_vfat_efi
changed_when: true

View file

@ -1,17 +1,18 @@
--- ---
- name: Check for existing zroot zfs volume - name: Root ZFS Pool | Check for existing zroot zfs volume
ansible.builtin.command: zpool list -Ho name zroot ansible.builtin.command: zpool list -Ho name zroot
register: zroot_check register: zroot_check
changed_when: false
ignore_errors: true ignore_errors: true
- when: zroot_check.rc != 0 - name: Root ZFS Pool |
when: zroot_check.rc != 0
block: block:
- name: Initialize disk device to id table - name: Root ZFS Pool | initialize disk device to id table
ansible.builtin.set_fact: ansible.builtin.set_fact:
partition_device_to_ids: {} partition_device_to_ids: {}
- name: Create disk device to id table - name: Root ZFS Pool | create disk device -> id table
ansible.builtin.set_fact: ansible.builtin.set_fact:
partition_device_to_ids: >- partition_device_to_ids: >-
{{ {{
@ -20,10 +21,7 @@
}} }}
with_items: "{{ base_partitions_by_id | dict2items }}" with_items: "{{ base_partitions_by_id | dict2items }}"
- ansible.builtin.debug: - name: Root ZFS Pool | create zroot volume
var: base_root_partitions | map('extract', partition_device_to_ids) | map('first')
- name: Create zroot volume
become: true become: true
ansible.builtin.command: >- ansible.builtin.command: >-
zpool create -f -o ashift=12 zpool create -f -o ashift=12
@ -40,14 +38,16 @@
zroot {{ mirror }} {{ base_root_partitions | map('extract', partition_device_to_ids) | map('first') | list | join(' ') }} zroot {{ mirror }} {{ base_root_partitions | map('extract', partition_device_to_ids) | map('first') | list | join(' ') }}
vars: vars:
mirror: "{{ 'mirror' if base_root_partitions | length > 1 else '' }}" mirror: "{{ 'mirror' if base_root_partitions | length > 1 else '' }}"
- name: Create zroot/ROOT and zroot/DATA volumes changed_when: true
- name: Root ZFS Pool | create zroot/ROOT and zroot/DATA volumes
community.general.zfs: community.general.zfs:
name: "zroot/{{ item }}" name: "zroot/{{ item }}"
state: present state: present
register: zfs_zroot_root_volume register: zfs_zroot_root_volume
with_items: [ROOT, DATA] with_items: [ROOT, DATA]
- name: Create zroot/ROOT/arch - name: Root ZFS Pool | create zroot/ROOT/arch
community.general.zfs: community.general.zfs:
name: zroot/ROOT/arch name: zroot/ROOT/arch
state: present state: present
@ -56,14 +56,17 @@
mountpoint: / mountpoint: /
when: zfs_zroot_root_volume.changed when: zfs_zroot_root_volume.changed
- name: Create zroot/home - name: Root ZFS Pool | create zroot/DATA/home
community.general.zfs: community.general.zfs:
name: zroot/DATA/home name: zroot/DATA/home
state: present state: present
extra_zfs_properties: extra_zfs_properties:
mountpoint: /home mountpoint: /home
- name: Export zroot pool - name: Root ZFS Pool | Export zroot pool
ansible.builtin.command: zpool export zroot ansible.builtin.command: zpool export zroot
- name: Import zroot pool (-R /mnt) changed_when: false
- name: Root ZFS Pool | Import zroot pool (-R /mnt)
ansible.builtin.command: zpool import -R /mnt zroot -N ansible.builtin.command: zpool import -R /mnt zroot -N
changed_when: false

View file

@ -1,34 +1,27 @@
--- ---
- name: Get details about rootfs disks - name: Partition | get details about rootfs disks
community.general.parted: community.general.parted:
device: "{{ item }}" device: "{{ item }}"
unit: MiB unit: MiB
register: base_root_disks_info register: base_root_disks_info
loop: "{{ base_root_disks | list }}" loop: "{{ base_root_disks | list }}"
- name: partition | Ensure efi is not mounted - name: Partition | calculate maximum usable disk space
ansible.posix.mount:
path: /mnt/boot/efi
state: unmounted
- name: Calculate maximum usable disk space
ansible.builtin.set_fact: ansible.builtin.set_fact:
base_root_usable_mib: "{{ (base_root_disks_info.results | map(attribute='disk.size') | min | int) - 1 }}" base_root_usable_mib: "{{ (base_root_disks_info.results | map(attribute='disk.size') | min | int) - 1 }}"
- ansible.builtin.debug: - name: Partition | calculate disk utilization percentage
var: base_root_usable_mib
- name: Calculate disk utilization percentage
ansible.builtin.set_fact: ansible.builtin.set_fact:
base_root_usable_mib: "{{ base_root_usable_mib | int - ((base_root_usable_mib | float) * (0.01 * (base_root_free_percent | float))) | round(method='floor') | base_root_usable_mib: "{{ base_root_usable_mib | int - ((base_root_usable_mib | float) * (0.01 * (base_root_free_percent | float))) | round(method='floor') |
int }}" int }}"
- name: Calculate zfs volume size - name: Partition | calculate zroot ZFS pool size
ansible.builtin.set_fact: ansible.builtin.set_fact:
base_root_zpool_mib: "{{ base_root_usable_mib | int - fixed_size_partitions | int }}" base_root_zpool_mib: "{{ base_root_usable_mib | int - fixed_size_partitions | int }}"
vars: vars:
fixed_size_partitions: "{{ base_root_swap_mib | int + base_root_efi_mib | int }}" fixed_size_partitions: "{{ base_root_swap_mib | int + base_root_efi_mib | int }}"
# #
- name: Calculate partition layouts - name: Partition | calculate partition layouts
ansible.builtin.set_fact: ansible.builtin.set_fact:
partition_ranges: >- partition_ranges: >-
{{ {{
@ -48,17 +41,19 @@
- name: swap - name: swap
size_mib: "{{ base_root_swap_mib }}" size_mib: "{{ base_root_swap_mib }}"
- ansible.builtin.debug: - name: Partition | initialize partitioning facts
var: partition_ranges
- name: Initialize partition facts
ansible.builtin.set_fact: ansible.builtin.set_fact:
base_efi_partitions: [] base_efi_partitions: []
base_root_partitions: [] base_root_partitions: []
base_swap_partitions: [] base_swap_partitions: []
- name: Partition | ensure efi is not mounted
ansible.posix.mount:
path: /mnt/boot/efi
state: unmounted
#### efi/boot #### efi/boot
- name: Create EFI partition - name: Partition | create EFI boot partition
become: true become: true
vars: vars:
part_index: 0 part_index: 0
@ -76,10 +71,11 @@
loop: "{{ base_root_disks_info.results }}" loop: "{{ base_root_disks_info.results }}"
register: parted_create register: parted_create
- name: Collect EFI partition devices - name: Partition | collect EFI boot partition devices
ansible.builtin.shell: "lsblk -r --noheadings -o PATH {{ item }} | sort" ansible.builtin.shell: "lsblk -r --noheadings -o PATH {{ item }} | sort"
register: lsblk register: lsblk
loop: "{{ parted_create.results | map(attribute='disk.dev') }}" loop: "{{ parted_create.results | map(attribute='disk.dev') }}"
changed_when: false
- name: Store EFI partition devices - name: Store EFI partition devices
ansible.builtin.set_fact: ansible.builtin.set_fact:
@ -91,10 +87,10 @@
loop: "{{ lsblk.results | map(attribute='stdout_lines') | sort }}" loop: "{{ lsblk.results | map(attribute='stdout_lines') | sort }}"
vars: vars:
part_index: 0 part_index: 0
changed_when: false
- ansible.builtin.debug: #### zroot zfs pool
var: base_efi_partitions - name: Partition | create root ZFS pool partition
- name: Create root zvol partition
become: true become: true
vars: vars:
part_index: 1 part_index: 1
@ -110,12 +106,13 @@
loop: "{{ parted_create.results }}" loop: "{{ parted_create.results }}"
register: parted_create register: parted_create
- name: Collect root zvol partition devices - name: Partition | collect root ZFS pool partition devices
ansible.builtin.shell: "lsblk -r --noheadings -o PATH {{ item }} | sort" ansible.builtin.shell: "lsblk -r --noheadings -o PATH {{ item }} | sort"
register: lsblk register: lsblk
loop: "{{ parted_create.results | map(attribute='disk.dev') }}" loop: "{{ parted_create.results | map(attribute='disk.dev') }}"
changed_when: false
- name: Store root zvol partition devices - name: Partition | store root ZFS pool partition devices
ansible.builtin.set_fact: ansible.builtin.set_fact:
base_root_partitions: >- base_root_partitions: >-
{{ base_root_partitions|d([]) + [ {{ base_root_partitions|d([]) + [
@ -125,9 +122,10 @@
loop: "{{ lsblk.results | map(attribute='stdout_lines') | sort }}" loop: "{{ lsblk.results | map(attribute='stdout_lines') | sort }}"
vars: vars:
part_index: 1 part_index: 1
changed_when: false
#### swap #### swap partitions
- name: Create swap partition - name: Partition | create swap partition
become: true become: true
vars: vars:
part_index: 2 part_index: 2
@ -144,13 +142,14 @@
register: parted_create register: parted_create
when: base_root_swap_mib is defined and base_root_swap_mib|int > 0 when: base_root_swap_mib is defined and base_root_swap_mib|int > 0
- name: Collect swap partition devices - name: Partition | Collect swap partition devices
ansible.builtin.shell: "lsblk -r --noheadings -o PATH {{ item }} | sort" ansible.builtin.shell: "set -o pipefail; lsblk -r --noheadings -o PATH {{ item }} | sort"
register: lsblk register: lsblk
loop: "{{ parted_create.results | map(attribute='disk.dev') }}" loop: "{{ parted_create.results | map(attribute='disk.dev') }}"
when: base_root_swap_mib is defined and base_root_swap_mib|int > 0 when: base_root_swap_mib is defined and base_root_swap_mib|int > 0
changed_when: false
- name: Store swap partition devices - name: Partition | Store swap partition devices
ansible.builtin.set_fact: ansible.builtin.set_fact:
base_swap_partitions: >- base_swap_partitions: >-
{{ base_swap_partitions|d([]) + [ {{ base_swap_partitions|d([]) + [
@ -161,19 +160,21 @@
vars: vars:
part_index: 2 part_index: 2
when: base_root_swap_mib is defined and base_root_swap_mib|int > 0 when: base_root_swap_mib is defined and base_root_swap_mib|int > 0
changed_when: false
- name: Analyze resulting partition layouts - name: Partition | Analyze resulting partition layouts
community.general.parted: community.general.parted:
unit: MiB unit: MiB
device: "{{ item }}" device: "{{ item }}"
register: base_root_disks_info register: base_root_disks_info
loop: "{{ base_root_disks | list }}" loop: "{{ base_root_disks | list }}"
- name: Collect disk device identifiers - name: Partition | Collect disk device identifiers
ansible.builtin.shell: "for x in /dev/disk/by-id/*; do echo $x $(realpath $x); done" ansible.builtin.shell: "set -o pipefail; for x in /dev/disk/by-id/*; do echo $x $(realpath $x); done"
register: disk_realpaths register: disk_realpaths
changed_when: false
- name: Collect disk device identifiers into a base_partitions_by_id dictionary - name: Partition | Collect disk device identifiers into a base_partitions_by_id dictionary
ansible.builtin.set_fact: ansible.builtin.set_fact:
base_partitions_by_id: >- base_partitions_by_id: >-
{{ {{
@ -183,10 +184,3 @@
| map('list') | map('list')
) )
}} }}
- ansible.builtin.debug:
var: base_efi_partitions
- ansible.builtin.debug:
var: base_root_partitions
- ansible.builtin.debug:
var: base_swap_partitions

View file

@ -1,18 +1,23 @@
--- ---
- name: Mount arch zroot - name: Arch Install | Chroot | Mount arch zroot
ansible.builtin.command: zfs mount zroot/ROOT/arch ansible.builtin.command: zfs mount zroot/ROOT/arch
- name: Mount all other zroot mountpoints changed_when: false
- name: Arch Install | Chroot | Mount all other zroot mountpoints
ansible.builtin.command: zfs mount -a ansible.builtin.command: zfs mount -a
- name: Create zroot destination directories changed_when: false
- name: Arch Install | Chroot | Create zroot destination directories
ansible.builtin.file: ansible.builtin.file:
path: "/mnt{{ item }}" path: "/mnt{{ item }}"
state: directory state: directory
owner: root
group: root
mode: '0755'
loop: loop:
- /etc/zfs - /etc/zfs
- /boot/efi - /boot/efi
- ansible.builtin.debug:
var: base_efi_partitions
- name: Mount EFI - name: Mount EFI
ansible.posix.mount: ansible.posix.mount:
path: /mnt/boot/efi path: /mnt/boot/efi
@ -20,9 +25,19 @@
fstype: vfat fstype: vfat
state: mounted state: mounted
- name: zfs | Set zroot bootfs to arch - name: Arch Chroot | zpool | Set zroot bootfs to arch
ansible.builtin.command: zpool set bootfs=zroot/ROOT/arch zroot ansible.builtin.command: zpool set bootfs=zroot/ROOT/arch zroot
- name: zfs | Set cachefile changed_when: false
- name: Arch Chroot | zpool | Set cachefile
ansible.builtin.command: zpool set cachefile=/etc/zfs/zpool.cache zroot ansible.builtin.command: zpool set cachefile=/etc/zfs/zpool.cache zroot
- name: zfs | Copy cache file to chroot changed_when: false
ansible.builtin.command: cp /etc/zfs/zpool.cache /mnt/etc/zfs
- name: Arch Chroot | zpool | copy zpool.cache to installation chroot
ansible.builtin.copy:
remote_src: true
src: /etc/zfs/zpool.cache
dest: /mnt/etc/zfs/zpool.cache
owner: root
group: root
mode: "0644"

View file

@ -7,7 +7,7 @@
msg: "please specify a root password via -e root_password=<password>" msg: "please specify a root password via -e root_password=<password>"
- ansible.builtin.import_tasks: archinstall/mirrorlist.yaml - ansible.builtin.import_tasks: archinstall/mirrorlist.yaml
- ansible.builtin.import_tasks: archinstall/partition.yaml - ansible.builtin.import_tasks: archinstall/partition.yaml
- ansible.builtin.import_tasks: archinstall/initialize_root_zvol.yaml - ansible.builtin.import_tasks: archinstall/initialize_root_zfs_pool.yaml
- ansible.builtin.import_tasks: archinstall/initialize_swap.yaml - ansible.builtin.import_tasks: archinstall/initialize_swap.yaml
- ansible.builtin.import_tasks: archinstall/initialize_efi.yaml - ansible.builtin.import_tasks: archinstall/initialize_efi.yaml
- ansible.builtin.import_tasks: archinstall/prepare_chroot.yaml - ansible.builtin.import_tasks: archinstall/prepare_chroot.yaml

View file

@ -1,6 +1,7 @@
--- ---
- name: Check for archinstall in path - name: Check for archinstall in path
ansible.builtin.command: which archinstall ansible.builtin.command: which archinstall
changed_when: false
ignore_errors: true ignore_errors: true
register: which_archinstall register: which_archinstall

View file

@ -1,2 +1,2 @@
--- ---
desktop_user: mark software_desktop_user: mark

View file

@ -1,12 +1,17 @@
--- ---
- when: not archiso_detected - name: Install system package groups
when: not archiso_detected
block: block:
- name: Pacman sync - name: Update pacman cache
community.general.pacman: community.general.pacman:
update_cache: true update_cache: true
- name: Minimal
- ansible.builtin.import_tasks: software/minimal.yaml ansible.builtin.import_tasks: software/minimal.yaml
- ansible.builtin.import_tasks: software/desktop.yaml - name: Desktop
- ansible.builtin.import_tasks: software/graphics.yaml ansible.builtin.import_tasks: software/desktop.yaml
- ansible.builtin.import_tasks: software/dev.yaml - name: Graphics
- ansible.builtin.import_tasks: software/gamedev.yaml ansible.builtin.import_tasks: software/graphics.yaml
- name: Development
ansible.builtin.import_tasks: software/dev.yaml
- name: Game Development
ansible.builtin.import_tasks: software/gamedev.yaml

View file

@ -39,62 +39,72 @@
- name: Install AUR packages - name: Install AUR packages
become: true become: true
become_user: "{{ desktop_user }}" become_user: "{{ software_desktop_user }}"
ansible.builtin.command: >- ansible.builtin.command: >-
paru -Sy --needed --noconfirm {{ packages | join(' ') }} paru -Sy --needed --noconfirm {{ packages | join(' ') }}
changed_when: true
vars: vars:
packages: packages:
- dracula-gtk-theme-full - dracula-gtk-theme-full
- ttf-envy-code-r - ttf-envy-code-r
- winbox - winbox
- name: loginctl | Enable linger for desktop user - name: Enable linger for desktop user
ansible.builtin.command: "loginctl enable-linger {{ desktop_user }}" ansible.builtin.command:
- name: syncthing | Generate default config cmd: "loginctl enable-linger {{ software_desktop_user }}"
creates: "/var/lib/systemd/linger/{{ software_desktop_user }}"
- name: Syncthing | Generate default config
become: true become: true
become_user: "{{ desktop_user }}" become_user: "{{ software_desktop_user }}"
ansible.builtin.command: >- ansible.builtin.command:
syncthing generate --no-default-folder --skip-port-probing cmd: syncthing generate --no-default-folder --skip-port-probing
- name: syncthing | Enable user systemd unit creates: "/home/{{ software_deskop_user }}/.local/state/syncthing/config.xml"
- name: Syncthing | Enable user systemd unit
ansible.builtin.systemd: ansible.builtin.systemd:
name: syncthing.service name: syncthing.service
enabled: true enabled: true
state: started state: started
scope: user scope: user
become: true become: true
become_user: "{{ desktop_user }}" become_user: "{{ software_desktop_user }}"
- name: greetd | configure | use tuigreet - name: Greetd | configure | use tuigreet
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: /etc/greetd/config.toml path: /etc/greetd/config.toml
regexp: "^command =" regexp: "^command ="
line: command = "tuigreet --cmd sway" line: command = "tuigreet --cmd sway"
- name: greetd | Enable systemd unit - name: Greetd | Enable systemd unit
ansible.builtin.systemd: ansible.builtin.systemd:
name: greetd name: greetd
enabled: true enabled: true
- name: bluetooth | Enable systemd unit - name: Bluetooth | Enable systemd unit
ansible.builtin.systemd: ansible.builtin.systemd:
name: bluetooth name: bluetooth
enabled: true enabled: true
- name: wal | Set initial colorscheme - name: Wal | Set initial colorscheme
become: true become: true
become_user: "{{ desktop_user }}" become_user: "{{ software_desktop_user }}"
ansible.builtin.command: wal --theme hybrid-material ansible.builtin.command: wal --theme hybrid-material
- name: sway | Reload if running changed_when: false
- name: Sway | Reload if running
become: true become: true
become_user: "{{ desktop_user }}" become_user: "{{ software_desktop_user }}"
ansible.builtin.shell: pidof sway && SWAYSOCK=$(ls /run/user/*/sway-ipc.*.sock | head -n 1) swaymsg reload ansible.builtin.shell: set -o pipefail; pidof sway && SWAYSOCK=$(ls /run/user/*/sway-ipc.*.sock | head -n 1) swaymsg reload
ignore_errors: true failed_when: false
changed_when: false
- name: graphics | Probe for graphics cards - name: Graphics | Probe for graphics cards
ansible.builtin.shell: lspci -nnk | grep -A 3 -E "VGA|3D" ansible.builtin.shell: set -o pipefail; lspci -nnk | grep -A 3 -E "VGA|3D"
register: lspci register: lspci
changed_when: false
- name: graphics | Install radeon specific packages - name: Graphics | Install radeon specific packages
ansible.builtin.package: ansible.builtin.package:
state: present state: present
name: name: