summaryrefslogtreecommitdiff
path: root/roles/setup-root-partition/tasks/main.yml
blob: 5ba9cd89d9d8530d840c378a8e15a80e7521cb7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
- 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 }}"

- 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 }}"

- 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 }}"

- name: Create a fileystem on EFI partition
  become: true
  filesystem:
    fstype: "vfat"
    device: "{{ vyos_target_drive }}p2"
    opts: "-n EFI -F 32 -s 1"
 

- name: Create a fileystem on root partition
  become: true
  filesystem:
    fstype: "{{ vyos_root_fstype }}"
    device: "{{ vyos_target_drive }}p3"
    opts: "-L persistence"

- name: Mount root partition
  become: true
  mount:
    name: "{{ vyos_write_root }}"
    src: "{{ vyos_target_drive }}p3"
    fstype: "{{ vyos_root_fstype }}"
    state: mounted