Skip to content

Commit 46b7bbf

Browse files
committed
xmpp2: enable a swap file
1 parent bda7731 commit 46b7bbf

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

.idea/dictionaries/project.xml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

xmpp2/default.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# SPDX-License-Identifier: MIT
44

55
- import_playbook: auth.yml
6+
- import_playbook: system.yml
67
- import_playbook: nginx.yml
78
- import_playbook: docker.yml
89
- import_playbook: codingteam.org.ru.yml

xmpp2/system.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# SPDX-FileCopyrightText: 2025 Friedrich von Never <[email protected]>
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
---
6+
- name: Set up the system
7+
hosts: xmpp2
8+
become: true
9+
10+
vars:
11+
swap_file_path: '/swapfile'
12+
swap_file_size: '2GiB'
13+
14+
tasks:
15+
- name: Check if swap file exists
16+
stat:
17+
path: '{{ swap_file_path }}'
18+
register: swap_file_check
19+
20+
- name: Create swap file
21+
ansible.builtin.command: fallocate -l "{{ swap_file_size }}" "{{ swap_file_path }}"
22+
when: not swap_file_check.stat.exists
23+
24+
- name: Set up swap file permissions
25+
ansible.builtin.file:
26+
path: '{{ swap_file_path }}'
27+
owner: root
28+
group: root
29+
mode: '0600'
30+
31+
- name: Prepare the swap file
32+
ansible.builtin.command: mkswap "{{ swap_file_path }}"
33+
when: not swap_file_check.stat.exists
34+
35+
- name: Mount the swap file
36+
ansible.posix.mount:
37+
path: none
38+
src: '{{ swap_file_path }}'
39+
fstype: swap
40+
opts: sw
41+
passno: 0
42+
dump: 0
43+
state: present
44+
45+
- name: Enable swap
46+
command: swapon -a
47+
when: not swap_file_check.stat.exists
48+
49+
- name: Enable swappiness
50+
sysctl:
51+
name: vm.swappiness
52+
value: 1

0 commit comments

Comments
 (0)