Commit 32da53d6 by Braden MacDonald

Document and uppercase vars

parent 9efbb540
--- ---
# To enable the swapfile role, set this variable using a MB or GB suffix # Size of the desired swap file. Use a MB or GB suffix.
# e.g. SWAPFILE_SIZE: 512MB SWAPFILE_SIZE: 2GB
# To disable the role, leave the default value of 'false' # SWAPFILE_LOCATION: Location of the swap file managed by this role.
SWAPFILE_SIZE: false SWAPFILE_LOCATION: /swapfile
# SWAPFILE_USE_DD: set this to True if your filesystem does not support
# fallocate (e.g. if you use ext3). dd will then be used instead of fallocate.
SWAPFILE_USE_DD: False
#
# Advanced, optional settings:
#
swapfile_location: /swapfile # SWAPFILE_SWAPPINESS: Update sysctl.conf to set the swappiness percentage
swapfile_swappiness: False # (vm.swappiness) -- the lower it is, the less your system swaps memory pages.
swapfile_vfs_cache_pressure: False # If this is False (default), no change will be made.
swapfile_use_dd: False SWAPFILE_SWAPPINESS: False
# SWAPFILE_VFS_CACHE_PRESSURE: Update sysctl.conf to set the VFS cache pressure.
# "this percentage value controls the tendency of the kernel to reclaim the
# memory which is used for caching of directory and inode objects."
# If this is False (default), no change will be made.
SWAPFILE_VFS_CACHE_PRESSURE: False
--- ---
- name: Write swapfile - name: Write swapfile
command: | command: |
{% if swapfile_use_dd %} {% if SWAPFILE_USE_DD %}
dd if=/dev/zero of={{ swapfile_location }} bs=1M count={{ SWAPFILE_SIZE }} creates={{ swapfile_location }} dd if=/dev/zero of={{ SWAPFILE_LOCATION }} bs=1M count={{ SWAPFILE_SIZE }} creates={{ SWAPFILE_LOCATION }}
{% else %} {% else %}
fallocate -l {{ SWAPFILE_SIZE }} {{ swapfile_location }} creates={{ swapfile_location }} fallocate -l {{ SWAPFILE_SIZE }} {{ SWAPFILE_LOCATION }} creates={{ SWAPFILE_LOCATION }}
{% endif %} {% endif %}
register: write_swapfile register: write_swapfile
when: SWAPFILE_SIZE != false when: SWAPFILE_SIZE != false
- name: Set swapfile permissions - name: Set swapfile permissions
file: path={{ swapfile_location }} mode=600 file: path={{ SWAPFILE_LOCATION }} mode=600
when: SWAPFILE_SIZE != false when: SWAPFILE_SIZE != false
- name: Create swapfile - name: Create swapfile
command: mkswap {{ swapfile_location }} command: mkswap {{ SWAPFILE_LOCATION }}
register: create_swapfile register: create_swapfile
when: SWAPFILE_SIZE != false and write_swapfile.changed when: SWAPFILE_SIZE != false and write_swapfile.changed
- name: Enable swapfile - name: Enable swapfile
command: swapon {{ swapfile_location }} command: swapon {{ SWAPFILE_LOCATION }}
when: SWAPFILE_SIZE != false and create_swapfile.changed when: SWAPFILE_SIZE != false and create_swapfile.changed
- name: Add swapfile to /etc/fstab - name: Add swapfile to /etc/fstab
lineinfile: dest=/etc/fstab line="{{ swapfile_location }} none swap sw 0 0" state=present lineinfile: dest=/etc/fstab line="{{ SWAPFILE_LOCATION }} none swap sw 0 0" state=present
when: SWAPFILE_SIZE != false when: SWAPFILE_SIZE != false
- name: Configure vm.swappiness - name: Configure vm.swappiness
lineinfile: dest=/etc/sysctl.conf line="vm.swappiness = {{ swapfile_swappiness }}" regexp="^vm.swappiness[\s]?=" state=present lineinfile: dest=/etc/sysctl.conf line="vm.swappiness = {{ SWAPFILE_SWAPPINESS }}" regexp="^vm.swappiness[\s]?=" state=present
notify: reload sysctl notify: reload sysctl
when: swapfile_swappiness != false when: SWAPFILE_SWAPPINESS != false
- name: Configure vm.vfs_cache_pressure - 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 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 notify: reload sysctl
when: swapfile_vfs_cache_pressure != false when: SWAPFILE_VFS_CACHE_PRESSURE != false
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment