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.

45 lines
1.1KB

  1. {%- from "linux/map.jinja" import storage with context %}
  2. {%- if storage.get('enabled', False) %}
  3. {%- for device, loopback in storage.loopback|dictsort %}
  4. {%- if loopback.get('enabled', True) %}
  5. {{ salt['file.dirname'](loopback.file) }}:
  6. file.directory:
  7. - makedirs: true
  8. - require_in:
  9. - file: {{ loopback.file }}
  10. {{ loopback.file }}:
  11. cmd.run:
  12. - name: "truncate --size {{ loopback.size|default('1G') }} {{ loopback.file }}"
  13. - creates: {{ loopback.file }}
  14. loopback_{{ device }}_init_script:
  15. file.managed:
  16. {%- if grains.get('init', None) == 'upstart' %}
  17. - name: /etc/init/setup-loopback-{{ device }}.conf
  18. - source: salt://linux/files/setup-loopback-device.upstart
  19. {%- else %}
  20. - name: /etc/systemd/system/setup-loopback-{{ device }}.service
  21. - source: salt://linux/files/setup-loopback-device.systemd
  22. {%- endif %}
  23. - template: jinja
  24. - defaults:
  25. file: {{ loopback.file }}
  26. device_name: "/dev/loop{{ loop.index0 }}"
  27. setup-loopback-{{ device }}:
  28. service.running:
  29. - enable: true
  30. - require:
  31. - cmd: {{ loopback.file }}
  32. - file: loopback_{{ device }}_init_script
  33. {%- endif %}
  34. {%- endfor %}
  35. {%- endif %}