77 lines
1.8 KiB
YAML
77 lines
1.8 KiB
YAML
---
|
|
- name: Install LVM tools (if not present)
|
|
ansible.builtin.package:
|
|
name: lvm2
|
|
state: present
|
|
|
|
- name: Create physical volume
|
|
community.general.lvg:
|
|
pvs: "/dev/{{ docker_disk }}"
|
|
vg: "{{ docker_vg }}"
|
|
|
|
- name: Check if Docker LV exists
|
|
ansible.builtin.command: "lvs --noheadings -o lv_name {{ docker_vg }}"
|
|
register: lvs_output
|
|
|
|
- name: Create logical volume for Docker (in VM)
|
|
community.general.lvol:
|
|
vg: "{{ docker_vg }}"
|
|
lv: "{{ docker_lv }}"
|
|
size: "{{ docker_lv_size }}"
|
|
state: present
|
|
|
|
# - name: Format logical volume with XFS
|
|
# community.general.filesystem:
|
|
# fstype: xfs
|
|
# dev: "/dev/{{ docker_vg }}/{{ docker_lv }}"
|
|
# opts: "-n ftype=1"
|
|
|
|
- name: Format logical volume with ext4
|
|
community.general.filesystem:
|
|
fstype: ext4
|
|
dev: "/dev/{{ docker_vg }}/{{ docker_lv }}"
|
|
opts: "-F"
|
|
|
|
- name: Create mount point for Docker volume
|
|
ansible.builtin.file:
|
|
path: "{{ docker_mountpoint }}"
|
|
state: directory
|
|
mode: '0755'
|
|
|
|
# - name: Mount Docker LV to VM filesystem
|
|
# ansible.posix.mount:
|
|
# path: "{{ docker_mountpoint }}"
|
|
# src: "/dev/{{ docker_vg }}/{{ docker_lv }}"
|
|
# fstype: xfs
|
|
# opts: defaults
|
|
# state: mounted
|
|
|
|
- name: Mount Docker LV to VM filesystem
|
|
ansible.posix.mount:
|
|
path: "{{ docker_mountpoint }}"
|
|
src: "/dev/{{ docker_vg }}/{{ docker_lv }}"
|
|
fstype: ext4
|
|
opts: defaults
|
|
state: mounted
|
|
|
|
|
|
- name: Stop Docker service
|
|
ansible.builtin.systemd:
|
|
name: docker
|
|
state: stopped
|
|
enabled: true
|
|
|
|
- name: Bind mount new Docker data dir to /var/lib/docker
|
|
ansible.posix.mount:
|
|
path: /var/lib/docker
|
|
src: /docker-data
|
|
fstype: none
|
|
opts: bind
|
|
state: mounted
|
|
|
|
- name: Start Docker service
|
|
ansible.builtin.systemd:
|
|
name: docker
|
|
state: started
|
|
enabled: true
|