From 33f1875ee979d2bfee8a683a9dceec51c8d8f1a7 Mon Sep 17 00:00:00 2001 From: Aine Date: Sat, 18 Mar 2023 13:24:46 +0200 Subject: [PATCH 1/2] add system/swap role --- docs/services/system.md | 31 +++++++++++++++++++++++++++++++ docs/supported-services.md | 1 + group_vars/mash_servers | 17 +++++++++++++++++ requirements.yml | 3 +++ setup.yml | 2 ++ 5 files changed, 54 insertions(+) create mode 100644 docs/services/system.md diff --git a/docs/services/system.md b/docs/services/system.md new file mode 100644 index 0000000..9f71e27 --- /dev/null +++ b/docs/services/system.md @@ -0,0 +1,31 @@ +# System-related configuration + +This Ansible playbook can install and configure various system-related things for you. +All the sections below relates to the host OS instead of docker containers. + +### swap + +To enable [swap](https://en.wikipedia.org/wiki/Memory_paging) management, add the following configuration to your `vars.yml` file and re-run the [installation](../installing.md) process: + +```yaml +######################################################################## +# # +# system # +# # +######################################################################## + +system_swap_enabled: true + +######################################################################## +# # +# /system # +# # +######################################################################## +``` + +By default, swap file size calculated using the following formula: `total RAM * 2 if total RAM <= 2GB, else - 1GB`, +if you want to set different swap file size, you can set the `system_swap_size` var in megabytes, example (4gb): + +```yaml +system_swap_size: 4096 +``` diff --git a/docs/supported-services.md b/docs/supported-services.md index 73f1318..9239b89 100644 --- a/docs/supported-services.md +++ b/docs/supported-services.md @@ -18,6 +18,7 @@ | [Vaultwarden](https://github.com/dani-garcia/vaultwarden) | A lightweight unofficial and compatible implementation of the [Bitwarden](https://bitwarden.com/) password manager | [Link](services/vaultwarden.md) | | [Uptime-kuma](https://uptime.kuma.pet/) | A fancy self-hosted monitoring tool | [Link](services/uptime-kuma.md) | | [Woodpecker CI](https://woodpecker-ci.org/) | A simple Continuous Integration (CI) engine with great extensibility. | [Link](services/woodpecker-ci.md) | +| System-related | A collection of various system-related components | [Link](services/system.md) | ## Related playbooks diff --git a/group_vars/mash_servers b/group_vars/mash_servers index d761f62..412bc19 100644 --- a/group_vars/mash_servers +++ b/group_vars/mash_servers @@ -1,5 +1,22 @@ --- +######################################################################## +# # +# system/swap # +# # +######################################################################## + +system_swap_enabled: false + +######################################################################## +# # +# system/swap # +# # +######################################################################## + + + + ######################################################################## # # # com.devture.ansible.role.systemd_service_manager # diff --git a/requirements.yml b/requirements.yml index 2184101..2675b3d 100644 --- a/requirements.yml +++ b/requirements.yml @@ -3,6 +3,9 @@ - src: geerlingguy.docker version: 6.1.0 +- src: git+https://gitlab.com/etke.cc/roles/swap + version: 33ce32b065276a96b7e2562752f3a63913ed5480 + - src: git+https://github.com/devture/com.devture.ansible.role.docker_sdk_for_python.git version: 129c8590e106b83e6f4c259649a613c6279e937a diff --git a/setup.yml b/setup.yml index 5b74e6e..d8d2d03 100644 --- a/setup.yml +++ b/setup.yml @@ -37,6 +37,8 @@ - role: mash/playbook_base + - role: galaxy/swap + # This role exposes various tags (setup-postgres, setup-all, upgrade-postgres, import-postgres, etc.), so we don't tag it here. - role: galaxy/com.devture.ansible.role.postgres From a5685d09a59a1596b6e086603b9bbd3bd7c22c61 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Sat, 18 Mar 2023 16:02:11 +0200 Subject: [PATCH 2/2] Add additional swap explanations in system.md --- docs/services/system.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/services/system.md b/docs/services/system.md index 9f71e27..8091cf7 100644 --- a/docs/services/system.md +++ b/docs/services/system.md @@ -1,11 +1,11 @@ # System-related configuration This Ansible playbook can install and configure various system-related things for you. -All the sections below relates to the host OS instead of docker containers. +All the sections below relate to the host OS instead of the managed containers. ### swap -To enable [swap](https://en.wikipedia.org/wiki/Memory_paging) management, add the following configuration to your `vars.yml` file and re-run the [installation](../installing.md) process: +To enable [swap](https://en.wikipedia.org/wiki/Memory_paging) management (also read more in the [Swap](https://wiki.archlinux.org/title/Swap) article in the [Arch Linux Wiki](https://wiki.archlinux.org/)), add the following configuration to your `vars.yml` file and re-run the [installation](../installing.md) process: ```yaml ######################################################################## @@ -23,8 +23,14 @@ system_swap_enabled: true ######################################################################## ``` -By default, swap file size calculated using the following formula: `total RAM * 2 if total RAM <= 2GB, else - 1GB`, -if you want to set different swap file size, you can set the `system_swap_size` var in megabytes, example (4gb): +A swap file will be created in `/var/swap` (configured using the `system_swap_path` variable) and enabled in your `/etc/fstab` file. + +By default, the swap file will have the following size: + +- on systems with `<= 2GB` of RAM, swap file size = `total RAM * 2` +- on systems with `> 2GB` of RAM, swap file size = `1GB` + +To avoid these calculations and set your own size explicitly, set the `system_swap_size` variable in megabytes, example (4gb): ```yaml system_swap_size: 4096