Skip to content

Commit

Permalink
Attempts to Resize Existing Swap File
Browse files Browse the repository at this point in the history
Resolves #22
  • Loading branch information
misilot committed Jul 19, 2022
1 parent e614780 commit 2a3d660
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tasks/check-size.yml
@@ -0,0 +1,13 @@
---
- name: Check if swap file exists
stat:
path: "{{ swap_file_path }}"
get_checksum: false
get_md5: false
register: swap_file_check
changed_when: false

- name: Set variable for existing swap file size
set_fact:
swap_file_existing_size_mb: "{{ (swap_file_check.stat.size / 1024 / 1024) | int }}"
when: swap_file_check.stat.exists
4 changes: 4 additions & 0 deletions tasks/main.yml
Expand Up @@ -7,8 +7,12 @@
opts: sw
state: "{{ swap_file_state }}"

- include_tasks: check-size.yml
when: swap_file_state == 'present'

- include_tasks: disable.yml
when: swap_file_state == 'absent'
or (swap_file_state == 'present' and swap_file_existing_size_mb != swap_file_size_mb)

- include_tasks: enable.yml
when: swap_file_state == 'present'

0 comments on commit 2a3d660

Please sign in to comment.