108 lines
3.2 KiB
YAML
108 lines
3.2 KiB
YAML
---
|
|
|
|
- name: Warn user that the blockdevice will be wiped
|
|
debug:
|
|
msg: "Warning! Continueing will wipe {{ arch_device }}!"
|
|
|
|
- name: Give user the ability to abort
|
|
pause:
|
|
prompt: "You can safely abort now if you want, or continue and wipe {{ arch_device }}"
|
|
|
|
- name: Create empty GPT
|
|
community.general.parted:
|
|
device: "{{ arch_device }}"
|
|
label: gpt
|
|
name: "{{ arch_part_label_base }}"
|
|
|
|
- name: Create EFI system partition
|
|
community.general.parted:
|
|
device: "{{ arch_device }}"
|
|
state: present
|
|
part_start: "0%"
|
|
part_end: "{{ arch_part_efi_size }}"
|
|
number: 1
|
|
label: gpt
|
|
name: "{{ arch_part_label_base }}-efi"
|
|
fs_type: fat32
|
|
|
|
- name: Create partition for luks
|
|
community.general.parted:
|
|
device: "{{ arch_device }}"
|
|
state: present
|
|
part_start: "{{ arch_part_efi_size }}"
|
|
part_end: "{{ arch_part_root_size }}"
|
|
number: 2
|
|
label: gpt
|
|
name: "{{ arch_part_label_base }}-main"
|
|
|
|
- name: Create luks device on main partition
|
|
community.crypto.luks_device:
|
|
device: "{{ arch_luks_device }}"
|
|
passphrase: "{{ arch_luks_passphrase }}"
|
|
state: present
|
|
|
|
- name: Open luks device
|
|
community.crypto.luks_device:
|
|
device: "{{ arch_luks_device }}"
|
|
passphrase: "{{ arch_luks_passphrase }}"
|
|
state: "opened"
|
|
name: "{{ arch_luks_container_name }}"
|
|
|
|
- name: Wipe volume group if it existed
|
|
community.general.lvg:
|
|
vg: "{{ arch_lvm_name }}"
|
|
force: yes
|
|
state: absent
|
|
|
|
- name: Create volume group
|
|
community.general.lvg:
|
|
vg: "{{ arch_lvm_name }}"
|
|
pvs: "/dev/mapper/{{ arch_luks_container_name }}"
|
|
pvresize: yes
|
|
|
|
- name: Create logical volume for swap and root filesystem
|
|
community.general.lvol:
|
|
vg: "{{ arch_lvm_name }}"
|
|
lv: "{{ item.name }}"
|
|
size: "{{ item.size }}"
|
|
loop: "{{ arch_lvm_volumes }}"
|
|
|
|
- name: Create filesystem on efi system partition
|
|
community.general.filesystem:
|
|
dev: "{{ arch_device }}1"
|
|
force: yes
|
|
fstype: vfat
|
|
opts: -F32
|
|
|
|
- name: Create filesystems on the volumes
|
|
community.general.filesystem:
|
|
dev: "/dev/mapper/{{ arch_lvm_name }}-{{ item.name }}"
|
|
fstype: "{{ item.fstype }}"
|
|
loop: "{{ arch_lvm_volumes }}"
|
|
|
|
- name: Create mountpoint
|
|
file:
|
|
path: "/mnt-{{ arch_luks_container_name }}"
|
|
state: directory
|
|
|
|
- name: Mount root partition
|
|
command:
|
|
cmd: "mount /dev/mapper/{{ arch_lvm_name }}-{{ item.name }} /mnt-{{ arch_luks_container_name }}"
|
|
loop: "{{ arch_lvm_volumes | selectattr('mountpoint', 'defined') | selectattr('mountpoint', 'equalto', '/') }}"
|
|
|
|
- name: Create mountpoints in root partition
|
|
file:
|
|
path: "/mnt-{{ arch_luks_container_name }}{{ item.mountpoint }}"
|
|
state: directory
|
|
recurse: yes
|
|
loop: "{{ arch_lvm_volumes | selectattr('mountpoint', 'defined') | selectattr('mountpoint', 'ne', '/') + [ { \"mountpoint\": \"/boot\" } ] }}"
|
|
|
|
- name: Mount efi system partition
|
|
command:
|
|
cmd: "mount {{ arch_device }}1 /mnt-{{ arch_luks_container_name }}/boot"
|
|
|
|
- name: Mount additional partitions
|
|
command:
|
|
cmd: "mount /dev/mapper/{{ arch_lvm_name }}-{{ item.name }} /mnt-{{ arch_luks_container_name }}{{ item.mountpoint }}"
|
|
loop: "{{ arch_lvm_volumes | selectattr('mountpoint', 'defined') | selectattr('mountpoint', 'ne', '/') | list }}"
|