Move files to this submodule
This commit is contained in:
commit
ed8986fc5c
10 changed files with 165 additions and 0 deletions
37
tasks/swap.yml
Normal file
37
tasks/swap.yml
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
- name: Check whether swap is already enabled or not
|
||||
shell: cat /etc/sysctl.conf
|
||||
register: swap_enabled
|
||||
check_mode: false
|
||||
changed_when: false
|
||||
|
||||
- block:
|
||||
- name: create swap file
|
||||
command: dd if=/dev/zero of=/swapfile bs=1G count=4
|
||||
|
||||
- name: change permission type
|
||||
file: path=/swapfile mode=600 state=file
|
||||
|
||||
- name: setup swap
|
||||
command: mkswap /swapfile
|
||||
|
||||
- name: create swap
|
||||
command: swapon /swapfile
|
||||
|
||||
- name: Add to fstab
|
||||
action: lineinfile dest=/etc/fstab regexp="swapfile" line="/swapfile none swap sw 0 0" state=present
|
||||
|
||||
- name: start swap
|
||||
command: swapon -a
|
||||
|
||||
- name: set swapiness
|
||||
sysctl:
|
||||
name: vm.swappiness
|
||||
value: "10"
|
||||
|
||||
- name: set swapiness
|
||||
sysctl:
|
||||
name: vm.vfs_cache_pressure
|
||||
value: "50"
|
||||
|
||||
when: swap_enabled.stdout.find('swappiness') == -1
|
||||
Loading…
Add table
Add a link
Reference in a new issue