refactor(vars): simplify normalization and remove effective intermediates
This commit is contained in:
@@ -155,14 +155,11 @@
|
||||
|
||||
- name: Configure LUKS encryption
|
||||
when: partitioning_luks_enabled | bool
|
||||
vars:
|
||||
partitioning_luks_passphrase_effective: >-
|
||||
{{ partitioning_luks_passphrase | string }}
|
||||
block:
|
||||
- name: Validate LUKS passphrase
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- partitioning_luks_passphrase_effective | length > 0
|
||||
- (partitioning_luks_passphrase | string | length) > 0
|
||||
fail_msg: system.luks.passphrase must be set when LUKS is enabled.
|
||||
no_log: true
|
||||
|
||||
@@ -177,7 +174,7 @@
|
||||
pbkdf:
|
||||
algorithm: "{{ partitioning_luks_pbkdf }}"
|
||||
iteration_time: "{{ (partitioning_luks_iter_time | float) / 1000 }}"
|
||||
passphrase: "{{ partitioning_luks_passphrase_effective }}"
|
||||
passphrase: "{{ partitioning_luks_passphrase | string }}"
|
||||
register: partitioning_luks_format_result
|
||||
no_log: true
|
||||
|
||||
@@ -206,7 +203,7 @@
|
||||
device: "{{ partitioning_luks_device }}"
|
||||
state: opened
|
||||
name: "{{ partitioning_luks_mapper_name }}"
|
||||
passphrase: "{{ partitioning_luks_passphrase_effective }}"
|
||||
passphrase: "{{ partitioning_luks_passphrase | string }}"
|
||||
allow_discards: "{{ 'discard' in (partitioning_luks_options | lower) }}"
|
||||
register: partitioning_luks_open_result
|
||||
no_log: true
|
||||
@@ -234,7 +231,7 @@
|
||||
device: "{{ partitioning_luks_device }}"
|
||||
state: opened
|
||||
name: "{{ partitioning_luks_mapper_name }}"
|
||||
passphrase: "{{ partitioning_luks_passphrase_effective }}"
|
||||
passphrase: "{{ partitioning_luks_passphrase | string }}"
|
||||
allow_discards: "{{ 'discard' in (partitioning_luks_options | lower) }}"
|
||||
register: partitioning_luks_open_retry
|
||||
no_log: true
|
||||
@@ -275,7 +272,7 @@
|
||||
{{
|
||||
(
|
||||
[
|
||||
(partitioning_vm_memory_effective | float / 1024),
|
||||
(partitioning_memory_mb | float / 1024),
|
||||
4
|
||||
] | max | float
|
||||
)
|
||||
@@ -287,14 +284,14 @@
|
||||
(
|
||||
4
|
||||
+ [
|
||||
(partitioning_vm_size_effective | float) - 20,
|
||||
(partitioning_disk_size_gb | float) - 20,
|
||||
0
|
||||
] | max
|
||||
)
|
||||
if system_cfg.features.swap.enabled | bool
|
||||
else 0
|
||||
}}
|
||||
partitioning_lvm_swap_target_effective_gb: >-
|
||||
partitioning_lvm_swap_target_limited_gb: >-
|
||||
{{
|
||||
(
|
||||
[
|
||||
@@ -310,7 +307,7 @@
|
||||
(
|
||||
[
|
||||
(
|
||||
(partitioning_vm_size_effective | float)
|
||||
(partitioning_disk_size_gb | float)
|
||||
- (partitioning_reserved_gb | float)
|
||||
- (system_cfg.features.cis.enabled | ternary(7.5, 0))
|
||||
- partitioning_lvm_extent_reserve_gb
|
||||
@@ -325,16 +322,16 @@
|
||||
partitioning_lvm_available_gb: >-
|
||||
{{
|
||||
(
|
||||
(partitioning_vm_size_effective | float)
|
||||
(partitioning_disk_size_gb | float)
|
||||
- (partitioning_reserved_gb | float)
|
||||
- (system_cfg.features.cis.enabled | ternary(7.5, 0))
|
||||
- partitioning_lvm_extent_reserve_gb
|
||||
- partitioning_lvm_swap_target_effective_gb
|
||||
- partitioning_lvm_swap_target_limited_gb
|
||||
) | float
|
||||
}}
|
||||
partitioning_lvm_home_gb: >-
|
||||
{{
|
||||
([([(((partitioning_vm_size_effective | float) - 20) * 0.1), 2] | max), 20] | min)
|
||||
([([(((partitioning_disk_size_gb | float) - 20) * 0.1), 2] | max), 20] | min)
|
||||
}}
|
||||
partitioning_lvm_root_default_gb: >-
|
||||
{{
|
||||
@@ -346,7 +343,7 @@
|
||||
(
|
||||
((partitioning_lvm_available_gb | float) > 12)
|
||||
| ternary(
|
||||
((partitioning_vm_size_effective | float) * 0.4)
|
||||
((partitioning_disk_size_gb | float) * 0.4)
|
||||
| round(0, 'ceil'),
|
||||
partitioning_lvm_available_gb
|
||||
)
|
||||
@@ -360,7 +357,7 @@
|
||||
{{
|
||||
(
|
||||
[
|
||||
partitioning_lvm_swap_target_effective_gb,
|
||||
partitioning_lvm_swap_target_limited_gb,
|
||||
partitioning_lvm_swap_max_gb
|
||||
] | min | round(2, 'floor')
|
||||
)
|
||||
@@ -371,7 +368,7 @@
|
||||
{{
|
||||
[
|
||||
(
|
||||
(partitioning_vm_size_effective | float)
|
||||
(partitioning_disk_size_gb | float)
|
||||
- (partitioning_reserved_gb | float)
|
||||
- (partitioning_lvm_swap_gb | float)
|
||||
- partitioning_lvm_extent_reserve_gb
|
||||
|
||||
Reference in New Issue
Block a user