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.

67 lines
1.6KB

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