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.

41 lines
1.0KB

  1. {%- from "linux/map.jinja" import storage with context %}
  2. {%- if storage.enabled %}
  3. parted:
  4. pkg.installed
  5. {%- for disk_name, disk in storage.disk.iteritems() %}
  6. {%- set disk_name = disk.name|default(disk_name) %}
  7. create_disk_label:
  8. module.run:
  9. - name: partition.mklabel
  10. - device: {{ disk_name }}
  11. - label_type: {{ disk.get('type', 'dos') }}
  12. - unless: "fdisk -l {{ disk_name }} | grep -i 'Disklabel type: {{ disk.get('type', 'dos') }}'"
  13. - require:
  14. - pkg: parted
  15. {% set end_size = 0 -%}
  16. {%- for partition in disk.get('partitions', []) %}
  17. create_partition_{{ disk_name }}_{{ loop.index }}:
  18. module.run:
  19. - name: partition.mkpart
  20. - device: {{ disk_name }}
  21. - part_type: primary
  22. - fs_type: {{ partition.type }}
  23. - start: {{ end_size }}MB
  24. - end: {{ end_size + partition.size }}MB
  25. - unless: "blkid {{ disk_name }}{{ loop.index }} {{ disk_name }}p{{ loop.index }}"
  26. - require:
  27. - module: create_disk_label
  28. {% set end_size = end_size + partition.size -%}
  29. {%- endfor %}
  30. {%- endfor %}
  31. {%- endif %}