packer-qemu/packer/assets/ansible/roles/setup/tasks/partition.yml

58 lines
1.2 KiB
YAML
Raw Normal View History

---
# partition disk to install gentoo
2020-03-03 22:20:24 +00:00
- name: "Create bios, boot and LVM partition"
parted:
2020-02-27 07:33:53 +00:00
device: "{{ devices_path }}"
name: "{{ item.name }}"
number: "{{ ansible_loop.index }}"
2020-03-03 22:20:24 +00:00
label: "{{ item.label }}"
flags: "{{ item.flags }}"
part_start: "{{ item.part_start }}"
part_end: "{{ item.part_end }}"
state: present
2020-02-27 07:33:53 +00:00
loop: "{{ devices_system }}"
loop_control:
extended: yes
2020-03-03 22:20:24 +00:00
tags:
- storage
- name: "Format partition with fstype keyword"
filesystem:
dev: "{{ item.dev }}"
fstype: "{{ item.fstype }}"
force: yes
resizefs: yes
loop: "{{ devices_system }}"
when: "item.fstype is defined"
tags:
- storage
2020-02-27 07:33:53 +00:00
- name: "Create vg and add disk to it"
lvg:
vg: vg_system
2020-03-03 22:20:24 +00:00
pvs: "{{ item.dev }}"
force: yes
loop: "{{ devices_system }}"
when: "'lvm' in item.flags"
tags:
- storage
2020-02-27 07:33:53 +00:00
- name: "Create list of lvs"
lvol:
2020-03-03 22:20:24 +00:00
vg: "{{ vg_name }}"
lv: "{{ item.name }}"
size: "{{ item.size }}"
2020-02-27 07:33:53 +00:00
loop: "{{ lvs }}"
2020-03-03 22:20:24 +00:00
tags:
- storage
- name: "Format lvs partition"
filesystem:
fstype: "{{ item.type }}"
dev: "/dev/{{ vg_name }}/{{ item.name }}"
force: yes
resizefs: yes
loop: "{{ lvs }}"
tags:
- storage