fix ansible-lint errors
This commit is contained in:
@@ -3,45 +3,45 @@
|
||||
- name: "Enable | create the swap file"
|
||||
block:
|
||||
- name: "Enable | stat the swap file"
|
||||
register: this
|
||||
failed_when: not this.stat.exists
|
||||
register: swapfile_this
|
||||
failed_when: not swapfile_this.stat.exists
|
||||
ansible.builtin.stat:
|
||||
path: "{{ swap_file_path }}"
|
||||
path: "{{ swapfile_path }}"
|
||||
get_checksum: false
|
||||
get_mime: false
|
||||
get_attributes: false
|
||||
|
||||
rescue:
|
||||
- name: "Enable | ensure swap file exists"
|
||||
register: swap_file_create
|
||||
register: swapfile_create
|
||||
ansible.builtin.command:
|
||||
cmd: "{{ swap_file_create_command }}"
|
||||
creates: "{{ swap_file_path }}"
|
||||
cmd: "{{ swapfile_create_command }}"
|
||||
creates: "{{ swapfile_path }}"
|
||||
|
||||
- name: "Enable | set permissions on swap file"
|
||||
ansible.builtin.file:
|
||||
path: "{{ swap_file_path }}"
|
||||
path: "{{ swapfile_path }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0600"
|
||||
|
||||
- name: "Enable | make swap" # noqa: no-handler no-changed-when
|
||||
register: mkswap_result
|
||||
when: swap_file_create is changed
|
||||
register: swapfile_mkswap_result
|
||||
when: swapfile_create is changed
|
||||
ansible.builtin.command:
|
||||
cmd: mkswap {{ swap_file_path }}
|
||||
cmd: mkswap {{ swapfile_path }}
|
||||
|
||||
- name: "Enable | run swapon on the swap file => '{{ swap_file_path }}'"
|
||||
- name: "Enable | run swapon on the swap file => '{{ swapfile_path }}'"
|
||||
when:
|
||||
- mkswap_result is changed
|
||||
- not swap_test_mode
|
||||
- swapfile_mkswap_result is changed
|
||||
- not swapfile_test_mode
|
||||
changed_when: false
|
||||
ansible.builtin.command:
|
||||
cmd: swapon {{ swap_file_path }}
|
||||
cmd: swapon {{ swapfile_path }}
|
||||
|
||||
|
||||
- name: "Set swappiness to '{{ swap_swappiness }}'"
|
||||
- name: "Set swappiness to '{{ swapfile_swappiness }}'"
|
||||
ansible.posix.sysctl:
|
||||
name: vm.swappiness
|
||||
value: "{{ swap_swappiness }}"
|
||||
value: "{{ swapfile_swappiness }}"
|
||||
state: present
|
||||
|
||||
Reference in New Issue
Block a user