libvirt_cloud/roles/ansible-gentoo_install/tasks/disk.yml

73 lines
2.1 KiB
YAML
Raw Normal View History

2023-12-29 19:40:31 +00:00
# -*- mode: yaml; indent-tabs-mode: nil; tab-width: 2; coding: utf-8-unix -*-
---
- name: "DEBUG: ansible-gentoo_install disk.yml"
debug:
verbosity: 1
msg: "DEBUG: ansible-gentoo_install disk.yml"
- name: test we are NOT in the chroot
shell: |
grep '/dev/{{AGI_NBD_DEV}}' /proc/mounts && exit 1
[ -n "{{AGI_NBD_MP}}" ] || exit 2
[ -d "{{AGI_NBD_MP}}" ] || exit 3
[ "{{ansible_distribution}}" == 'Gentoo' ] || \
( {{AGI_GENTOO_FROM_MP}} != '' && "{{AGI_GENTOO_FROM_MP}}" != '/' ) || \
exit 4
[ -d "{{AGI_GENTOO_FROM_MP}}" ] || exit 5
check_mode: false
- name: create disklabel
command: parted -s {{ AGI_install_disk }} mklabel {{ AGI_install_disklabel }}
2023-12-30 12:52:24 +00:00
register: disklabel_out
# stderr: 'Warning: Error fsyncing/closing /dev/nbd1: Input/output error'
failed_when: false
2023-12-29 19:40:31 +00:00
2023-12-30 12:52:24 +00:00
- name: disklabel_out
debug:
var: disklabel_out
2023-12-29 19:40:31 +00:00
# We need to leave a small gap at the beginning of the disk, or grub won't be
# able to install to the MBR
- name: create boot partition
shell: |
parted -s {{ AGI_install_disk }} mkpart primary ext2 1M 200M
args:
2023-12-30 12:52:24 +00:00
creates: "{{ AGI_install_disk }}p1"
2023-12-29 19:40:31 +00:00
- name: mark boot partition as active
shell: |
parted -s {{ AGI_install_disk }} set 1 boot on
- name: create swap partition
shell: |
parted -s {{ AGI_install_disk }} -- mkpart primary linux-swap 201M 2200M
args:
creates: "{{ AGI_install_disk }}p2"
- name: create root partition
shell: |
parted -s {{ AGI_install_disk }} -- mkpart primary ext4 2201M 20070M
args:
creates: "{{ AGI_install_disk }}p3"
- name: format boot partition
filesystem: dev={{ AGI_install_disk }}p1 fstype=ext2 force=yes
check_mode: false
when: not ansible_check_mode
- name: format swap partition
filesystem: dev={{ AGI_install_disk }}p2 fstype=swap force=yes
check_mode: false
when: false
- name: format root partition
filesystem: dev={{ AGI_install_disk }}p3 fstype=ext4 force=yes
check_mode: false
when: not ansible_check_mode
2023-12-30 12:52:24 +00:00
- name: label partitions
shell: |
e2label {{ AGI_install_disk }}p3 root
e2label {{ AGI_install_disk }}p1 boot
mkswap -L swap "{{ AGI_install_disk }}p2"