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.

70 line
1.6KB

  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. /etc/lvm/lvm.conf:
  7. file.managed:
  8. - source: salt://linux/files/lvm.conf
  9. - template: jinja
  10. - require:
  11. - pkg: linux_lvm_pkgs
  12. lvm_services:
  13. service.running:
  14. - enable: true
  15. - names: {{ storage.lvm_services }}
  16. - require:
  17. - file: /etc/lvm/lvm.conf
  18. - watch:
  19. - file: /etc/lvm/lvm.conf
  20. {%- for vgname, vg in storage.lvm.items() %}
  21. {%- if vg.get('enabled', True) %}
  22. {%- for dev in vg.devices %}
  23. lvm_{{ vg.get('name', vgname) }}_pv_{{ dev }}:
  24. lvm.pv_present:
  25. - name: {{ dev }}
  26. - require:
  27. - pkg: linux_lvm_pkgs
  28. - file: /etc/lvm/lvm.conf
  29. - service: lvm_services
  30. - require_in:
  31. - lvm: lvm_vg_{{ vg.get('name', vgname) }}
  32. {%- endfor %}
  33. lvm_vg_{{ vg.get('name', vgname) }}:
  34. lvm.vg_present:
  35. - name: {{ vg.get('name', vgname) }}
  36. - devices: {{ vg.devices|join(',') }}
  37. {%- for lvname, volume in vg.get('volume', {}).items() %}
  38. lvm_{{ vg.get('name', vgname) }}_lv_{{ volume.get('name', lvname) }}:
  39. lvm.lv_present:
  40. - name: {{ volume.get('name', lvname) }}
  41. - vgname: {{ vg.get('name', vgname) }}
  42. - size: {{ volume.size }}
  43. - require:
  44. - lvm: lvm_vg_{{ vg.get('name', vgname) }}
  45. {%- if volume.mount is defined %}
  46. - require_in:
  47. - mount: {{ volume.mount.path }}
  48. {%- if not volume.mount.get('file_system', None) in ['nfs', 'nfs4', 'cifs', 'tmpfs', None] %}
  49. - cmd: mkfs_{{ volume.mount.device}}
  50. {%- endif %}
  51. {%- endif %}
  52. {%- endfor %}
  53. {%- endif %}
  54. {%- endfor %}
  55. {%- endif %}