datavol: Playbook to provision a data volume
The `datavol.yml` playbook can provision one or more data volumes on a managed node, using the definitions in the `data_volumes` variable. This variable must contain a list of dictionaries with the following keys: * `dev`: The block device where the data volume is stored (e.g. `/dev/vdb`) * `fstype`: The type of filesystem to create on the block device * `mountpoint`: The location in the filesystem hierarchy where the volume is mounted * `opts`: (Optional) options to pass to the `mkfs` program when formatting the device * `mountopts`: (Optional) additional options to pass to the `mount` program when mounting the filesystemfrigate-exporter
parent
edffaf258b
commit
54ad68b5bb
|
@ -0,0 +1,52 @@
|
|||
- hosts: all
|
||||
vars:
|
||||
mkfs_package:
|
||||
btrfs: btrfs-progs
|
||||
ext2: e2fsprogs
|
||||
ext3: e2fsprogs
|
||||
ext4: e2fsprogs
|
||||
xfs: xfsprogs
|
||||
|
||||
tasks:
|
||||
- name: ensure filesystem tools are installed
|
||||
package:
|
||||
name: >-
|
||||
{{
|
||||
data_volumes
|
||||
| map(attribute='fstype')
|
||||
| map('extract', mkfs_package)
|
||||
| list
|
||||
}}
|
||||
tags:
|
||||
- install
|
||||
|
||||
- name: ensure data volume filesystem exists
|
||||
filesystem:
|
||||
dev: '{{ item.dev }}'
|
||||
fstype: '{{ item.fstype }}'
|
||||
opts: '{{ item.opts|d(omit) }}'
|
||||
loop: '{{ data_volumes|d([]) }}'
|
||||
tags:
|
||||
- mkfs
|
||||
|
||||
- name: ensure data volume is mounted
|
||||
mount:
|
||||
path: '{{ item.mountpoint }}'
|
||||
src: '{{ item.dev }}'
|
||||
fstype: '{{ item.fstype }}'
|
||||
opts: '{{ item.mountopts|d(omit) }}'
|
||||
state: mounted
|
||||
loop: '{{ data_volumes|d([]) }}'
|
||||
notify:
|
||||
- reload systemd
|
||||
- fix data volume selinux context
|
||||
|
||||
handlers:
|
||||
- name: reload systemd
|
||||
systemd:
|
||||
daemon_reload: true
|
||||
|
||||
- name: fix data volume selinux context
|
||||
command:
|
||||
restorecon -RF {{ item.mountpoint }}
|
||||
loop: '{{ data_volumes }}'
|
Loading…
Reference in New Issue