summaryrefslogtreecommitdiff
path: root/roles/setup-root-partition
diff options
context:
space:
mode:
authorKim <kim.sidney@gmail.com>2020-09-17 21:55:56 +0200
committerGitHub <noreply@github.com>2020-09-17 21:55:56 +0200
commit347544107d1cfede98eee4e816e74a9a724a36de (patch)
tree70b14e66826515320bee99fc2f2b28613fdb3fb9 /roles/setup-root-partition
parente025218641378434864f73cf0b7354ce5b97c6a9 (diff)
parent93879fe015cd9a60a94becd923c609376edf777d (diff)
downloadvyos-vm-images-347544107d1cfede98eee4e816e74a9a724a36de.tar.gz
vyos-vm-images-347544107d1cfede98eee4e816e74a9a724a36de.zip
Merge pull request #8 from zdc/bugfixes
Fixes for the images building process
Diffstat (limited to 'roles/setup-root-partition')
-rw-r--r--roles/setup-root-partition/tasks/main.yml30
1 files changed, 8 insertions, 22 deletions
diff --git a/roles/setup-root-partition/tasks/main.yml b/roles/setup-root-partition/tasks/main.yml
index 5ba9cd8..308cf10 100644
--- a/roles/setup-root-partition/tasks/main.yml
+++ b/roles/setup-root-partition/tasks/main.yml
@@ -1,34 +1,21 @@
- name: Partition disk
become: true
command:
- cmd: "sgdisk -a1 -n1:34:2047 -t1:EF02 -n2:2048:+256M -t2:EF00 -n3:0:0:+100% -t3:8300 {{ vyos_raw_img }}"
-
-- name: Create hybrid MBR
- become: true
- command:
- cmd: "sgdisk -h -t1:EF02 -t2:EF00 -t3:8300 {{ vyos_raw_img }}"
+ cmd: "sgdisk -a1 -n1:34:2047 -t1:EF02 -n2:2048:+256M -t2:EF00 -n3:0:0:+100% -t3:8300 {{ vyos_raw_img }}"
- name: Reread partitions from image and mount to loopback
become: true
- command: "kpartx -av {{ vyos_raw_img }}"
-
-- name: Find the loop device that was used, map to mapper
- become: true
- shell: "losetup | grep vyos_raw_image.img | head -n1 | awk '{print $1}' | sed 's/dev/dev\\/mapper/g'"
- register: result
-
-- name: Set vyos_target_drive.
- set_fact:
- vyos_target_drive: "{{ result.stdout }}"
+ shell: "kpartx -av {{ vyos_raw_img }} | awk '{ print $3 }'"
+ register: loop_partitions
-- name: Pull grub drive
+- name: Find loop device path
become: true
- shell: "losetup | grep vyos_raw_image.img | head -n1 | awk '{print $1}'"
- register: result
+ shell: "losetup -l -O NAME,BACK-FILE | awk '{ if (match($2, \"{{ vyos_raw_img }}\")) print $1}'"
+ register: loop_device
-- name: Set vyos_grub_drive.
+- name: Set vyos_target_drive fact
set_fact:
- vyos_grub_drive: "{{ result.stdout }}"
+ vyos_target_drive: "{{ loop_device.stdout | regex_replace('^/dev/(loop.*)$', '/dev/mapper/\\1') }}"
- name: Create a fileystem on EFI partition
become: true
@@ -37,7 +24,6 @@
device: "{{ vyos_target_drive }}p2"
opts: "-n EFI -F 32 -s 1"
-
- name: Create a fileystem on root partition
become: true
filesystem: