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
923B

  1. {%- from "linux/map.jinja" import storage with context %}
  2. {%- if storage.enabled %}
  3. {%- for swap_name, swap in storage.swap.iteritems() %}
  4. {%- if swap.enabled %}
  5. {%- if swap.engine == 'file' %}
  6. linux_create_swap_file_{{ swap.device }}:
  7. cmd.run:
  8. - name: 'dd if=/dev/zero of={{ swap.device }} bs=1048576 count={{ swap.size }} && chmod 0600 {{ swap.device }}'
  9. - creates: {{ swap.device }}
  10. linux_set_swap_file_{{ swap.device }}:
  11. cmd.wait:
  12. - name: 'mkswap {{ swap.device }}'
  13. - watch:
  14. - cmd: linux_create_swap_file_{{ swap.device }}
  15. linux_set_swap_file_status_{{ swap.device }}:
  16. cmd.run:
  17. - name: 'swapon {{ swap.device }}'
  18. - unless: grep {{ swap.device }} /proc/swaps
  19. - require:
  20. - cmd: linux_set_swap_file_{{ swap.device }}
  21. {{ swap.device }}:
  22. mount.swap:
  23. - persist: True
  24. - require:
  25. - cmd: linux_set_swap_file_{{ swap.device }}
  26. {%- endif %}
  27. {%- endif %}
  28. {%- endfor %}
  29. {%- endif %}