23 lines
794 B
YAML
23 lines
794 B
YAML
---
|
|
- 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
|
|
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
|
|
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"
|