@@ -369,6 +369,28 @@ Linux with file swap | |||
device: /swapfile | |||
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 | |||
===== | |||
@@ -104,17 +104,21 @@ | |||
'Arch': { | |||
'mount': {}, | |||
'swap': {}, | |||
'lvm': {}, | |||
'multipath': False, | |||
}, | |||
'Debian': { | |||
'mount': {}, | |||
'swap': {}, | |||
'lvm': {}, | |||
'multipath': False, | |||
'multipath_pkgs': ['multipath-tools'] | |||
'lvm_pkgs': ['lvm2'] | |||
}, | |||
'RedHat': { | |||
'mount': {}, | |||
'swap': {}, | |||
'lvm': {}, | |||
'multipath': False, | |||
}, | |||
}, grain='os_family', merge=salt['pillar.get']('linux:storage')) %} |
@@ -7,6 +7,9 @@ include: | |||
{%- if storage.swap|length > 0 %} | |||
- linux.storage.swap | |||
{%- endif %} | |||
{%- if storage.lvm|length > 0 %} | |||
- linux.storage.lvm | |||
{%- endif %} | |||
{%- if storage.multipath %} | |||
- linux.storage.multipath | |||
{%- endif %} |
@@ -0,0 +1,48 @@ | |||
{%- 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 %} |