ansible-lint --fix

This commit is contained in:
Mark Riedesel 2024-11-22 10:45:41 -06:00
parent 5634cd32d3
commit faa046aa21
21 changed files with 181 additions and 179 deletions

View file

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

View file

@ -1,10 +1,10 @@
---
- name: detect archinso environment
- name: Detect archinso environment
hosts: all
roles:
- detect_archiso
- name: provision base archlinux installation
- name: Provision base archlinux installation
hosts: base
tags: base
roles:

View file

@ -1,4 +1,5 @@
- name: post-install setup
---
- name: Post-install setup
hosts: base
roles:
- software

View file

@ -1,11 +1,11 @@
---
- name: Inspect EFI boot partitions
become: true
command: "blkid {{ item }}"
ansible.builtin.command: "blkid {{ item }}"
loop: "{{ base_efi_partitions | default([]) }}"
register: blkid
- name: Format EFI partitions fat32
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\"') }}"
register: mkfs_vfat_efi

View file

@ -1,45 +1,45 @@
---
- name: Check for existing zroot zfs volume
command: zpool list -Ho name zroot
ansible.builtin.command: zpool list -Ho name zroot
register: zroot_check
ignore_errors: true
- block:
- name: Initialize disk device to id table
set_fact:
partition_device_to_ids: {}
- when: zroot_check.rc != 0
- name: Create disk device to id table
set_fact:
partition_device_to_ids: >-
{{
partition_device_to_ids
| combine({ item.value: (partition_device_to_ids[item.value] | default([])) + [item.key] })
}}
with_items: "{{ base_partitions_by_id | dict2items }}"
block:
- name: Initialize disk device to id table
ansible.builtin.set_fact:
partition_device_to_ids: {}
- debug:
var: base_root_partitions | map('extract', partition_device_to_ids) | map('first')
- name: Create disk device to id table
ansible.builtin.set_fact:
partition_device_to_ids: >-
{{
partition_device_to_ids
| combine({ item.value: (partition_device_to_ids[item.value] | default([])) + [item.key] })
}}
with_items: "{{ base_partitions_by_id | dict2items }}"
- name: Create zroot volume
become: true
command: >-
zpool create -f -o ashift=12
-o autotrim=on
-O devices=off
-O relatime=on
-O xattr=sa
-O acltype=posixacl
-O normalization=formD
-O compression=lz4
-O canmount=off
-O mountpoint=none
-R /mnt
zroot {{ mirror }} {{ base_root_partitions | map('extract', partition_device_to_ids) | map('first') | list | join(' ') }}
vars:
mirror: "{{ 'mirror' if base_root_partitions | length > 1 else '' }}"
when: zroot_check.rc != 0
- ansible.builtin.debug:
var: base_root_partitions | map('extract', partition_device_to_ids) | map('first')
- name: Create zroot volume
become: true
ansible.builtin.command: >-
zpool create -f -o ashift=12
-o autotrim=on
-O devices=off
-O relatime=on
-O xattr=sa
-O acltype=posixacl
-O normalization=formD
-O compression=lz4
-O canmount=off
-O mountpoint=none
-R /mnt
zroot {{ mirror }} {{ base_root_partitions | map('extract', partition_device_to_ids) | map('first') | list | join(' ') }}
vars:
mirror: "{{ 'mirror' if base_root_partitions | length > 1 else '' }}"
- name: Create zroot/ROOT and zroot/DATA volumes
community.general.zfs:
name: "zroot/{{ item }}"
@ -64,7 +64,6 @@
mountpoint: /home
- name: Export zroot pool
command: zpool export zroot
ansible.builtin.command: zpool export zroot
- name: Import zroot pool (-R /mnt)
command: zpool import -R /mnt zroot -N
ansible.builtin.command: zpool import -R /mnt zroot -N

View file

@ -1,12 +1,12 @@
---
- name: Initialize swap space
become: true
command: "blkid {{item}}"
ansible.builtin.command: "blkid {{item}}"
loop: "{{ base_swap_partitions | default([]) }}"
register: blkid
- name: Swap devices without swap filesystems present
become: true
command: "mkswap --verbose {{item.item}}"
ansible.builtin.command: "mkswap --verbose {{item.item}}"
loop: "{{ blkid.results | rejectattr('stdout', 'contains', 'TYPE=\"swap\"') }}"
register: mkswap

View file

@ -1,14 +1,14 @@
---
- name: archinstall | install os | check for presence of previously pacstrapped /mnt
stat:
ansible.builtin.stat:
path: /mnt/usr/lib
register: existing_pacstrap
- debug:
- ansible.builtin.debug:
var: existing_pacstrap
- name: archinstall | install os | pacstrap
shell: "pacstrap /mnt {{ packages | join(' ') }}"
ansible.builtin.command: "pacstrap /mnt {{ packages | join(' ') }}"
vars:
packages:
- ansible
@ -26,56 +26,54 @@
when: not existing_pacstrap.stat.exists
- name: archinstall | install os | copy pacman mirrorlist
copy:
ansible.builtin.copy:
remote_src: true
src: /etc/pacman.d/mirrorlist
dest: /mnt/etc/pacman.d/mirrorlist
- name: archinstall | install os | propagate root authorized keys
copy:
ansible.builtin.copy:
remote_src: true
src: /root/.ssh/authorized_keys
dest: /mnt/root/.ssh/authorized_keys
- name: archinstall | install os | passwordless sudo for group wheel
copy:
ansible.builtin.copy:
content: "%wheel ALL=(ALL) NOPASSWD: ALL"
dest: /mnt/etc/sudoers.d/wheel-group-nopasswd
- name: archinstall | install os | set timezone
file:
ansible.builtin.file:
src: /usr/share/zoneinfo/US/Central
dest: /mnt/etc/localtime
state: link
- name: archinstall | install os | enable en_US locales
command: sed -i 's/^#en_US/en_US/' /mnt/etc/locale.gen
ansible.builtin.command: sed -i 's/^#en_US/en_US/' /mnt/etc/locale.gen
- name: archinstall | install os | generate locales
command: arch-chroot /mnt locale-gen
ansible.builtin.command: arch-chroot /mnt locale-gen
- name: archinstall | install os | generate template for arch-chroot installation
template:
ansible.builtin.template:
src: arch_chroot_install.sh
dest: /mnt/arch_chroot_install.sh
mode: "0755"
- name: archinstall | install os | set hostname
copy:
ansible.builtin.copy:
dest: /mnt/etc/hostname
content: |
{{ inventory_hostname }}
- name: archinstall | install os | run installation script in arch-chroot
command: arch-chroot /mnt /arch_chroot_install.sh
ansible.builtin.command: arch-chroot /mnt /arch_chroot_install.sh
register: chroot
- name: archinstall | install os | arch-chroot install output
debug:
ansible.builtin.debug:
msg: "{{ chroot.stdout_lines }}"
- name: archinstall | install os | remove arch-chroot installation script
file:
ansible.builtin.file:
path: /mnt/arch_chroot_install.sh
state: absent

View file

@ -1,4 +1,4 @@
---
- name: Select fastest Arch repository mirrors
command:
ansible.builtin.command:
cmd: reflector --country US --latest 5 --sort rate --save /etc/pacman.d/mirrorlist

View file

@ -6,8 +6,8 @@
register: base_root_disks_info
loop: "{{ base_root_disks | list }}"
- name: partition | ensure efi is not mounted
mount:
- name: partition | Ensure efi is not mounted
ansible.posix.mount:
path: /mnt/boot/efi
state: unmounted
@ -15,20 +15,21 @@
ansible.builtin.set_fact:
base_root_usable_mib: "{{ (base_root_disks_info.results | map(attribute='disk.size') | min | int) - 1 }}"
- debug: var=base_root_usable_mib
- ansible.builtin.debug:
var: base_root_usable_mib
- name: Calculate disk utilization percentage
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') | int }}"
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 }}"
- name: Calculate zfs volume size
set_fact:
base_root_zpool_mib: "{{ base_root_usable_mib|int - fixed_size_partitions|int }}"
ansible.builtin.set_fact:
base_root_zpool_mib: "{{ base_root_usable_mib | int - fixed_size_partitions | int }}"
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
set_fact:
ansible.builtin.set_fact:
partition_ranges: >-
{{
(partition_ranges|d([])) + [{
@ -47,11 +48,11 @@
- name: swap
size_mib: "{{ base_root_swap_mib }}"
- debug:
- ansible.builtin.debug:
var: partition_ranges
- name: Initialize partition facts
set_fact:
ansible.builtin.set_fact:
base_efi_partitions: []
base_root_partitions: []
base_swap_partitions: []
@ -61,14 +62,14 @@
become: true
vars:
part_index: 0
parted:
community.general.parted:
label: gpt
unit: MiB
name: EFI Boot
device: "{{ item.disk.dev }}"
number: "{{ part_index + 1 }}"
flags: [ boot, esp ]
part_start: "{{ [partition_ranges[part_index].begin, 1]|max }}MiB"
flags: [boot, esp]
part_start: "{{ [partition_ranges[part_index].begin, 1] | max }}MiB"
part_end: "{{ partition_ranges[part_index].end }}MiB"
state: present
fs_type: fat32
@ -76,12 +77,12 @@
register: parted_create
- name: Collect EFI partition devices
shell: "lsblk -r --noheadings -o PATH {{ item }} | sort"
ansible.builtin.shell: "lsblk -r --noheadings -o PATH {{ item }} | sort"
register: lsblk
loop: "{{ parted_create.results | map(attribute='disk.dev') }}"
- name: Store EFI partition devices
set_fact:
ansible.builtin.set_fact:
base_efi_partitions: >-
{{ base_efi_partitions|d([]) + [
item[part_index+1]
@ -91,14 +92,13 @@
vars:
part_index: 0
- debug: var=base_efi_partitions
#### zroot
- ansible.builtin.debug:
var: base_efi_partitions
- name: Create root zvol partition
become: true
vars:
part_index: 1
parted:
community.general.parted:
label: gpt
unit: MiB
name: ArchLinux ZFS Root
@ -111,12 +111,12 @@
register: parted_create
- name: Collect root zvol partition devices
shell: "lsblk -r --noheadings -o PATH {{ item }} | sort"
ansible.builtin.shell: "lsblk -r --noheadings -o PATH {{ item }} | sort"
register: lsblk
loop: "{{ parted_create.results | map(attribute='disk.dev') }}"
- name: Store root zvol partition devices
set_fact:
ansible.builtin.set_fact:
base_root_partitions: >-
{{ base_root_partitions|d([]) + [
item[part_index+1]
@ -131,7 +131,7 @@
become: true
vars:
part_index: 2
parted:
community.general.parted:
label: gpt
unit: MiB
device: "{{ item.disk.dev }}"
@ -145,13 +145,13 @@
when: base_root_swap_mib is defined and base_root_swap_mib|int > 0
- name: Collect swap partition devices
shell: "lsblk -r --noheadings -o PATH {{ item }} | sort"
ansible.builtin.shell: "lsblk -r --noheadings -o PATH {{ item }} | sort"
register: lsblk
loop: "{{ parted_create.results | map(attribute='disk.dev') }}"
when: base_root_swap_mib is defined and base_root_swap_mib|int > 0
- name: Store swap partition devices
set_fact:
ansible.builtin.set_fact:
base_swap_partitions: >-
{{ base_swap_partitions|d([]) + [
item[part_index+1]
@ -163,18 +163,18 @@
when: base_root_swap_mib is defined and base_root_swap_mib|int > 0
- name: Analyze resulting partition layouts
parted:
community.general.parted:
unit: MiB
device: "{{ item }}"
register: base_root_disks_info
loop: "{{ base_root_disks | list }}"
- name: Collect disk device identifiers
shell: "for x in /dev/disk/by-id/*; do echo $x $(realpath $x); done"
ansible.builtin.shell: "for x in /dev/disk/by-id/*; do echo $x $(realpath $x); done"
register: disk_realpaths
- name: Collect disk device identifiers into a base_partitions_by_id dictionary
set_fact:
ansible.builtin.set_fact:
base_partitions_by_id: >-
{{
dict(
@ -184,6 +184,9 @@
)
}}
- debug: var=base_efi_partitions
- debug: var=base_root_partitions
- debug: var=base_swap_partitions
- ansible.builtin.debug:
var: base_efi_partitions
- ansible.builtin.debug:
var: base_root_partitions
- ansible.builtin.debug:
var: base_swap_partitions

View file

@ -1,10 +1,11 @@
- name: archinstall | re-create post-installation snapshot of zroot/ROOT/arch
---
- name: archinstall | Re-create post-installation snapshot of zroot/ROOT/arch
community.general.zfs:
name: zroot/ROOT/arch@post-installation
state: "{{ item }}"
with_items: [absent, present]
- name: archinstall | re-create post-installation snapshot of zroot/DATA/home
- name: archinstall | Re-create post-installation snapshot of zroot/DATA/home
community.general.zfs:
name: zroot/DATA/home@post-installation
state: "{{ item }}"

View file

@ -1,10 +1,8 @@
---
- name: Mount arch zroot
command: zfs mount zroot/ROOT/arch
ansible.builtin.command: zfs mount zroot/ROOT/arch
- name: Mount all other zroot mountpoints
command: zfs mount -a
ansible.builtin.command: zfs mount -a
- name: Create zroot destination directories
ansible.builtin.file:
path: "/mnt{{ item }}"
@ -13,8 +11,8 @@
- /etc/zfs
- /boot/efi
- debug: var=base_efi_partitions
- ansible.builtin.debug:
var: base_efi_partitions
- name: Mount EFI
ansible.posix.mount:
path: /mnt/boot/efi
@ -22,11 +20,9 @@
fstype: vfat
state: mounted
- name: zfs | set zroot bootfs to arch
command: zpool set bootfs=zroot/ROOT/arch zroot
- name: zfs | set cachefile
command: zpool set cachefile=/etc/zfs/zpool.cache zroot
- name: zfs | copy cache file to chroot
command: cp /etc/zfs/zpool.cache /mnt/etc/zfs
- name: zfs | Set zroot bootfs to arch
ansible.builtin.command: zpool set bootfs=zroot/ROOT/arch zroot
- name: zfs | Set cachefile
ansible.builtin.command: zpool set cachefile=/etc/zfs/zpool.cache zroot
- name: zfs | Copy cache file to chroot
ansible.builtin.command: cp /etc/zfs/zpool.cache /mnt/etc/zfs

View file

@ -1,15 +1,15 @@
---
- block:
- name: ensure root_password is set
assert:
that: root_password is defined
msg: "please specify a root password via -e root_password=<password>"
- import_tasks: archinstall/mirrorlist.yaml
- import_tasks: archinstall/partition.yaml
- import_tasks: archinstall/initialize_root_zvol.yaml
- import_tasks: archinstall/initialize_swap.yaml
- import_tasks: archinstall/initialize_efi.yaml
- import_tasks: archinstall/prepare_chroot.yaml
- import_tasks: archinstall/install_os.yaml
- import_tasks: archinstall/postinstall_snapshot.yaml
when: archiso_detected and base_root_disks is defined
- when: archiso_detected and base_root_disks is defined
block:
- name: Ensure root_password is set
ansible.builtin.assert:
that: root_password is defined
msg: "please specify a root password via -e root_password=<password>"
- ansible.builtin.import_tasks: archinstall/mirrorlist.yaml
- ansible.builtin.import_tasks: archinstall/partition.yaml
- ansible.builtin.import_tasks: archinstall/initialize_root_zvol.yaml
- ansible.builtin.import_tasks: archinstall/initialize_swap.yaml
- ansible.builtin.import_tasks: archinstall/initialize_efi.yaml
- ansible.builtin.import_tasks: archinstall/prepare_chroot.yaml
- ansible.builtin.import_tasks: archinstall/install_os.yaml
- ansible.builtin.import_tasks: archinstall/postinstall_snapshot.yaml

View file

@ -1,9 +1,9 @@
---
- name: check for archinstall in path
command: which archinstall
- name: Check for archinstall in path
ansible.builtin.command: which archinstall
ignore_errors: true
register: which_archinstall
- name: inspect archinstall check result
set_fact:
- name: Inspect archinstall check result
ansible.builtin.set_fact:
archiso_detected: "{{ which_archinstall.rc == 0 }}"

View file

@ -1,13 +1,13 @@
---
- name: dotfiles | set user shell
- name: dotfiles | Set user shell
ansible.builtin.user:
name: "{{ dotfiles_user }}"
shell: "/usr/bin/{{ dotfiles_shell }}"
- name: dotfiles | install from remote source
- name: dotfiles | Install from remote source
become: true
become_user: "{{ dotfiles_user }}"
shell:
ansible.builtin.shell:
cmd: "curl -o- -L {{ dotfiles_url }} | {{ dotfiles_shell }}"
creates: "/home/{{ dotfiles_user }}/.dotfiles"
register: dotfiles

View file

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

View file

@ -1,12 +1,12 @@
---
- block:
- name: pacman sync
community.general.pacman:
update_cache: true
- when: not archiso_detected
block:
- name: Pacman sync
community.general.pacman:
update_cache: true
- import_tasks: software/minimal.yaml
- import_tasks: software/desktop.yaml
- import_tasks: software/graphics.yaml
- import_tasks: software/dev.yaml
- import_tasks: software/gamedev.yaml
when: not archiso_detected
- ansible.builtin.import_tasks: software/minimal.yaml
- ansible.builtin.import_tasks: software/desktop.yaml
- ansible.builtin.import_tasks: software/graphics.yaml
- ansible.builtin.import_tasks: software/dev.yaml
- ansible.builtin.import_tasks: software/gamedev.yaml

View file

@ -1,5 +1,6 @@
- name: install desktop packages
package:
---
- name: Install desktop packages
ansible.builtin.package:
state: present
name:
- adwaita-cursors
@ -36,10 +37,10 @@
- xdg-user-dirs
- xorg-xwayland
- name: install AUR packages
- name: Install AUR packages
become: true
become_user: "{{ desktop_user }}"
shell: >-
ansible.builtin.command: >-
paru -Sy --needed --noconfirm {{ packages | join(' ') }}
vars:
packages:
@ -47,17 +48,15 @@
- ttf-envy-code-r
- winbox
- name: loginctl | enable linger for desktop user
command: "loginctl enable-linger {{ desktop_user }}"
- name: syncthing | generate default config
become: yes
- name: loginctl | Enable linger for desktop user
ansible.builtin.command: "loginctl enable-linger {{ desktop_user }}"
- name: syncthing | Generate default config
become: true
become_user: "{{ desktop_user }}"
command: >-
ansible.builtin.command: >-
syncthing generate --no-default-folder --skip-port-probing
- name: syncthing | enable user systemd unit
systemd:
- name: syncthing | Enable user systemd unit
ansible.builtin.systemd:
name: syncthing.service
enabled: true
state: started
@ -68,38 +67,37 @@
- name: greetd | configure | use tuigreet
ansible.builtin.lineinfile:
path: /etc/greetd/config.toml
regexp: '^command ='
regexp: "^command ="
line: command = "tuigreet --cmd sway"
- name: greetd | enable systemd unit
systemd:
- name: greetd | Enable systemd unit
ansible.builtin.systemd:
name: greetd
enabled: true
- name: bluetooth | enable systemd unit
systemd:
- name: bluetooth | Enable systemd unit
ansible.builtin.systemd:
name: bluetooth
enabled: true
- name: wal | set initial colorscheme
- name: wal | Set initial colorscheme
become: true
become_user: "{{ desktop_user }}"
shell: wal --theme hybrid-material
- name: sway | reload if running
ansible.builtin.command: wal --theme hybrid-material
- name: sway | Reload if running
become: true
become_user: "{{ desktop_user }}"
shell: pidof sway && SWAYSOCK=$(ls /run/user/*/sway-ipc.*.sock | head -n 1) swaymsg reload
ansible.builtin.shell: pidof sway && SWAYSOCK=$(ls /run/user/*/sway-ipc.*.sock | head -n 1) swaymsg reload
ignore_errors: true
- name: graphics | probe for graphics cards
shell: lspci -nnk | grep -A 3 -E "VGA|3D"
- name: graphics | Probe for graphics cards
ansible.builtin.shell: lspci -nnk | grep -A 3 -E "VGA|3D"
register: lspci
- name: graphics | install radeon specific packages
package:
- name: graphics | Install radeon specific packages
ansible.builtin.package:
state: present
name:
- hip-runtime-amd
- rocm-opencl-runtime
- vulkan-radeon
- hip-runtime-amd
- rocm-opencl-runtime
- vulkan-radeon

View file

@ -1,5 +1,6 @@
- name: install gamedev packages
package:
---
- name: Install gamedev packages
ansible.builtin.package:
state: present
name:
- neovim

View file

@ -1,5 +1,6 @@
- name: install gamedev packages
package:
---
- name: Install gamedev packages
ansible.builtin.package:
state: present
name:
- godot

View file

@ -1,5 +1,6 @@
- name: install graphics packages
package:
---
- name: Install graphics packages
ansible.builtin.package:
state: present
name:
- blender

View file

@ -1,10 +1,11 @@
- name: install minimal packages
package:
---
- name: Install minimal packages
ansible.builtin.package:
state: present
name:
- eza
- fzf
- htop
- ripgrep
- zip
- unzip
- zsh