ansible-role-basic-system-s.../tasks/swap_device.yml

23 lines
794 B
YAML
Raw Normal View History

2024-07-12 16:30:36 +02:00
---
- name: swap_device | Configure and enable a swap device
when: swap_device
tags:
- swap
- swap_device
block:
- name: swap_device | Initialize the swap device
ansible.builtin.shell: mkswap {{ swap_device_name }} && touch /root/.mkswap_executed
2024-07-12 16:30:36 +02:00
args:
creates: /root/.mkswap_executed
register: mkswap_command_execution
- name: swap_device | Enable the swap device
ansible.builtin.shell: swapon {{ swap_device_name }} && touch /root/.swapon_executed
2024-07-12 16:30:36 +02:00
args:
creates: /root/.swapon_executed
- name: swap_device | Add the swap device to the fstab file
ansible.builtin.lineinfile:
path: /etc/fstab
regexp: "^{{ swap_device_name }}"
line: "{{ swap_device_name }} swap swap defaults 0 0"