瀏覽代碼

rewrite LVM lv_present

Since salt now also supports LV extend and reduce, the option Force must be used with care.

The changes include that force is only set if the corresponding LV does not yet exist (check via Grains) in order to overwrite any FS signatures (Wiping fs signature).

If the LV already exists (check via Grains), Force is set to False unless this is explicitly set to True in the pillars.
pull/221/head
preussal 4 年之前
父節點
當前提交
f51b3fb219
共有 2 個檔案被更改,包括 33 行新增4 行删除
  1. +25
    -2
      README.rst
  2. +8
    -2
      linux/storage/lvm.sls

+ 25
- 2
README.rst 查看文件

@@ -457,7 +457,7 @@ Systemd journal settings:
journal:
SystemMaxUse: "50M"
RuntimeMaxFiles: "100"
Ensure presence of directory:

.. code-block:: yaml
@@ -2119,6 +2119,30 @@ into ``/mnt/data``.
size: 40G
mount: ${linux:storage:mount:data}

Salt now also supports expanding and shrinking a LV:

To reduce the size of an LV the option force must be set to true.
! Caution this can destroy the file system if it is not shrunk before !
only some file systems can be shrunk.

.. code-block:: yaml

parameters:
linux:
lvm:
vg1:
enabled: true
devices:
- /dev/sdb
volume:
data: # to expand
size: 50G
mount: ${linux:storage:mount:data}
data: # to reduce
size: 30G
force: true
mount: ${linux:storage:mount:data}

Create partitions on disk. Specify size in MB. It expects empty
disk without any existing partitions.
Set ``startsector=1`` if you want to start partitions from ``2048``.
@@ -2610,4 +2634,3 @@ Documentation and Bugs
* #salt-formulas @ irc.freenode.net
Use this IRC channel in case of any questions or feedback which is always
welcome.


+ 8
- 2
linux/storage/lvm.sls 查看文件

@@ -51,10 +51,16 @@ lvm_{{ vg.get('name', vgname) }}_lv_{{ volume.get('name', lvname) }}:
- name: {{ volume.get('name', lvname) }}
- vgname: {{ vg.get('name', vgname) }}
- size: {{ volume.size }}
- force: true
{%- if (volume.force is defined and volume.force is sameas true) or
(volume.get('name', lvname) not in grains.lvm[vg.get('name', vgname)]) %}
- force: True
{%- else %}
- force: False
{%- endif %}
- require:
- lvm: lvm_vg_{{ vg.get('name', vgname) }}
{%- if volume.mount is defined %}
{%- if (volume.mount is defined) and
(volume.get('name', lvname) not in grains.lvm[vg.get('name', vgname)]) %}
- require_in:
- mount: {{ volume.mount.path }}
{%- if not volume.mount.get('file_system', None) in ['nfs', 'nfs4', 'cifs', 'tmpfs', None] %}

Loading…
取消
儲存