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 line
1.5KB

  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:
  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. {%- if mount.file_system == 'xfs' %}
  37. - require:
  38. - pkg: xfs_packages_{{ mount.device }}
  39. {%- endif %}
  40. {%- if mount.user is defined %}
  41. {{ mount.path }}_permissions:
  42. file.directory:
  43. - name: {{ mount.path }}
  44. - user: {{ mount.user }}
  45. - group: {{ mount.get('group', 'root') }}
  46. - mode: {{ mount.get('mode', 755) }}
  47. - require:
  48. - mount: {{ mount.path }}
  49. {%- endif %}
  50. {%- endif %}
  51. {%- endfor %}
  52. {%- endif %}