Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add role "swap" - configure swap space (if not already exists) #160

Merged
merged 5 commits into from
Apr 19, 2022
Merged

Conversation

vitabaks
Copy link
Owner

Variables:

  • swap_file_create
  • swap_file_path
  • swap_file_size_mb

Variables: swap_file_create, swap_file_path, swap_file_size_mb
@vitabaks
Copy link
Owner Author

vitabaks commented Apr 19, 2022

test

swap_file_size_mb: '2048'

ansible-playbook add_pgnode.yml --tag swap

PLAY [PostgreSQL High-Availability Cluster Scaling (add replica node)] *******************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************************************************
ok: [10.128.64.157]

TASK [Include OS-specific variables] *****************************************************************************************************************************************************************
ok: [10.128.64.157]

TASK [swap : Ensure swap exists] *********************************************************************************************************************************************************************
ok: [10.128.64.157]

TASK [swap : Swap exists] ****************************************************************************************************************************************************************************
ok: [10.128.64.157] => {
    "msg": "Size 1024"
}

TASK [swap : Disable all existing swaps] *************************************************************************************************************************************************************
changed: [10.128.64.157]

TASK [swap : Remove swap from /etc/fstab] ************************************************************************************************************************************************************
changed: [10.128.64.157]

TASK [swap : Remove swap file (if exists)] ***********************************************************************************************************************************************************
changed: [10.128.64.157]

TASK [swap : Create swap file] ***********************************************************************************************************************************************************************
changed: [10.128.64.157]

TASK [swap : Set permissions on swap file] ***********************************************************************************************************************************************************
changed: [10.128.64.157]

TASK [swap : Make swap file if necessary] ************************************************************************************************************************************************************
changed: [10.128.64.157]

TASK [swap : Run swapon on the swap file] ************************************************************************************************************************************************************
changed: [10.128.64.157]

TASK [swap : Manage swap file entry in fstab] ********************************************************************************************************************************************************
changed: [10.128.64.157]

PLAY [pgbackrest:postgres_cluster] *******************************************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************************************************
ok: [10.128.64.157]
ok: [10.128.64.136]

TASK [Include OS-specific variables] *****************************************************************************************************************************************************************
ok: [10.128.64.136]
ok: [10.128.64.157]

PLAY [replica] ***************************************************************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************************************************
ok: [10.128.64.157]

TASK [Include OS-specific variables] *****************************************************************************************************************************************************************
ok: [10.128.64.157]

PLAY RECAP *******************************************************************************************************************************************************************************************
10.128.64.136              : ok=2    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0
10.128.64.157              : ok=16   changed=8    unreachable=0    failed=0    skipped=3    rescued=0    ignored=0

Result:

[root@host-05 ~]# swapon --show
NAME      TYPE SIZE USED PRIO
/swapfile file   2G   0B   -2

idempotency test

ansible-playbook add_pgnode.yml --tag swap

PLAY [PostgreSQL High-Availability Cluster Scaling (add replica node)] *******************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************************************************
ok: [10.128.64.157]

TASK [Include OS-specific variables] *****************************************************************************************************************************************************************
ok: [10.128.64.157]

TASK [swap : Ensure swap exists] *********************************************************************************************************************************************************************
ok: [10.128.64.157]

TASK [swap : Swap exists] ****************************************************************************************************************************************************************************
ok: [10.128.64.157] => {
    "msg": "Size 2048"
}

PLAY [pgbackrest:postgres_cluster] *******************************************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************************************************
ok: [10.128.64.157]
ok: [10.128.64.136]

TASK [Include OS-specific variables] *****************************************************************************************************************************************************************
ok: [10.128.64.136]
ok: [10.128.64.157]

PLAY [replica] ***************************************************************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************************************************
ok: [10.128.64.157]

TASK [Include OS-specific variables] *****************************************************************************************************************************************************************
ok: [10.128.64.157]

PLAY RECAP *******************************************************************************************************************************************************************************************
10.128.64.136              : ok=2    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0
10.128.64.157              : ok=8    changed=0    unreachable=0    failed=0    skipped=11   rescued=0    ignored=0

test passed.

Example:

[root@host-05 ~]# swapon --show=SIZE --noheadings
1000M
  20M

Result:

TASK [swap : Swap exists] ********************
ok: [10.128.64.157] => {
    "msg": "swap_size_mb: 1020"
}
@vitabaks vitabaks merged commit d17a520 into master Apr 19, 2022
@vitabaks vitabaks deleted the dev branch November 9, 2022 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant