Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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