diff --git a/local.yml b/local.yml index 1aa4698..9becd98 100644 --- a/local.yml +++ b/local.yml @@ -1,2 +1,3 @@ --- -- import_playbook: playbooks/install.yaml +- name: OS Install + import_playbook: playbooks/install.yaml diff --git a/playbooks/info.yaml b/playbooks/info.yaml deleted file mode 100644 index c5381ad..0000000 --- a/playbooks/info.yaml +++ /dev/null @@ -1,6 +0,0 @@ -- 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 b290e86..c7b8300 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 d045fbd..47daad6 100644 --- a/playbooks/post-install.yaml +++ b/playbooks/post-install.yaml @@ -1,4 +1,5 @@ -- 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 9f4e836..2312599 100644 --- a/roles/base/tasks/archinstall/initialize_efi.yaml +++ b/roles/base/tasks/archinstall/initialize_efi.yaml @@ -1,11 +1,13 @@ --- - name: Inspect EFI boot partitions become: true - command: "blkid {{ item }}" + ansible.builtin.command: "blkid {{ item }}" loop: "{{ base_efi_partitions | default([]) }}" register: blkid + changed_when: false - 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 + 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 new file mode 100644 index 0000000..87ca78a --- /dev/null +++ b/roles/base/tasks/archinstall/initialize_root_zfs_pool.yaml @@ -0,0 +1,72 @@ +--- +- 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 deleted file mode 100644 index 1421e83..0000000 --- a/roles/base/tasks/archinstall/initialize_root_zvol.yaml +++ /dev/null @@ -1,70 +0,0 @@ ---- -- 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 83a0a72..75f5d50 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 - 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 diff --git a/roles/base/tasks/archinstall/install_os.yaml b/roles/base/tasks/archinstall/install_os.yaml index db2fbd6..eea201c 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 - 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 diff --git a/roles/base/tasks/archinstall/mirrorlist.yaml b/roles/base/tasks/archinstall/mirrorlist.yaml index 08af6ee..a1225b3 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 - command: + ansible.builtin.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 696b38a..116ed88 100644 --- a/roles/base/tasks/archinstall/partition.yaml +++ b/roles/base/tasks/archinstall/partition.yaml @@ -1,34 +1,28 @@ --- -- name: Get details about rootfs disks +- name: Partition | get details about rootfs disks community.general.parted: device: "{{ item }}" unit: MiB register: base_root_disks_info loop: "{{ base_root_disks | list }}" -- name: partition | ensure efi is not mounted - mount: - path: /mnt/boot/efi - state: unmounted - -- name: Calculate maximum usable disk space +- name: Partition | 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 }}" -- debug: var=base_root_usable_mib - -- name: Calculate disk utilization percentage +- 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 }}" + 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 }}" +- name: Partition | calculate zroot ZFS pool size + 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: +- name: Partition | calculate partition layouts + ansible.builtin.set_fact: partition_ranges: >- {{ (partition_ranges|d([])) + [{ @@ -36,7 +30,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: @@ -47,41 +41,44 @@ - name: swap size_mib: "{{ base_root_swap_mib }}" -- debug: - var: partition_ranges - -- name: Initialize partition facts - set_fact: +- name: Partition | initialize partitioning facts + ansible.builtin.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: Create EFI partition +- name: Partition | create EFI boot partition 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 loop: "{{ base_root_disks_info.results }}" register: parted_create -- name: Collect EFI partition devices - shell: "lsblk -r --noheadings -o PATH {{ item }} | sort" +- name: Partition | collect EFI boot partition devices + ansible.builtin.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 - set_fact: + ansible.builtin.set_fact: base_efi_partitions: >- {{ base_efi_partitions|d([]) + [ item[part_index+1] @@ -90,15 +87,14 @@ loop: "{{ lsblk.results | map(attribute='stdout_lines') | sort }}" vars: part_index: 0 + changed_when: false -- debug: var=base_efi_partitions - -#### zroot -- name: Create root zvol partition +#### zroot zfs pool +- name: Partition | create root ZFS pool partition become: true vars: part_index: 1 - parted: + community.general.parted: label: gpt unit: MiB name: ArchLinux ZFS Root @@ -110,13 +106,14 @@ loop: "{{ parted_create.results }}" register: parted_create -- name: Collect root zvol partition devices - shell: "lsblk -r --noheadings -o PATH {{ item }} | sort" +- name: Partition | collect root ZFS pool partition devices + ansible.builtin.shell: "lsblk -r --noheadings -o PATH {{ item }} | sort" register: lsblk loop: "{{ parted_create.results | map(attribute='disk.dev') }}" + changed_when: false -- name: Store root zvol partition devices - set_fact: +- name: Partition | store root ZFS pool partition devices + ansible.builtin.set_fact: base_root_partitions: >- {{ base_root_partitions|d([]) + [ item[part_index+1] @@ -125,13 +122,14 @@ loop: "{{ lsblk.results | map(attribute='stdout_lines') | sort }}" vars: part_index: 1 + changed_when: false -#### swap -- name: Create swap partition +#### swap partitions +- name: Partition | create swap partition become: true vars: part_index: 2 - parted: + community.general.parted: label: gpt unit: MiB device: "{{ item.disk.dev }}" @@ -144,14 +142,15 @@ register: parted_create 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" +- name: Partition | Collect swap partition devices + ansible.builtin.shell: "set -o pipefail; 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: Store swap partition devices - set_fact: +- name: Partition | Store swap partition devices + ansible.builtin.set_fact: base_swap_partitions: >- {{ base_swap_partitions|d([]) + [ item[part_index+1] @@ -161,20 +160,22 @@ vars: part_index: 2 when: base_root_swap_mib is defined and base_root_swap_mib|int > 0 + changed_when: false -- name: Analyze resulting partition layouts - parted: +- name: Partition | Analyze resulting partition layouts + 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" +- 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" register: disk_realpaths + changed_when: false -- name: Collect disk device identifiers into a base_partitions_by_id dictionary - set_fact: +- name: Partition | Collect disk device identifiers into a base_partitions_by_id dictionary + ansible.builtin.set_fact: base_partitions_by_id: >- {{ dict( @@ -183,7 +184,3 @@ | 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 d25cb28..5968140 100644 --- a/roles/base/tasks/archinstall/postinstall_snapshot.yaml +++ b/roles/base/tasks/archinstall/postinstall_snapshot.yaml @@ -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 }}" diff --git a/roles/base/tasks/archinstall/prepare_chroot.yaml b/roles/base/tasks/archinstall/prepare_chroot.yaml index 2e68b80..a67cf80 100644 --- a/roles/base/tasks/archinstall/prepare_chroot.yaml +++ b/roles/base/tasks/archinstall/prepare_chroot.yaml @@ -1,20 +1,23 @@ --- -- name: Mount arch zroot - command: zfs mount zroot/ROOT/arch +- name: Arch Install | Chroot | Mount arch zroot + ansible.builtin.command: zfs mount zroot/ROOT/arch + changed_when: false -- name: Mount all other zroot mountpoints - command: zfs mount -a +- name: Arch Install | Chroot | Mount all other zroot mountpoints + ansible.builtin.command: zfs mount -a + changed_when: false -- name: Create zroot destination directories +- name: Arch Install | Chroot | 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 @@ -22,11 +25,19 @@ fstype: vfat state: mounted -- name: zfs | set zroot bootfs to arch - command: zpool set bootfs=zroot/ROOT/arch zroot +- 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 cachefile - command: zpool set cachefile=/etc/zfs/zpool.cache zroot +- name: Arch Chroot | zpool | Set cachefile + ansible.builtin.command: zpool set cachefile=/etc/zfs/zpool.cache zroot + changed_when: false -- name: zfs | copy cache file to chroot - 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" diff --git a/roles/base/tasks/main.yaml b/roles/base/tasks/main.yaml index d9aba5c..99fa190 100644 --- a/roles/base/tasks/main.yaml +++ b/roles/base/tasks/main.yaml @@ -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=" - - 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=" + - 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 diff --git a/roles/detect_archiso/tasks/main.yaml b/roles/detect_archiso/tasks/main.yaml index ec3e07a..9048005 100644 --- a/roles/detect_archiso/tasks/main.yaml +++ b/roles/detect_archiso/tasks/main.yaml @@ -1,9 +1,10 @@ --- -- name: check for archinstall in path - command: which archinstall +- name: Check for archinstall in path + ansible.builtin.command: which archinstall + changed_when: false 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 }}" diff --git a/roles/dotfiles/tasks/main.yaml b/roles/dotfiles/tasks/main.yaml index 74424f9..f7c141c 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 }}" - shell: - cmd: "curl -o- -L {{ dotfiles_url }} | {{ dotfiles_shell }}" + ansible.builtin.shell: + cmd: "set -o pipefail; 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 d473ea5..47e8841 100644 --- a/roles/software/defaults/main.yaml +++ b/roles/software/defaults/main.yaml @@ -1 +1,2 @@ -desktop_user: mark +--- +software_desktop_user: mark diff --git a/roles/software/tasks/main.yaml b/roles/software/tasks/main.yaml index 8f8a139..74f0a28 100644 --- a/roles/software/tasks/main.yaml +++ b/roles/software/tasks/main.yaml @@ -1,12 +1,17 @@ --- -- 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 +- name: Install system package groups 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 40aff55..db90571 100644 --- a/roles/software/tasks/software/desktop.yaml +++ b/roles/software/tasks/software/desktop.yaml @@ -1,5 +1,6 @@ -- name: install desktop packages - package: +--- +- name: Install desktop packages + ansible.builtin.package: state: present name: - adwaita-cursors @@ -24,6 +25,7 @@ - solaar - swappy - sway + - swaybg - syncthing - telegram-desktop - thunar @@ -35,70 +37,77 @@ - xdg-user-dirs - xorg-xwayland -- name: install AUR packages +- name: Install AUR packages become: true - become_user: "{{ desktop_user }}" - shell: >- + become_user: "{{ software_desktop_user }}" + ansible.builtin.command: >- paru -Sy --needed --noconfirm {{ packages | join(' ') }} + changed_when: true vars: packages: - dracula-gtk-theme-full - ttf-envy-code-r - winbox -- name: loginctl | enable linger for desktop user - command: "loginctl enable-linger {{ desktop_user }}" +- 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: syncthing | generate default config - become: yes - become_user: "{{ desktop_user }}" - command: >- - syncthing generate --no-default-folder --skip-port-probing +- 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 | enable user systemd unit - systemd: +- name: Syncthing | Enable user systemd unit + ansible.builtin.systemd: name: syncthing.service enabled: true state: started scope: user become: true - become_user: "{{ desktop_user }}" + become_user: "{{ software_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 - 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 + become_user: "{{ software_desktop_user }}" + ansible.builtin.command: wal --theme hybrid-material + changed_when: false -- name: sway | reload if running +- 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 - ignore_errors: 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 -- name: graphics | probe for graphics cards - shell: lspci -nnk | grep -A 3 -E "VGA|3D" +- name: Graphics | Probe for graphics cards + ansible.builtin.shell: set -o pipefail; lspci -nnk | grep -A 3 -E "VGA|3D" register: lspci + changed_when: false -- 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 diff --git a/roles/software/tasks/software/dev.yaml b/roles/software/tasks/software/dev.yaml index 3094e0f..c43327e 100644 --- a/roles/software/tasks/software/dev.yaml +++ b/roles/software/tasks/software/dev.yaml @@ -1,5 +1,6 @@ -- name: install gamedev packages - package: +--- +- name: Install gamedev packages + ansible.builtin.package: state: present name: - neovim diff --git a/roles/software/tasks/software/gamedev.yaml b/roles/software/tasks/software/gamedev.yaml index da2bea4..043eadb 100644 --- a/roles/software/tasks/software/gamedev.yaml +++ b/roles/software/tasks/software/gamedev.yaml @@ -1,5 +1,6 @@ -- name: install gamedev packages - package: +--- +- name: Install gamedev packages + ansible.builtin.package: state: present name: - godot diff --git a/roles/software/tasks/software/graphics.yaml b/roles/software/tasks/software/graphics.yaml index a2d7964..73e8d8a 100644 --- a/roles/software/tasks/software/graphics.yaml +++ b/roles/software/tasks/software/graphics.yaml @@ -1,5 +1,6 @@ -- name: install graphics packages - package: +--- +- name: Install graphics packages + ansible.builtin.package: state: present name: - blender diff --git a/roles/software/tasks/software/minimal.yaml b/roles/software/tasks/software/minimal.yaml index 3e75fe1..13c347a 100644 --- a/roles/software/tasks/software/minimal.yaml +++ b/roles/software/tasks/software/minimal.yaml @@ -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