Saltstack Official Linux Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 line
1.2KB

  1. {%- from "linux/map.jinja" import storage with context %}
  2. {%- if storage.enabled %}
  3. linux_lvm_pkgs:
  4. pkg.installed:
  5. - pkgs: {{ storage.lvm_pkgs }}
  6. {%- for vgname, vg in storage.lvm.iteritems() %}
  7. {%- if vg.get('enabled', True) %}
  8. {%- for dev in vg.devices %}
  9. lvm_{{ vg.get('name', vgname) }}_pv_{{ dev }}:
  10. lvm.pv_present:
  11. - name: {{ dev }}
  12. - require:
  13. - pkg: linux_lvm_pkgs
  14. - require_in:
  15. - lvm: lvm_vg_{{ vg.get('name', vgname) }}
  16. {%- endfor %}
  17. lvm_vg_{{ vg.get('name', vgname) }}:
  18. lvm.vg_present:
  19. - name: {{ vg.get('name', vgname) }}
  20. - devices: {{ vg.devices|join(',') }}
  21. {%- for lvname, volume in vg.get('volume', {}).iteritems() %}
  22. lvm_{{ vg.get('name', vgname) }}_lv_{{ volume.get('name', lvname) }}:
  23. lvm.lv_present:
  24. - name: {{ volume.get('name', lvname) }}
  25. - vgname: {{ vg.get('name', vgname) }}
  26. - size: {{ volume.size }}
  27. - require:
  28. - lvm: lvm_vg_{{ vg.get('name', vgname) }}
  29. {%- if volume.mount is defined %}
  30. - require_in:
  31. - mount: {{ volume.mount.path }}
  32. {%- if not volume.mount.get('file_system', None) in ['nfs', 'nfs4', 'cifs', 'tmpfs', None] %}
  33. - cmd: mkfs_{{ volume.mount.device}}
  34. {%- endif %}
  35. {%- endif %}
  36. {%- endfor %}
  37. {%- endif %}
  38. {%- endfor %}
  39. {%- endif %}