Aucune description
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

swap.yml 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. ---
  2. # adapted from https://stackoverflow.com/a/24765946
  3. - name: Create swap files
  4. command: dd if=/dev/zero of={{ '%s%d' | format(swap_file_path, item) }} bs=1024 count={{ swap_file_size }}K
  5. creates="{{ '%s%d' | format(swap_file_path, item) }}"
  6. loop: "{{ range(1, ( swap_file_count | int ) + 1) | list }}"
  7. - name: Change swap file permissions
  8. file: path="{{ '%s%d' | format(swap_file_path, item) }}"
  9. owner=root
  10. group=root
  11. mode=0600
  12. loop: "{{ range(1, ( swap_file_count | int ) + 1) | list }}"
  13. - name: Check swap file types
  14. command: file {{ '%s%d' | format(swap_file_path, item) }}
  15. register: swapfile
  16. loop: "{{ range(1, ( swap_file_count | int ) + 1) | list }}"
  17. - name: Make swap files
  18. command: "mkswap {{ '%s%d' | format(swap_file_path, item) }}"
  19. become: true
  20. when: swapfile.results[item - 1].stdout.find('swap file') == -1
  21. loop: "{{ range(1, ( swap_file_count | int ) + 1) | list }}"
  22. - name: Write swap entries in fstab
  23. mount: name=none
  24. src={{ '%s%d' | format(swap_file_path, item) }}
  25. fstype=swap
  26. opts=sw
  27. passno=0
  28. dump=0
  29. state=present
  30. loop: "{{ range(1, ( swap_file_count | int )+ 1) |list }}"
  31. - name: Mount swap
  32. command: "swapon --all"
  33. become: true