Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ansible/roles/base/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ __base_packages:
- jq
- python3-pip
- vim

# swap config for s390x
swap_file_path: /swapfile
swap_file_size: 8G
42 changes: 42 additions & 0 deletions ansible/roles/base/tasks/setup-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,45 @@
enabled: no
masked: yes
when: "'auditd' in ansible_facts.packages"

- name: Set up swap space on s390x
when: ansible_architecture == "s390x"
block:
- name: Check if swap file exists
ansible.builtin.stat:
path: "{{ swap_file_path }}"
register: swap_file

- name: Create swap file
become: true
ansible.builtin.command:
cmd: "fallocate -l {{ swap_file_size }} {{ swap_file_path }}"
creates: "{{ swap_file_path }}"
when: not swap_file.stat.exists

- name: Set swap file permissions
become: true
ansible.builtin.file:
path: "{{ swap_file_path }}"
mode: "0600"

- name: Make swap file
become: true
ansible.builtin.command:
cmd: "mkswap {{ swap_file_path }}"
when: not swap_file.stat.exists

- name: Enable swap file
become: true
ansible.builtin.command:
cmd: "swapon {{ swap_file_path }}"
register: swapon_result
changed_when: swapon_result.rc == 0
failed_when: false

- name: Add swap to fstab
become: true
ansible.builtin.lineinfile:
path: /etc/fstab
line: "{{ swap_file_path }} none swap sw 0 0"
state: present
Loading