Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
configuration
Commits
32da53d6
Commit
32da53d6
authored
Nov 16, 2015
by
Braden MacDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document and uppercase vars
parent
9efbb540
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
19 deletions
+30
-19
playbooks/roles/swapfile/defaults/main.yml
+19
-8
playbooks/roles/swapfile/tasks/main.yml
+11
-11
No files found.
playbooks/roles/swapfile/defaults/main.yml
View file @
32da53d6
---
---
# 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
playbooks/roles/swapfile/tasks/main.yml
View file @
32da53d6
---
---
-
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment