tweaks for lint happiness
This commit is contained in:
parent
5d78efcac5
commit
c6f5d3546a
12 changed files with 128 additions and 104 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue