diff --git a/local.yml b/local.yml index 9becd98..1aa4698 100644 --- a/local.yml +++ b/local.yml @@ -1,3 +1,2 @@ --- -- name: OS Install - import_playbook: playbooks/install.yaml +- import_playbook: playbooks/install.yaml diff --git a/playbooks/info.yaml b/playbooks/info.yaml new file mode 100644 index 0000000..c5381ad --- /dev/null +++ b/playbooks/info.yaml @@ -0,0 +1,6 @@ +- hosts: all + become: true + tasks: + - name: is this a livecd? + debug: + msg: "{{ ansible_nodename }} {{ ansible_nodename == 'archiso' }}" diff --git a/playbooks/install.yaml b/playbooks/install.yaml index c7b8300..b290e86 100644 --- a/playbooks/install.yaml +++ b/playbooks/install.yaml @@ -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: diff --git a/playbooks/post-install.yaml b/playbooks/post-install.yaml index 47daad6..d045fbd 100644 --- a/playbooks/post-install.yaml +++ b/playbooks/post-install.yaml @@ -1,5 +1,4 @@ ---- -- name: Post-install setup +- name: post-install setup hosts: base roles: - software diff --git a/roles/base/tasks/archinstall/initialize_efi.yaml b/roles/base/tasks/archinstall/initialize_efi.yaml index 2312599..9f4e836 100644 --- a/roles/base/tasks/archinstall/initialize_efi.yaml +++ b/roles/base/tasks/archinstall/initialize_efi.yaml @@ -1,13 +1,11 @@ --- - name: Inspect EFI boot partitions become: true - ansible.builtin.command: "blkid {{ item }}" + command: "blkid {{ item }}" loop: "{{ base_efi_partitions | default([]) }}" register: blkid - changed_when: false - name: Format EFI partitions fat32 - ansible.builtin.command: "mkfs.vfat -v -F 32 -n EFI {{ item.item }}" + command: "mkfs.vfat -v -F 32 -n EFI {{ item.item }}" loop: "{{ blkid.results | rejectattr('stdout', 'contains', 'TYPE=\"vfat\"') }}" register: mkfs_vfat_efi - changed_when: true diff --git a/roles/base/tasks/archinstall/initialize_root_zfs_pool.yaml b/roles/base/tasks/archinstall/initialize_root_zfs_pool.yaml deleted file mode 100644 index 87ca78a..0000000 --- a/roles/base/tasks/archinstall/initialize_root_zfs_pool.yaml +++ /dev/null @@ -1,72 +0,0 @@ ---- -- name: Root ZFS Pool | Check for existing zroot zfs volume - ansible.builtin.command: zpool list -Ho name zroot - register: zroot_check - changed_when: false - ignore_errors: true - -- name: Root ZFS Pool | - when: zroot_check.rc != 0 - block: - - name: Root ZFS Pool | initialize disk device to id table - ansible.builtin.set_fact: - partition_device_to_ids: {} - - - name: Root ZFS Pool | create disk device -> 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: Root ZFS Pool | 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 '' }}" - changed_when: true - -- name: Root ZFS Pool | create zroot/ROOT and zroot/DATA volumes - community.general.zfs: - name: "zroot/{{ item }}" - state: present - register: zfs_zroot_root_volume - with_items: [ROOT, DATA] - -- name: Root ZFS Pool | create zroot/ROOT/arch - community.general.zfs: - name: zroot/ROOT/arch - state: present - extra_zfs_properties: - canmount: noauto - mountpoint: / - when: zfs_zroot_root_volume.changed - -- name: Root ZFS Pool | create zroot/DATA/home - community.general.zfs: - name: zroot/DATA/home - state: present - extra_zfs_properties: - mountpoint: /home - -- name: Root ZFS Pool | Export zroot pool - ansible.builtin.command: zpool export zroot - changed_when: false - -- name: Root ZFS Pool | Import zroot pool (-R /mnt) - ansible.builtin.command: zpool import -R /mnt zroot -N - changed_when: false diff --git a/roles/base/tasks/archinstall/initialize_root_zvol.yaml b/roles/base/tasks/archinstall/initialize_root_zvol.yaml new file mode 100644 index 0000000..1421e83 --- /dev/null +++ b/roles/base/tasks/archinstall/initialize_root_zvol.yaml @@ -0,0 +1,70 @@ +--- +- name: Check for existing zroot zfs volume + 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: {} + + - 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 }}" + + - debug: + var: base_root_partitions | map('extract', partition_device_to_ids) | map('first') + + - 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 + +- name: Create zroot/ROOT and zroot/DATA volumes + community.general.zfs: + name: "zroot/{{ item }}" + state: present + register: zfs_zroot_root_volume + with_items: [ROOT, DATA] + +- name: Create zroot/ROOT/arch + community.general.zfs: + name: zroot/ROOT/arch + state: present + extra_zfs_properties: + canmount: noauto + mountpoint: / + when: zfs_zroot_root_volume.changed + +- name: Create zroot/home + community.general.zfs: + name: zroot/DATA/home + state: present + extra_zfs_properties: + mountpoint: /home + +- name: Export zroot pool + command: zpool export zroot + +- name: Import zroot pool (-R /mnt) + command: zpool import -R /mnt zroot -N diff --git a/roles/base/tasks/archinstall/initialize_swap.yaml b/roles/base/tasks/archinstall/initialize_swap.yaml index 75f5d50..83a0a72 100644 --- a/roles/base/tasks/archinstall/initialize_swap.yaml +++ b/roles/base/tasks/archinstall/initialize_swap.yaml @@ -1,12 +1,12 @@ --- - name: Initialize swap space become: true - ansible.builtin.command: "blkid {{ item }}" + command: "blkid {{item}}" loop: "{{ base_swap_partitions | default([]) }}" register: blkid - name: Swap devices without swap filesystems present become: true - ansible.builtin.command: "mkswap --verbose {{ item.item }}" + command: "mkswap --verbose {{item.item}}" loop: "{{ blkid.results | rejectattr('stdout', 'contains', 'TYPE=\"swap\"') }}" register: mkswap diff --git a/roles/base/tasks/archinstall/install_os.yaml b/roles/base/tasks/archinstall/install_os.yaml index eea201c..db2fbd6 100644 --- a/roles/base/tasks/archinstall/install_os.yaml +++ b/roles/base/tasks/archinstall/install_os.yaml @@ -1,14 +1,14 @@ --- - name: archinstall | install os | check for presence of previously pacstrapped /mnt - ansible.builtin.stat: + stat: path: /mnt/usr/lib register: existing_pacstrap -- ansible.builtin.debug: +- debug: var: existing_pacstrap - name: archinstall | install os | pacstrap - ansible.builtin.command: "pacstrap /mnt {{ packages | join(' ') }}" + shell: "pacstrap /mnt {{ packages | join(' ') }}" vars: packages: - ansible @@ -26,54 +26,56 @@ when: not existing_pacstrap.stat.exists - name: archinstall | install os | copy pacman mirrorlist - ansible.builtin.copy: + copy: remote_src: true src: /etc/pacman.d/mirrorlist dest: /mnt/etc/pacman.d/mirrorlist - name: archinstall | install os | propagate root authorized keys - ansible.builtin.copy: + copy: remote_src: true src: /root/.ssh/authorized_keys dest: /mnt/root/.ssh/authorized_keys - name: archinstall | install os | passwordless sudo for group wheel - ansible.builtin.copy: + copy: content: "%wheel ALL=(ALL) NOPASSWD: ALL" dest: /mnt/etc/sudoers.d/wheel-group-nopasswd - name: archinstall | install os | set timezone - ansible.builtin.file: + file: src: /usr/share/zoneinfo/US/Central dest: /mnt/etc/localtime state: link - name: archinstall | install os | enable en_US locales - ansible.builtin.command: sed -i 's/^#en_US/en_US/' /mnt/etc/locale.gen + command: sed -i 's/^#en_US/en_US/' /mnt/etc/locale.gen + - name: archinstall | install os | generate locales - ansible.builtin.command: arch-chroot /mnt locale-gen + command: arch-chroot /mnt locale-gen + - name: archinstall | install os | generate template for arch-chroot installation - ansible.builtin.template: + template: src: arch_chroot_install.sh dest: /mnt/arch_chroot_install.sh mode: "0755" - name: archinstall | install os | set hostname - ansible.builtin.copy: + copy: dest: /mnt/etc/hostname content: | {{ inventory_hostname }} - name: archinstall | install os | run installation script in arch-chroot - ansible.builtin.command: arch-chroot /mnt /arch_chroot_install.sh + command: arch-chroot /mnt /arch_chroot_install.sh register: chroot - name: archinstall | install os | arch-chroot install output - ansible.builtin.debug: + debug: msg: "{{ chroot.stdout_lines }}" - name: archinstall | install os | remove arch-chroot installation script - ansible.builtin.file: + file: path: /mnt/arch_chroot_install.sh state: absent diff --git a/roles/base/tasks/archinstall/mirrorlist.yaml b/roles/base/tasks/archinstall/mirrorlist.yaml index a1225b3..08af6ee 100644 --- a/roles/base/tasks/archinstall/mirrorlist.yaml +++ b/roles/base/tasks/archinstall/mirrorlist.yaml @@ -1,4 +1,4 @@ --- - name: Select fastest Arch repository mirrors - ansible.builtin.command: + command: cmd: reflector --country US --latest 5 --sort rate --save /etc/pacman.d/mirrorlist diff --git a/roles/base/tasks/archinstall/partition.yaml b/roles/base/tasks/archinstall/partition.yaml index 116ed88..696b38a 100644 --- a/roles/base/tasks/archinstall/partition.yaml +++ b/roles/base/tasks/archinstall/partition.yaml @@ -1,28 +1,34 @@ --- -- name: Partition | get details about rootfs disks +- name: Get details about rootfs disks community.general.parted: device: "{{ item }}" unit: MiB register: base_root_disks_info loop: "{{ base_root_disks | list }}" -- name: Partition | calculate maximum usable disk space +- name: partition | ensure efi is not mounted + mount: + path: /mnt/boot/efi + state: unmounted + +- name: Calculate maximum usable disk space ansible.builtin.set_fact: base_root_usable_mib: "{{ (base_root_disks_info.results | map(attribute='disk.size') | min | int) - 1 }}" -- name: Partition | 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 }}" +- debug: var=base_root_usable_mib -- name: Partition | calculate zroot ZFS pool size +- name: Calculate disk utilization percentage ansible.builtin.set_fact: - base_root_zpool_mib: "{{ base_root_usable_mib | int - fixed_size_partitions | 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 }}" 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: Partition | calculate partition layouts - ansible.builtin.set_fact: +- name: Calculate partition layouts + set_fact: partition_ranges: >- {{ (partition_ranges|d([])) + [{ @@ -30,7 +36,7 @@ 'end': partitions[:(loop_index|int+1)] | map(attribute='size_mib') | map('int') | sum(), }] }} - with_sequence: start=0 end="{{ partitions | length - 1 }}" + with_sequence: start=0 end="{{ partitions | length - 1}}" vars: loop_index: "{{ item }}" partitions: @@ -41,44 +47,41 @@ - name: swap size_mib: "{{ base_root_swap_mib }}" -- name: Partition | initialize partitioning facts - ansible.builtin.set_fact: +- debug: + var: partition_ranges + +- name: Initialize partition facts + set_fact: base_efi_partitions: [] base_root_partitions: [] base_swap_partitions: [] -- name: Partition | ensure efi is not mounted - ansible.posix.mount: - path: /mnt/boot/efi - state: unmounted - #### efi/boot -- name: Partition | create EFI boot partition +- name: Create EFI partition become: true vars: part_index: 0 - community.general.parted: + 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 loop: "{{ base_root_disks_info.results }}" register: parted_create -- name: Partition | collect EFI boot partition devices - ansible.builtin.shell: "lsblk -r --noheadings -o PATH {{ item }} | sort" +- name: Collect EFI partition devices + shell: "lsblk -r --noheadings -o PATH {{ item }} | sort" register: lsblk loop: "{{ parted_create.results | map(attribute='disk.dev') }}" - changed_when: false - name: Store EFI partition devices - ansible.builtin.set_fact: + set_fact: base_efi_partitions: >- {{ base_efi_partitions|d([]) + [ item[part_index+1] @@ -87,14 +90,15 @@ loop: "{{ lsblk.results | map(attribute='stdout_lines') | sort }}" vars: part_index: 0 - changed_when: false -#### zroot zfs pool -- name: Partition | create root ZFS pool partition +- debug: var=base_efi_partitions + +#### zroot +- name: Create root zvol partition become: true vars: part_index: 1 - community.general.parted: + parted: label: gpt unit: MiB name: ArchLinux ZFS Root @@ -106,14 +110,13 @@ loop: "{{ parted_create.results }}" register: parted_create -- name: Partition | collect root ZFS pool partition devices - ansible.builtin.shell: "lsblk -r --noheadings -o PATH {{ item }} | sort" +- name: Collect root zvol partition devices + shell: "lsblk -r --noheadings -o PATH {{ item }} | sort" register: lsblk loop: "{{ parted_create.results | map(attribute='disk.dev') }}" - changed_when: false -- name: Partition | store root ZFS pool partition devices - ansible.builtin.set_fact: +- name: Store root zvol partition devices + set_fact: base_root_partitions: >- {{ base_root_partitions|d([]) + [ item[part_index+1] @@ -122,14 +125,13 @@ loop: "{{ lsblk.results | map(attribute='stdout_lines') | sort }}" vars: part_index: 1 - changed_when: false -#### swap partitions -- name: Partition | create swap partition +#### swap +- name: Create swap partition become: true vars: part_index: 2 - community.general.parted: + parted: label: gpt unit: MiB device: "{{ item.disk.dev }}" @@ -142,15 +144,14 @@ register: parted_create when: base_root_swap_mib is defined and base_root_swap_mib|int > 0 -- name: Partition | Collect swap partition devices - ansible.builtin.shell: "set -o pipefail; lsblk -r --noheadings -o PATH {{ item }} | sort" +- name: Collect swap partition devices + 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 - changed_when: false -- name: Partition | Store swap partition devices - ansible.builtin.set_fact: +- name: Store swap partition devices + set_fact: base_swap_partitions: >- {{ base_swap_partitions|d([]) + [ item[part_index+1] @@ -160,22 +161,20 @@ vars: part_index: 2 when: base_root_swap_mib is defined and base_root_swap_mib|int > 0 - changed_when: false -- name: Partition | Analyze resulting partition layouts - community.general.parted: +- name: Analyze resulting partition layouts + parted: unit: MiB device: "{{ item }}" register: base_root_disks_info loop: "{{ base_root_disks | list }}" -- name: Partition | Collect disk device identifiers - ansible.builtin.shell: "set -o pipefail; for x in /dev/disk/by-id/*; do echo $x $(realpath $x); done" +- name: Collect disk device identifiers + shell: "for x in /dev/disk/by-id/*; do echo $x $(realpath $x); done" register: disk_realpaths - changed_when: false -- name: Partition | Collect disk device identifiers into a base_partitions_by_id dictionary - ansible.builtin.set_fact: +- name: Collect disk device identifiers into a base_partitions_by_id dictionary + set_fact: base_partitions_by_id: >- {{ dict( @@ -184,3 +183,7 @@ | map('list') ) }} + +- debug: var=base_efi_partitions +- debug: var=base_root_partitions +- debug: var=base_swap_partitions diff --git a/roles/base/tasks/archinstall/postinstall_snapshot.yaml b/roles/base/tasks/archinstall/postinstall_snapshot.yaml index 5968140..d25cb28 100644 --- a/roles/base/tasks/archinstall/postinstall_snapshot.yaml +++ b/roles/base/tasks/archinstall/postinstall_snapshot.yaml @@ -1,11 +1,10 @@ ---- -- 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 }}" diff --git a/roles/base/tasks/archinstall/prepare_chroot.yaml b/roles/base/tasks/archinstall/prepare_chroot.yaml index a67cf80..2e68b80 100644 --- a/roles/base/tasks/archinstall/prepare_chroot.yaml +++ b/roles/base/tasks/archinstall/prepare_chroot.yaml @@ -1,23 +1,20 @@ --- -- name: Arch Install | Chroot | Mount arch zroot - ansible.builtin.command: zfs mount zroot/ROOT/arch - changed_when: false +- name: Mount arch zroot + command: zfs mount zroot/ROOT/arch -- name: Arch Install | Chroot | Mount all other zroot mountpoints - ansible.builtin.command: zfs mount -a - changed_when: false +- name: Mount all other zroot mountpoints + command: zfs mount -a -- name: Arch Install | Chroot | Create zroot destination directories +- name: Create zroot destination directories ansible.builtin.file: path: "/mnt{{ item }}" state: directory - owner: root - group: root - mode: '0755' loop: - /etc/zfs - /boot/efi +- debug: var=base_efi_partitions + - name: Mount EFI ansible.posix.mount: path: /mnt/boot/efi @@ -25,19 +22,11 @@ fstype: vfat state: mounted -- name: Arch Chroot | zpool | Set zroot bootfs to arch - ansible.builtin.command: zpool set bootfs=zroot/ROOT/arch zroot - changed_when: false +- name: zfs | set zroot bootfs to arch + command: zpool set bootfs=zroot/ROOT/arch zroot -- name: Arch Chroot | zpool | Set cachefile - ansible.builtin.command: zpool set cachefile=/etc/zfs/zpool.cache zroot - changed_when: false +- name: zfs | set cachefile + command: zpool set cachefile=/etc/zfs/zpool.cache zroot -- 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" +- name: zfs | copy cache file to chroot + command: cp /etc/zfs/zpool.cache /mnt/etc/zfs diff --git a/roles/base/tasks/main.yaml b/roles/base/tasks/main.yaml index 99fa190..d9aba5c 100644 --- a/roles/base/tasks/main.yaml +++ b/roles/base/tasks/main.yaml @@ -1,15 +1,15 @@ --- -- 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=" - - ansible.builtin.import_tasks: archinstall/mirrorlist.yaml - - ansible.builtin.import_tasks: archinstall/partition.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_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 +- block: + - name: ensure root_password is set + assert: + that: root_password is defined + msg: "please specify a root password via -e root_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 diff --git a/roles/detect_archiso/tasks/main.yaml b/roles/detect_archiso/tasks/main.yaml index 9048005..ec3e07a 100644 --- a/roles/detect_archiso/tasks/main.yaml +++ b/roles/detect_archiso/tasks/main.yaml @@ -1,10 +1,9 @@ --- -- name: Check for archinstall in path - ansible.builtin.command: which archinstall - changed_when: false +- name: check for archinstall in path + command: which archinstall ignore_errors: true register: which_archinstall -- name: Inspect archinstall check result - ansible.builtin.set_fact: +- name: inspect archinstall check result + set_fact: archiso_detected: "{{ which_archinstall.rc == 0 }}" diff --git a/roles/dotfiles/tasks/main.yaml b/roles/dotfiles/tasks/main.yaml index f7c141c..74424f9 100644 --- a/roles/dotfiles/tasks/main.yaml +++ b/roles/dotfiles/tasks/main.yaml @@ -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 }}" - ansible.builtin.shell: - cmd: "set -o pipefail; curl -o- -L {{ dotfiles_url }} | {{ dotfiles_shell }}" + shell: + cmd: "curl -o- -L {{ dotfiles_url }} | {{ dotfiles_shell }}" creates: "/home/{{ dotfiles_user }}/.dotfiles" register: dotfiles diff --git a/roles/software/defaults/main.yaml b/roles/software/defaults/main.yaml index 47e8841..d473ea5 100644 --- a/roles/software/defaults/main.yaml +++ b/roles/software/defaults/main.yaml @@ -1,2 +1 @@ ---- -software_desktop_user: mark +desktop_user: mark diff --git a/roles/software/tasks/main.yaml b/roles/software/tasks/main.yaml index 74f0a28..8f8a139 100644 --- a/roles/software/tasks/main.yaml +++ b/roles/software/tasks/main.yaml @@ -1,17 +1,12 @@ --- -- name: Install system package groups +- 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 - block: - - name: Update pacman cache - community.general.pacman: - update_cache: true - - name: Minimal - ansible.builtin.import_tasks: software/minimal.yaml - - name: Desktop - ansible.builtin.import_tasks: software/desktop.yaml - - name: Graphics - 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 diff --git a/roles/software/tasks/software/desktop.yaml b/roles/software/tasks/software/desktop.yaml index db90571..40aff55 100644 --- a/roles/software/tasks/software/desktop.yaml +++ b/roles/software/tasks/software/desktop.yaml @@ -1,6 +1,5 @@ ---- -- name: Install desktop packages - ansible.builtin.package: +- name: install desktop packages + package: state: present name: - adwaita-cursors @@ -25,7 +24,6 @@ - solaar - swappy - sway - - swaybg - syncthing - telegram-desktop - thunar @@ -37,77 +35,70 @@ - xdg-user-dirs - xorg-xwayland -- name: Install AUR packages +- name: install AUR packages become: true - become_user: "{{ software_desktop_user }}" - ansible.builtin.command: >- + become_user: "{{ desktop_user }}" + shell: >- paru -Sy --needed --noconfirm {{ packages | join(' ') }} - changed_when: true vars: packages: - dracula-gtk-theme-full - ttf-envy-code-r - winbox -- name: Enable linger for desktop user - ansible.builtin.command: - cmd: "loginctl enable-linger {{ software_desktop_user }}" - creates: "/var/lib/systemd/linger/{{ software_desktop_user }}" +- name: loginctl | enable linger for desktop user + command: "loginctl enable-linger {{ desktop_user }}" -- name: Syncthing | Generate default config - become: true - become_user: "{{ software_desktop_user }}" - ansible.builtin.command: - cmd: syncthing generate --no-default-folder --skip-port-probing - creates: "/home/{{ software_deskop_user }}/.local/state/syncthing/config.xml" +- name: syncthing | generate default config + become: yes + become_user: "{{ desktop_user }}" + command: >- + syncthing generate --no-default-folder --skip-port-probing -- name: Syncthing | Enable user systemd unit - ansible.builtin.systemd: +- name: syncthing | enable user systemd unit + systemd: name: syncthing.service enabled: true state: started scope: user become: true - become_user: "{{ software_desktop_user }}" + become_user: "{{ desktop_user }}" -- name: Greetd | configure | use tuigreet +- 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 - ansible.builtin.systemd: +- name: greetd | enable systemd unit + systemd: name: greetd enabled: true -- name: Bluetooth | Enable systemd unit - ansible.builtin.systemd: +- name: bluetooth | enable systemd unit + systemd: name: bluetooth enabled: true -- name: Wal | Set initial colorscheme +- name: wal | set initial colorscheme become: true - become_user: "{{ software_desktop_user }}" - ansible.builtin.command: wal --theme hybrid-material - changed_when: false + become_user: "{{ desktop_user }}" + shell: wal --theme hybrid-material -- name: Sway | Reload if running +- name: sway | reload if running become: true - become_user: "{{ software_desktop_user }}" - ansible.builtin.shell: set -o pipefail; pidof sway && SWAYSOCK=$(ls /run/user/*/sway-ipc.*.sock | head -n 1) swaymsg reload - failed_when: false - changed_when: false + become_user: "{{ desktop_user }}" + shell: pidof sway && SWAYSOCK=$(ls /run/user/*/sway-ipc.*.sock | head -n 1) swaymsg reload + ignore_errors: true -- name: Graphics | Probe for graphics cards - ansible.builtin.shell: set -o pipefail; lspci -nnk | grep -A 3 -E "VGA|3D" +- name: graphics | probe for graphics cards + shell: lspci -nnk | grep -A 3 -E "VGA|3D" register: lspci - changed_when: false -- name: Graphics | Install radeon specific packages - ansible.builtin.package: +- name: graphics | install radeon specific packages + package: state: present name: - - hip-runtime-amd - - rocm-opencl-runtime - - vulkan-radeon + - hip-runtime-amd + - rocm-opencl-runtime + - vulkan-radeon diff --git a/roles/software/tasks/software/dev.yaml b/roles/software/tasks/software/dev.yaml index c43327e..3094e0f 100644 --- a/roles/software/tasks/software/dev.yaml +++ b/roles/software/tasks/software/dev.yaml @@ -1,6 +1,5 @@ ---- -- name: Install gamedev packages - ansible.builtin.package: +- name: install gamedev packages + package: state: present name: - neovim diff --git a/roles/software/tasks/software/gamedev.yaml b/roles/software/tasks/software/gamedev.yaml index 043eadb..da2bea4 100644 --- a/roles/software/tasks/software/gamedev.yaml +++ b/roles/software/tasks/software/gamedev.yaml @@ -1,6 +1,5 @@ ---- -- name: Install gamedev packages - ansible.builtin.package: +- name: install gamedev packages + package: state: present name: - godot diff --git a/roles/software/tasks/software/graphics.yaml b/roles/software/tasks/software/graphics.yaml index 73e8d8a..a2d7964 100644 --- a/roles/software/tasks/software/graphics.yaml +++ b/roles/software/tasks/software/graphics.yaml @@ -1,6 +1,5 @@ ---- -- name: Install graphics packages - ansible.builtin.package: +- name: install graphics packages + package: state: present name: - blender diff --git a/roles/software/tasks/software/minimal.yaml b/roles/software/tasks/software/minimal.yaml index 13c347a..3e75fe1 100644 --- a/roles/software/tasks/software/minimal.yaml +++ b/roles/software/tasks/software/minimal.yaml @@ -1,11 +1,10 @@ ---- -- name: Install minimal packages - ansible.builtin.package: +- name: install minimal packages + package: state: present name: - eza - fzf - htop - ripgrep - - unzip + - zip - zsh