diff --git a/config.yml b/config.yml index 90ae4e6..0c24c91 100644 --- a/config.yml +++ b/config.yml @@ -31,6 +31,7 @@ smtp_username: smtpuser smtp_password: smtppassword smtp_authentication: plain smtp_enable_starttls: true +swap_add_mb: 500 ruby_version: 2.1.3 is_production_vm: False redmine_files_nfs_mount: '' # /mnt/redminefiles diff --git a/roles/easyredmine/tasks/addswap.yml b/roles/easyredmine/tasks/addswap.yml new file mode 100644 index 0000000..fabd86a --- /dev/null +++ b/roles/easyredmine/tasks/addswap.yml @@ -0,0 +1,46 @@ +# add new swap file if it does not already exist. +# Set `swap_add_mb` in config for swap size in MByte +# swap_add_mb: 1024 +# Based on https://gist.github.com/manuelmeurer/a2c0a8c24a0bb5092250 +# +- name: set swap_file variable + set_fact: + swap_file: /var/swap + +- name: check if swap file exists + stat: + path: "{{ swap_file }}" + register: swap_file_check + +- name: create swap file + become: yes + command: dd if=/dev/zero of="{{ swap_file }}" bs=1M count="{{ swap_add_mb }}" + when: not swap_file_check.stat.exists + +- name: set permissions on swap file + become: yes + file: + path: "{{ swap_file }}" + mode: 0600 + +- name: format swap file + become: yes + command: mkswap {{ swap_file }} + when: not swap_file_check.stat.exists + +- name: add to fstab + become: yes + lineinfile: + dest: /etc/fstab + regexp: "{{ swap_file }}" + line: "{{ swap_file }} none swap sw 0 0" + +- name: turn on swap + become: yes + command: swapon -a + +- name: set swapiness + become: yes + sysctl: + name: vm.swappiness + value: "1" \ No newline at end of file diff --git a/roles/easyredmine/tasks/system.yml b/roles/easyredmine/tasks/system.yml index 8d06e7f..ebe55e0 100644 --- a/roles/easyredmine/tasks/system.yml +++ b/roles/easyredmine/tasks/system.yml @@ -1,4 +1,5 @@ +- include: addswap.yml - name: install system tools yum: name='{{ item }}'