Support for LVM See merge request !8tags/2016.12
device: /swapfile | device: /swapfile | ||||
size: 1024 | size: 1024 | ||||
LVM group `vg1` with one device and `data` volume mounted into `/mnt/data` | |||||
.. code-block:: yaml | |||||
parameters: | |||||
linux: | |||||
storage: | |||||
mount: | |||||
data: | |||||
device: /dev/vg1/data | |||||
file_system: ext4 | |||||
path: /mnt/data | |||||
lvm: | |||||
vg1: | |||||
enabled: true | |||||
devices: | |||||
- /dev/sdb | |||||
volume: | |||||
data: | |||||
size: 40G | |||||
mount: ${linux:storage:mount:data} | |||||
Usage | Usage | ||||
===== | ===== | ||||
'Arch': { | 'Arch': { | ||||
'mount': {}, | 'mount': {}, | ||||
'swap': {}, | 'swap': {}, | ||||
'lvm': {}, | |||||
'multipath': False, | 'multipath': False, | ||||
}, | }, | ||||
'Debian': { | 'Debian': { | ||||
'mount': {}, | 'mount': {}, | ||||
'swap': {}, | 'swap': {}, | ||||
'lvm': {}, | |||||
'multipath': False, | 'multipath': False, | ||||
'multipath_pkgs': ['multipath-tools'] | 'multipath_pkgs': ['multipath-tools'] | ||||
'lvm_pkgs': ['lvm2'] | |||||
}, | }, | ||||
'RedHat': { | 'RedHat': { | ||||
'mount': {}, | 'mount': {}, | ||||
'swap': {}, | 'swap': {}, | ||||
'lvm': {}, | |||||
'multipath': False, | 'multipath': False, | ||||
}, | }, | ||||
}, grain='os_family', merge=salt['pillar.get']('linux:storage')) %} | }, grain='os_family', merge=salt['pillar.get']('linux:storage')) %} |
{%- if storage.swap|length > 0 %} | {%- if storage.swap|length > 0 %} | ||||
- linux.storage.swap | - linux.storage.swap | ||||
{%- endif %} | {%- endif %} | ||||
{%- if storage.lvm|length > 0 %} | |||||
- linux.storage.lvm | |||||
{%- endif %} | |||||
{%- if storage.multipath %} | {%- if storage.multipath %} | ||||
- linux.storage.multipath | - linux.storage.multipath | ||||
{%- endif %} | {%- endif %} |
{%- from "linux/map.jinja" import storage with context %} | |||||
{%- if storage.enabled %} | |||||
linux_lvm_pkgs: | |||||
pkg.installed: | |||||
- names: {{ storage.lvm_pkgs }} | |||||
{%- for vgname, vg in storage.lvm.iteritems() %} | |||||
{%- if vg.get('enabled', True) %} | |||||
{%- for dev in vg.devices %} | |||||
lvm_{{ vgname }}_pv_{{ dev }}: | |||||
lvm.pv_present: | |||||
- name: dev | |||||
- require: | |||||
- pkg: linux_lvm_pkgs | |||||
- require_in: | |||||
- lvm: lvm_vg_{{ vgname }} | |||||
{%- endfor %} | |||||
lvm_vg_{{ vgname }}: | |||||
lvm.vg_present: | |||||
- name: {{ vgname }} | |||||
- devices: {{ vg.devices }} | |||||
{%- for lvname, volume in vg.volume.iteritems() %} | |||||
lvm_{{ vgname }}_lv_{{ lvname }}: | |||||
lvm.lv_present: | |||||
- name: {{ lvname }} | |||||
- vgname: {{ vgname }} | |||||
- size: {{ volume.size }} | |||||
- require: | |||||
- lvm: lvm_vg_{{ vgname }} | |||||
{%- if volume.mount is defined %} | |||||
- require_in: | |||||
- mount: {{ volume.mount.path }} | |||||
{%- endif %} | |||||
{%- endfor %} | |||||
{%- endif %} | |||||
{%- endfor %} | |||||
{%- endif %} |