fix ansible-lint errors
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
---
|
||||
swap_file_path: /swapfile
|
||||
swap_file_size_mb: '512'
|
||||
swap_swappiness: '60'
|
||||
swap_file_state: present
|
||||
swap_file_create_command: "dd if=/dev/zero of={{ swap_file_path }} bs=1M count={{ swap_file_size_mb }}"
|
||||
swapfile_path: /swapfile
|
||||
swapfile_size_mb: '512'
|
||||
swapfile_swappiness: '60'
|
||||
swapfile_state: present
|
||||
swapfile_create_command: "dd if=/dev/zero of={{ swapfile_path }} bs=1M count={{ swapfile_size_mb }}"
|
||||
|
||||
swap_test_mode: false
|
||||
swapfile_test_mode: false
|
||||
|
||||
@@ -10,8 +10,8 @@ galaxy_info:
|
||||
|
||||
platforms:
|
||||
- name: "Ubuntu"
|
||||
versions: [ "focal", "jammy" ]
|
||||
versions: ["focal", "jammy"]
|
||||
|
||||
galaxy_tags: [ ]
|
||||
galaxy_tags: []
|
||||
|
||||
dependencies: []
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
cache_valid_time: 600
|
||||
|
||||
roles:
|
||||
- role: genlab.swapfile
|
||||
swap_file_path: /swapfile
|
||||
swap_file_size_mb: 2000
|
||||
swap_swappiness: 30
|
||||
swap_file_state: present
|
||||
swap_test_mode: true
|
||||
- role: genlab.common.swapfile
|
||||
swapfile_path: /swapfile
|
||||
swapfile_size_mb: 2000
|
||||
swapfile_swappiness: 30
|
||||
swapfile_state: present
|
||||
swapfile_test_mode: true
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
|
||||
- name: "Disable | ensure swap file doesn't exist"
|
||||
ansible.builtin.file:
|
||||
path: "{{ swap_file_path }}"
|
||||
path: "{{ swapfile_path }}"
|
||||
state: absent
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
- name: "Manage swap file entry in fstab"
|
||||
ansible.posix.mount:
|
||||
name: none
|
||||
src: "{{ swap_file_path }}"
|
||||
src: "{{ swapfile_path }}"
|
||||
fstype: swap
|
||||
opts: sw
|
||||
state: "{{ swap_file_state }}"
|
||||
state: "{{ swapfile_state }}"
|
||||
|
||||
|
||||
- name: "Include disable swap tasks"
|
||||
when: swap_file_state == 'absent'
|
||||
when: swapfile_state == 'absent'
|
||||
ansible.builtin.include_tasks: disable.yml
|
||||
|
||||
|
||||
- name: "Include enable swap tasks"
|
||||
when: swap_file_state == 'present'
|
||||
when: swapfile_state == 'present'
|
||||
ansible.builtin.include_tasks: enable.yml
|
||||
|
||||
Reference in New Issue
Block a user