summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcreate with ansible <qxmips@debian10-vyos-build.local>2020-10-08 01:57:50 -0400
committercreate with ansible <qxmips@debian10-vyos-build.local>2020-10-08 02:05:15 -0400
commit8ef65f52418997af40a4afb2df83a8faef09111a (patch)
treecd49c8e9afc8ead4385dfee9e94a33fda2fbce69
parentcdbd9df937e524c1d89ef74c15a013e79359b9fc (diff)
parent347544107d1cfede98eee4e816e74a9a724a36de (diff)
downloadvyos-vm-images-8ef65f52418997af40a4afb2df83a8faef09111a.tar.gz
vyos-vm-images-8ef65f52418997af40a4afb2df83a8faef09111a.zip
minor fixes
-rw-r--r--roles/install-grub/tasks/main.yml3
-rw-r--r--roles/setup-root-partition/tasks/main.yml32
-rw-r--r--roles/unmount-all/tasks/main.yml11
3 files changed, 19 insertions, 27 deletions
diff --git a/roles/install-grub/tasks/main.yml b/roles/install-grub/tasks/main.yml
index dfe765d..974f011 100644
--- a/roles/install-grub/tasks/main.yml
+++ b/roles/install-grub/tasks/main.yml
@@ -1,4 +1,3 @@
-
- name: Create GRUB directory
become: true
file:
@@ -35,7 +34,7 @@
- name: Install GRUB in the boot sector of {{ vyos_target_drive }}
become: true
- command: "chroot {{ vyos_install_root }} grub-install --no-floppy --root-directory=/boot {{ vyos_grub_drive }} --force"
+ command: "chroot {{ vyos_install_root }} grub-install --no-floppy --target=i386-pc --root-directory=/boot {{ loop_device.stdout }} --force"
args:
creates: "{{ vyos_install_root }}/boot/grub/grubenv"
diff --git a/roles/setup-root-partition/tasks/main.yml b/roles/setup-root-partition/tasks/main.yml
index 1f6df8d..57ba5ae 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
+ shell: "kpartx -av {{ vyos_raw_img }} | awk '{ print $3 }'"
+ register: loop_partitions
+
+- name: Find loop device path
become: true
- shell: "losetup | grep {{ vyos_raw_img }} | head -n1 | awk '{print $1}' | sed 's/dev/dev\\/mapper/g'"
- register: result
+ shell: "losetup -l -O NAME,BACK-FILE | awk '{ if (match($2, \"{{ vyos_raw_img }}\")) print $1}'"
+ register: loop_device
-- name: Set vyos_target_drive.
+- name: Set vyos_target_drive fact
set_fact:
- vyos_target_drive: "{{ result.stdout }}"
-
-- name: Pull grub drive
- become: true
- shell: "losetup | grep vyos_raw_image.img | head -n1 | awk '{print $1}'"
- register: result
-
-- name: Set vyos_grub_drive.
- 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:
diff --git a/roles/unmount-all/tasks/main.yml b/roles/unmount-all/tasks/main.yml
index 98d4cdd..24dfc8c 100644
--- a/roles/unmount-all/tasks/main.yml
+++ b/roles/unmount-all/tasks/main.yml
@@ -36,14 +36,21 @@
become: true
mount:
name: "{{ vyos_write_root }}"
- src: "{{ vyos_target_drive }}"
- fstype: "{{ vyos_root_fstype }}"
state: absent
- name: Remove image partitions
become: true
command: "kpartx -dv {{ vyos_raw_img }}"
+- name: Remove /dev/mapper entries
+ become: true
+ command: "dmsetup remove {{ item }}"
+ with_items: "{{ loop_partitions.stdout_lines }}"
+
+- name: Detach {{ loop_device.stdout }}
+ become: true
+ command: "losetup -d {{ loop_device.stdout }}"
+
- name: Unmount {{ vyos_cd_squash_root }}
become: true
mount: