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.

65 lines
1.4KB

  1. {%- from "linux/map.jinja" import storage with context %}
  2. {%- if storage.enabled %}
  3. {%- set install_xfs = False %}
  4. {%- for name, mount in storage.mount.iteritems() %}
  5. {%- if mount.enabled and mount.file_system == 'xfs' %}
  6. {%- set install_xfs = True %}
  7. {%- endif %}
  8. {%- endfor %}
  9. {%- if install_xfs == True %}
  10. xfs_packages:
  11. package.installed:
  12. - name: xfsprogs
  13. {%- endif %}
  14. {%- for name, mount in storage.mount.iteritems() %}
  15. {%- if mount.enabled %}
  16. {%- if not mount.file_system in ['nfs', 'nfs4'] %}
  17. mkfs_{{ mount.device}}:
  18. cmd.run:
  19. - name: "mkfs.{{ mount.file_system }} -L {{ name }} {{ mount.device }}"
  20. - onlyif: "test `blkid {{ mount.device }} >/dev/null;echo $?` -eq 2"
  21. - require_in:
  22. - mount: {{ mount.path }}
  23. {%- if mount.file_system == 'xfs' %}
  24. - require:
  25. - pkg: xfs_packages
  26. {%- endif %}
  27. {%- endif %}
  28. {{ mount.path }}:
  29. mount.mounted:
  30. - device: {{ mount.device }}
  31. - fstype: {{ mount.file_system }}
  32. - mkmnt: True
  33. - opts: {{ mount.get('opts', 'defaults,noatime') }}
  34. {%- if mount.file_system == 'xfs' %}
  35. - require:
  36. - pkg: xfs_packages
  37. {%- endif %}
  38. {%- if mount.user is defined %}
  39. {{ mount.path }}_permissions:
  40. file.directory:
  41. - name: {{ mount.path }}
  42. - user: {{ mount.user }}
  43. - group: {{ mount.get('group', 'root') }}
  44. - mode: {{ mount.get('mode', 755) }}
  45. - require:
  46. - mount: {{ mount.path }}
  47. {%- endif %}
  48. {%- endif %}
  49. {%- endfor %}
  50. {%- endif %}