Browse Source

Merge branch 'fpy_lvm' into 'master'

Support for LVM

See merge request !8
tags/2016.12
Jan Kaufman 9 years ago
parent
commit
eeb27d4212
4 changed files with 77 additions and 0 deletions
  1. +22
    -0
      README.rst
  2. +4
    -0
      linux/map.jinja
  3. +3
    -0
      linux/storage/init.sls
  4. +48
    -0
      linux/storage/lvm.sls

+ 22
- 0
README.rst View File

@@ -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
=====


+ 4
- 0
linux/map.jinja View File

@@ -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')) %}

+ 3
- 0
linux/storage/init.sls View File

@@ -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 %}

+ 48
- 0
linux/storage/lvm.sls View File

@@ -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 %}

Loading…
Cancel
Save