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

Swap file is always recreated if the size is given as a number rather than a string #39

Closed
iay opened this issue Apr 21, 2024 · 3 comments
Labels

Comments

@iay
Copy link

iay commented Apr 21, 2024

This is probably obvious to people more used to reading Ansible examples, but the swap file size you provide to this role MUST be a string, e.g., "2048". If you set the parameter to a number, e.g., 2048, the file will always be removed and recreated.

It might be nice to have argument_specs so that this is detected.

@Floppy
Copy link

Floppy commented Jun 11, 2024

Note for others who may come across this issue; this just bit me even though I thought I was using a string. I set swap_file_size_mb: "{{ ansible_memtotal_mb }}", thinking that because the quotes were there it would be a string. However, because of the quirk of ansible's variable interpolation in YAML, it put it through as a number. You need an explicit string conversion if you want to do this: swap_file_size_mb: "{{ ansible_memtotal_mb | string }}"

In terms of fixing this in the role, I think that the best defensive choice is probably to make sure both things are converted to the same type in the comparison at

or (swap_file_state == 'present' and swap_file_existing_size_mb != swap_file_size_mb)
.

Copy link

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

@github-actions github-actions bot added the stale label Oct 11, 2024
Copy link

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants