From 775d90c41747132f134d301ca3acf2ebb1fe8f97 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Sat, 24 Feb 2024 13:31:20 -0800 Subject: install_gentoo: split mounts Signed-off-by: Robin H. Johnson --- roles/install_gentoo/tasks/early-mount.yml | 51 ++++++++++++++++++++++++++++++ roles/install_gentoo/tasks/install.yml | 23 -------------- roles/install_gentoo/tasks/late-mount.yml | 30 ++++++++++++++++++ roles/install_gentoo/tasks/main.yml | 8 ++++- roles/install_gentoo/tasks/mount.yml | 44 -------------------------- 5 files changed, 88 insertions(+), 68 deletions(-) create mode 100644 roles/install_gentoo/tasks/early-mount.yml create mode 100644 roles/install_gentoo/tasks/late-mount.yml delete mode 100644 roles/install_gentoo/tasks/mount.yml diff --git a/roles/install_gentoo/tasks/early-mount.yml b/roles/install_gentoo/tasks/early-mount.yml new file mode 100644 index 0000000..ba65856 --- /dev/null +++ b/roles/install_gentoo/tasks/early-mount.yml @@ -0,0 +1,51 @@ +--- +- name: mkdir /mnt/gentoo + ansible.builtin.file: + path: /mnt/gentoo + state: directory + tags: + - mount + - early-mount + +- name: mount / + ansible.builtin.command: "mount /dev/{{ vgs }}/rootfs /mnt/gentoo" + tags: + - mount + - early-mount + +- name: mkdir /mnt/gentoo/boot + ansible.builtin.file: + path: /mnt/gentoo/boot + state: directory + tags: + - mount + - early-mount + +- name: mount /boot + ansible.builtin.command: "mount LABEL=BOOT /mnt/gentoo/boot" + tags: + - mount + - early-mount + +- name: mkdir /mnt/gentoo/boot/efi + ansible.builtin.file: + path: /mnt/gentoo/boot/efi + state: directory + tags: + - mount + - early-mount + +- name: mount /boot/efi + ansible.builtin.command: "mount LABEL=EFI /mnt/gentoo/boot/efi" + tags: + - mount + - early-mount + +- name: mkdir /mnt/gentoo/tmp + ansible.builtin.file: + path: /mnt/gentoo/tmp + state: directory + mode: '01777' + tags: + - mount + - early-mount diff --git a/roles/install_gentoo/tasks/install.yml b/roles/install_gentoo/tasks/install.yml index c083e0f..9c89f16 100644 --- a/roles/install_gentoo/tasks/install.yml +++ b/roles/install_gentoo/tasks/install.yml @@ -35,29 +35,6 @@ nameserver 2001:4860:4860::8888 nameserver 2001:4860:4860::8844 - - name: stat /dev/shm - ansible.builtin.stat: - path: /dev/shm - follow: false # explicitly; we need this to NOT be a link - register: stat_dev_shm - - - name: fix /dev/shm - ansible.builtin.shell: > - rm -f /dev/shm && mkdir /dev/shm && mount --types tmpfs --options nosuid,nodev,noexec shm /dev/shm && chmod 1777 /dev/shm /run/shm - when: not stat_dev_shm.stat.exists or stat_dev_shm.stat.islnk - - - name: virtual.fstab - ansible.builtin.copy: - dest: /tmp/virtual.fstab - content: | - /proc {{ chroot }}/proc proc rw,relatime 0 0 - /sys {{ chroot }}/sys bind rbind,rslave 0 0 - /dev {{ chroot }}/dev bind rbind,rslave 0 0 - /run {{ chroot }}/run bind bind,slave 0 0 - - - name: mount virtual - # TODO: how to safely check if this is needed at all? - ansible.builtin.command: mount -T /tmp/virtual.fstab -a - name: /etc/portage/repos.conf/gentoo.conf ansible.builtin.copy: diff --git a/roles/install_gentoo/tasks/late-mount.yml b/roles/install_gentoo/tasks/late-mount.yml new file mode 100644 index 0000000..cc36d99 --- /dev/null +++ b/roles/install_gentoo/tasks/late-mount.yml @@ -0,0 +1,30 @@ +--- +- name: late-mount + tags: + - mount + - late-mount + block: + - name: stat /dev/shm + ansible.builtin.stat: + path: /dev/shm + follow: false # explicitly; we need this to NOT be a link + register: stat_dev_shm + + - name: fix /dev/shm + ansible.builtin.shell: > + rm -f /dev/shm && mkdir /dev/shm && mount --types tmpfs --options nosuid,nodev,noexec shm /dev/shm && chmod 1777 /dev/shm /run/shm + when: not stat_dev_shm.stat.exists or stat_dev_shm.stat.islnk + + - name: virtual.fstab + ansible.builtin.copy: + dest: /tmp/virtual.fstab + content: | + /proc {{ chroot }}/proc proc rw,relatime 0 0 + /sys {{ chroot }}/sys bind rbind,rslave 0 0 + /dev {{ chroot }}/dev bind rbind,rslave 0 0 + /run {{ chroot }}/run bind bind,slave 0 0 + + - name: mount virtual + # TODO: how to safely check if this is needed at all? + ansible.builtin.command: mount -T /tmp/virtual.fstab -a + diff --git a/roles/install_gentoo/tasks/main.yml b/roles/install_gentoo/tasks/main.yml index b528285..7d477c5 100644 --- a/roles/install_gentoo/tasks/main.yml +++ b/roles/install_gentoo/tasks/main.yml @@ -8,14 +8,20 @@ - disks - mount -- include_tasks: mount.yml +- include_tasks: early-mount.yml tags: - mount + - early-mount - include_tasks: rootfs.yml tags: - rootfs +- include_tasks: late-mount.yml + tags: + - mount + - late-mount + - include_tasks: install.yml tags: - install diff --git a/roles/install_gentoo/tasks/mount.yml b/roles/install_gentoo/tasks/mount.yml deleted file mode 100644 index 74672cb..0000000 --- a/roles/install_gentoo/tasks/mount.yml +++ /dev/null @@ -1,44 +0,0 @@ ---- -- name: mkdir /mnt/gentoo - ansible.builtin.file: - path: /mnt/gentoo - state: directory - tags: - - mount - -- name: mount / - ansible.builtin.command: "mount /dev/{{ vgs }}/rootfs /mnt/gentoo" - tags: - - mount - -- name: mkdir /mnt/gentoo/boot - ansible.builtin.file: - path: /mnt/gentoo/boot - state: directory - tags: - - mount - -- name: mount /boot - ansible.builtin.command: "mount LABEL=BOOT /mnt/gentoo/boot" - tags: - - mount - -- name: mkdir /mnt/gentoo/boot/efi - ansible.builtin.file: - path: /mnt/gentoo/boot/efi - state: directory - tags: - - mount - -- name: mount /boot/efi - ansible.builtin.command: "mount LABEL=EFI /mnt/gentoo/boot/efi" - tags: - - mount - -- name: mkdir /mnt/gentoo/tmp - ansible.builtin.file: - path: /mnt/gentoo/tmp - state: directory - mode: '01777' - tags: - - mount -- cgit v1.2.3-65-gdbad