mirror of
https://github.com/koodiklinikka/playbooks.git
synced 2026-03-17 00:05:05 +00:00
Docker deployment for tohtori and some refactoring
This commit is contained in:
37
roles/base/tasks/swapfile.yml
Normal file
37
roles/base/tasks/swapfile.yml
Normal file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
- name: Write swapfile
|
||||
command: |
|
||||
{% if swapfile_use_dd %}
|
||||
dd if=/dev/zero of=/swapfile bs=1M count={{ swapfile_size }} creates=/swapfile
|
||||
{% else %}
|
||||
fallocate -l {{ swapfile_size }} /swapfile creates=/swapfile
|
||||
{% endif %}
|
||||
register: write_swapfile
|
||||
when: swapfile_size != false
|
||||
|
||||
- name: Set swapfile permissions
|
||||
file: path=/swapfile mode=600
|
||||
when: swapfile_size != false
|
||||
|
||||
- name: Create swapfile
|
||||
command: mkswap /swapfile
|
||||
register: create_swapfile
|
||||
when: swapfile_size != false and write_swapfile.changed
|
||||
|
||||
- name: Enable swapfile
|
||||
command: swapon /swapfile
|
||||
when: swapfile_size != false and create_swapfile.changed
|
||||
|
||||
- name: Add swapfile to /etc/fstab
|
||||
lineinfile: dest=/etc/fstab line="/swapfile none swap sw 0 0" state=present
|
||||
when: swapfile_size != false
|
||||
|
||||
- name: Configure vm.swappiness
|
||||
lineinfile: dest=/etc/sysctl.conf line="vm.swappiness = {{ swapfile_swappiness }}" regexp="^vm.swappiness[\s]?=" state=present
|
||||
notify: Reload sysctl
|
||||
when: swapfile_swappiness != false
|
||||
|
||||
- name: Configure vm.vfs_cache_pressure
|
||||
lineinfile: dest=/etc/sysctl.conf line="vm.vfs_cache_pressure = {{ swapfile_vfs_cache_pressure }}" regexp="^vm.vfs_cache_pressure[\s]?=" state=present
|
||||
notify: Reload sysctl
|
||||
when: swapfile_vfs_cache_pressure != false
|
||||
Reference in New Issue
Block a user