tweaks for lint happiness
This commit is contained in:
parent
5d78efcac5
commit
c6f5d3546a
12 changed files with 128 additions and 104 deletions
|
@ -4,8 +4,10 @@
|
|||
ansible.builtin.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 }}"
|
||||
loop: "{{ blkid.results | rejectattr('stdout', 'contains', 'TYPE=\"vfat\"') }}"
|
||||
register: mkfs_vfat_efi
|
||||
changed_when: true
|
||||
|
|
|
@ -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
|
||||
register: zroot_check
|
||||
changed_when: false
|
||||
ignore_errors: true
|
||||
|
||||
- when: zroot_check.rc != 0
|
||||
|
||||
- name: Root ZFS Pool |
|
||||
when: zroot_check.rc != 0
|
||||
block:
|
||||
- name: Initialize disk device to id table
|
||||
- name: Root ZFS Pool | initialize disk device to id table
|
||||
ansible.builtin.set_fact:
|
||||
partition_device_to_ids: {}
|
||||
|
||||
- name: Create disk device to id table
|
||||
- name: Root ZFS Pool | create disk device -> id table
|
||||
ansible.builtin.set_fact:
|
||||
partition_device_to_ids: >-
|
||||
{{
|
||||
|
@ -20,10 +21,7 @@
|
|||
}}
|
||||
with_items: "{{ base_partitions_by_id | dict2items }}"
|
||||
|
||||
- ansible.builtin.debug:
|
||||
var: base_root_partitions | map('extract', partition_device_to_ids) | map('first')
|
||||
|
||||
- name: Create zroot volume
|
||||
- name: Root ZFS Pool | create zroot volume
|
||||
become: true
|
||||
ansible.builtin.command: >-
|
||||
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(' ') }}
|
||||
vars:
|
||||
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:
|
||||
name: "zroot/{{ item }}"
|
||||
state: present
|
||||
register: zfs_zroot_root_volume
|
||||
with_items: [ROOT, DATA]
|
||||
|
||||
- name: Create zroot/ROOT/arch
|
||||
- name: Root ZFS Pool | create zroot/ROOT/arch
|
||||
community.general.zfs:
|
||||
name: zroot/ROOT/arch
|
||||
state: present
|
||||
|
@ -56,14 +56,17 @@
|
|||
mountpoint: /
|
||||
when: zfs_zroot_root_volume.changed
|
||||
|
||||
- name: Create zroot/home
|
||||
- name: Root ZFS Pool | create zroot/DATA/home
|
||||
community.general.zfs:
|
||||
name: zroot/DATA/home
|
||||
state: present
|
||||
extra_zfs_properties:
|
||||
mountpoint: /home
|
||||
|
||||
- name: Export zroot pool
|
||||
- name: Root ZFS Pool | Export zroot pool
|
||||
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
|
||||
changed_when: false
|
|
@ -1,12 +1,12 @@
|
|||
---
|
||||
- name: Initialize swap space
|
||||
become: true
|
||||
ansible.builtin.command: "blkid {{item}}"
|
||||
ansible.builtin.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}}"
|
||||
ansible.builtin.command: "mkswap --verbose {{ item.item }}"
|
||||
loop: "{{ blkid.results | rejectattr('stdout', 'contains', 'TYPE=\"swap\"') }}"
|
||||
register: mkswap
|
||||
|
|
|
@ -1,34 +1,27 @@
|
|||
---
|
||||
- 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
|
||||
ansible.posix.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 }}"
|
||||
|
||||
- ansible.builtin.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 }}"
|
||||
|
||||
- name: Calculate zfs volume size
|
||||
- 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 }}"
|
||||
#
|
||||
- name: Calculate partition layouts
|
||||
- name: Partition | calculate partition layouts
|
||||
ansible.builtin.set_fact:
|
||||
partition_ranges: >-
|
||||
{{
|
||||
|
@ -37,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:
|
||||
|
@ -48,17 +41,19 @@
|
|||
- name: swap
|
||||
size_mib: "{{ base_root_swap_mib }}"
|
||||
|
||||
- ansible.builtin.debug:
|
||||
var: partition_ranges
|
||||
|
||||
- name: Initialize partition facts
|
||||
- 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
|
||||
|
@ -76,10 +71,11 @@
|
|||
loop: "{{ base_root_disks_info.results }}"
|
||||
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"
|
||||
register: lsblk
|
||||
loop: "{{ parted_create.results | map(attribute='disk.dev') }}"
|
||||
changed_when: false
|
||||
|
||||
- name: Store EFI partition devices
|
||||
ansible.builtin.set_fact:
|
||||
|
@ -91,10 +87,10 @@
|
|||
loop: "{{ lsblk.results | map(attribute='stdout_lines') | sort }}"
|
||||
vars:
|
||||
part_index: 0
|
||||
changed_when: false
|
||||
|
||||
- ansible.builtin.debug:
|
||||
var: base_efi_partitions
|
||||
- name: Create root zvol partition
|
||||
#### zroot zfs pool
|
||||
- name: Partition | create root ZFS pool partition
|
||||
become: true
|
||||
vars:
|
||||
part_index: 1
|
||||
|
@ -110,12 +106,13 @@
|
|||
loop: "{{ parted_create.results }}"
|
||||
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"
|
||||
register: lsblk
|
||||
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:
|
||||
base_root_partitions: >-
|
||||
{{ base_root_partitions|d([]) + [
|
||||
|
@ -125,9 +122,10 @@
|
|||
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
|
||||
|
@ -144,13 +142,14 @@
|
|||
register: parted_create
|
||||
when: base_root_swap_mib is defined and base_root_swap_mib|int > 0
|
||||
|
||||
- name: Collect swap partition devices
|
||||
ansible.builtin.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
|
||||
- name: Partition | Store swap partition devices
|
||||
ansible.builtin.set_fact:
|
||||
base_swap_partitions: >-
|
||||
{{ base_swap_partitions|d([]) + [
|
||||
|
@ -161,19 +160,21 @@
|
|||
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
|
||||
- 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
|
||||
ansible.builtin.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
|
||||
- name: Partition | Collect disk device identifiers into a base_partitions_by_id dictionary
|
||||
ansible.builtin.set_fact:
|
||||
base_partitions_by_id: >-
|
||||
{{
|
||||
|
@ -183,10 +184,3 @@
|
|||
| map('list')
|
||||
)
|
||||
}}
|
||||
|
||||
- ansible.builtin.debug:
|
||||
var: base_efi_partitions
|
||||
- ansible.builtin.debug:
|
||||
var: base_root_partitions
|
||||
- ansible.builtin.debug:
|
||||
var: base_swap_partitions
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
---
|
||||
- name: Mount arch zroot
|
||||
- name: Arch Install | Chroot | Mount arch zroot
|
||||
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
|
||||
- name: Create zroot destination directories
|
||||
changed_when: false
|
||||
|
||||
- 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
|
||||
|
||||
- ansible.builtin.debug:
|
||||
var: base_efi_partitions
|
||||
- name: Mount EFI
|
||||
ansible.posix.mount:
|
||||
path: /mnt/boot/efi
|
||||
|
@ -20,9 +25,19 @@
|
|||
fstype: vfat
|
||||
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
|
||||
- name: zfs | Set cachefile
|
||||
changed_when: false
|
||||
|
||||
- name: Arch Chroot | zpool | 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
|
||||
changed_when: false
|
||||
|
||||
- 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"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
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_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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue