{"id":29143883,"url":"https://github.com/nickjj/ansible-swapfile","last_synced_at":"2025-06-30T20:39:42.529Z","repository":{"id":49585830,"uuid":"72362979","full_name":"nickjj/ansible-swapfile","owner":"nickjj","description":"Create and configure a swap file with Ansible.","archived":false,"fork":false,"pushed_at":"2019-11-15T12:28:09.000Z","size":10,"stargazers_count":32,"open_issues_count":0,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-22T01:47:49.982Z","etag":null,"topics":["ansible","swap"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nickjj.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-30T17:06:02.000Z","updated_at":"2023-11-22T11:08:54.000Z","dependencies_parsed_at":"2022-09-02T20:22:18.896Z","dependency_job_id":null,"html_url":"https://github.com/nickjj/ansible-swapfile","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/nickjj/ansible-swapfile","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickjj%2Fansible-swapfile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickjj%2Fansible-swapfile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickjj%2Fansible-swapfile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickjj%2Fansible-swapfile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nickjj","download_url":"https://codeload.github.com/nickjj/ansible-swapfile/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickjj%2Fansible-swapfile/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262847740,"owners_count":23374070,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","swap"],"created_at":"2025-06-30T20:39:39.374Z","updated_at":"2025-06-30T20:39:42.486Z","avatar_url":"https://github.com/nickjj.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"## What is ansible-swapfile? [![Build Status](https://secure.travis-ci.org/nickjj/ansible-swapfile.png)](http://travis-ci.org/nickjj/ansible-swapfile)\n\nIt is an [Ansible](http://www.ansible.com/home) role to:\n\n- Create a swap file\n- Delete a swap file\n\n## Why would you want to use this role?\n\nHaving a swap file is useful. It will help protect you from the OOM killer going\nberserk and shutting down services, but it also gives the Linux kernel a place\nto dump less frequently accessed memory pages, so it can provide more memory to\nhighly accessed memory pages. Basically it can improve overall system performance.\n\n## Supported platforms\n\n- Ubuntu 16.04 LTS (Xenial)\n- Debian 8 (Jessie)\n- Debian 9 (Stretch)\n\n## Role variables\n\n```\n# Default to double your system's RAM capacity if you have 2GB or less.\nswapfile_size: \"{{ ((ansible_memtotal_mb | int * 2)\n                    if (ansible_memtotal_mb | int \u003c= 2048)\n                    else '512') }}\"\n\n# Using fallocate is quite a bit faster than dd, so we'll default to using that.\n# If your file system does not support fallocate, set this to False.\n#\n# If you're using one of the supported platforms you have it, so don't worry.\nswapfile_fallocate: True\n\n# Where should the swap file be created?\nswapfile_path: \"/swapfile-{{ swapfile_size }}\"\n\n# Settings to configure your swap file. Google them for more details.\nswapfile_swappiness: 60\nswapfile_vfs_cache_pressure: 100\n\n# Default settings for configuring your swap file, you should not edit this\n# directly. Instead use the variables above. This allows you to customize just\n# 1 of them without having to bring along the entire dictionary.\nswapfile_sysctl:\n  \"vm.swappiness\": \"{{ swapfile_swappiness }}\"\n  \"vm.vfs_cache_pressure\": \"{{ swapfile_vfs_cache_pressure }}\"\n\n# When set to True, the swap file will be disabled and deleted.\nswapfile_delete: False\n```\n\n## Example usage\n\nFor the sake of this example let's assume you have a group called **app** and\nyou have a typical `site.yml` file.\n\nTo use this role edit your `site.yml` file to look something like this:\n\n```\n---\n\n- name: \"Configure app server(s)\"\n  hosts: \"app\"\n  become: True\n\n  roles:\n    - { role: \"nickjj.swapfile\", tags: \"swapfile\" }\n```\n\nLet's say you want to set a 4GB swap file and customize the swappiness, you can\ndo this by opening or creating `group_vars/app.yml` which is located relative\nto your `inventory` directory and then making it look like this:\n\n```\n---\n\nswapfile_size: 4096\n\nswapfile_swappiness: 20\n\n```\n\nNow you would run `ansible-playbook -i inventory/hosts site.yml -t swapfile`.\n\n## Installation\n\n`$ ansible-galaxy install nickjj.swapfile`\n\n## Ansible Galaxy\n\nYou can find it on the official\n[Ansible Galaxy](https://galaxy.ansible.com/nickjj/swapfile/) if you want to\nrate it.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnickjj%2Fansible-swapfile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnickjj%2Fansible-swapfile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnickjj%2Fansible-swapfile/lists"}