Updated to clean up and stabilize how installations and expansion to a second region works.
diff --git a/tasks/main.yml b/tasks/main.yml
index 819bc32..1ece891 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -8,27 +8,32 @@
- name: Set swap file permissions
file: dest={{ swap_path }} owner=root group=root mode=0600
+ when: swap_allocate | changed
+
- name: Determine whether swap file must be initialized
command: file {{ swap_path }}
register: file_type
changed_when: false
+ when: swap_allocate | changed
- name: Initialize swap file
command: mkswap {{ swap_path }}
- when: file_type.stdout.count('swap file') == 0
+ when: swap_allocate | changed and file_type.stdout.count('swap file') == 0
- name: Add swap to fstab
mount: src={{ swap_path }} name=none fstype=swap opts=sw passno=0 dump=0 state=present
+ when: swap_allocate | changed
- name: Determine whether swap file must be activated
command: swapon -s
register: active_swaps
changed_when: false
+ when: swap_allocate | changed
- name: Activate swap
command: swapon {{ swap_path}}
- when: active_swaps.stdout.count('{{ swap_path }}') == 0
+ when: swap_allocate | changed and active_swaps.stdout.count('{{ swap_path }}') == 0
become: yes
become_user: root