From 4fbcb12e07eaefa1bf36fe5c3b7db2f4ccf02797 Mon Sep 17 00:00:00 2001
From: nl6720 <nl6720@gmail.com>
Date: Sun, 9 Jun 2024 16:39:50 +0300
Subject: [PATCH] install_arch: create all partitions with a single sgdisk
 command

There is no need to split up partitioning into per-partition tasks.
Use long options for readability.
---
 roles/install_arch/tasks/main.yml | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/roles/install_arch/tasks/main.yml b/roles/install_arch/tasks/main.yml
index a0c7dd080..7fc9b62d1 100644
--- a/roles/install_arch/tasks/main.yml
+++ b/roles/install_arch/tasks/main.yml
@@ -29,22 +29,15 @@
     - name: Set the no-use-tor option in dirmngr.conf
       lineinfile: name=/root/.gnupg/dirmngr.conf create=yes line=no-use-tor owner=root group=root mode=0644
 
-- name: Create GRUB embed partitions
-  command: sgdisk -g -I --clear -n 1:0:+1M {{ item }} -c 1:'BIOS boot partition' -t 1:ef02
-  with_items:
-    - "{{ system_disks }}"
-  register: sgdisk
-  changed_when: "sgdisk.rc == 0"
-
-- name: Create EFI system partitions
-  command: sgdisk -g -I -n 2:0:+512M {{ item }} -c 2:'EFI system partition' -t 2:ef00
-  with_items:
-    - "{{ system_disks }}"
-  register: sgdisk
-  changed_when: "sgdisk.rc == 0"
-
-- name: Create root partitions
-  command: sgdisk -I -n 3:0:0 {{ item }} -c 3:root -t 3:8304
+- name: Create partitions
+  command: >
+    sgdisk
+      --align-end
+      --clear
+      --new=0:0:+1M --change-name=0:'BIOS boot partition' --typecode=0:ef02
+      --new=0:0:+512M --change-name=0:'EFI system partition' --typecode=0:ef00
+      --new=0:0:0 --change-name=0:root --typecode=0:8304
+      {{ item }}
   with_items:
     - "{{ system_disks }}"
   register: sgdisk
-- 
GitLab