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 support for swap management #106

Open
gavenkoa opened this issue Oct 28, 2020 · 3 comments · May be fixed by #135
Open

Add support for swap management #106

gavenkoa opened this issue Oct 28, 2020 · 3 comments · May be fixed by #135
Labels
feature This issue/PR relates to a feature request.

Comments

@gavenkoa
Copy link

gavenkoa commented Oct 28, 2020

There were tasks:

closed due to migration to collections.

Docs:

don't mention swap support. I believe it is not implemented.

There are two things here:

  • swap creation (LVM/file/partition) - because of variety it is out of scope
  • swap registration and activation:
    • add/update/remove entry in /etc/fstab
    • call to swapon/swapoff.
@mhalano
Copy link

mhalano commented Oct 30, 2020

@gavenkoa The management of /etc/fstab is made by the mount module. I think this module should just manage activiation (swapon/off) and format (mkswap)

@maxamillion maxamillion added the feature This issue/PR relates to a feature request. label Dec 1, 2020
quidame added a commit to quidame/collection-ansible.posix that referenced this issue Feb 13, 2021
* Declare functions swapon() & swapoff(), is_swap() & reswap().
* Apply swapon/swapoff for states mounted, unmounted, remounted and
  absent.
* Move 'swap' related test cases into dedicated file (swap.yml)
* Add new test cases about swap enabling/disabling
* Update documentation
@quidame quidame linked a pull request Feb 13, 2021 that will close this issue
quidame added a commit to quidame/collection-ansible.posix that referenced this issue Feb 13, 2021
* Declare functions swapon() & swapoff(), is_swap() & reswap().
* Apply swapon/swapoff for states mounted, unmounted, remounted and
  absent.
* Move 'swap' related test cases into dedicated file (swap.yml)
* Add new test cases about swap enabling/disabling
* Update documentation
quidame added a commit to quidame/collection-ansible.posix that referenced this issue Feb 13, 2021
* Declare functions swapon() & swapoff(), is_swap() & reswap().
* Apply swapon/swapoff for states mounted, unmounted, remounted and
  absent.
* Move 'swap' related test cases into dedicated file (swap.yml)
* Add new test cases about swap enabling/disabling
* Update documentation
quidame added a commit to quidame/collection-ansible.posix that referenced this issue Feb 13, 2021
* Declare functions swapon() & swapoff(), is_swap() & reswap().
* Apply swapon/swapoff for states mounted, unmounted, remounted and
  absent.
* Move 'swap' related test cases into dedicated file (swap.yml)
* Add new test cases about swap enabling/disabling
* Update documentation
quidame added a commit to quidame/collection-ansible.posix that referenced this issue Feb 13, 2021
* Declare functions swapon() & swapoff(), is_swap() & reswap().
* Apply swapon/swapoff for states mounted, unmounted, remounted and
  absent.
* Move 'swap' related test cases into dedicated file (swap.yml)
* Add new test cases about swap enabling/disabling
* Update documentation
quidame added a commit to quidame/collection-ansible.posix that referenced this issue Feb 13, 2021
* Declare functions swapon() & swapoff(), is_swap() & reswap().
* Apply swapon/swapoff for states mounted, unmounted, remounted and
  absent.
* Move 'swap' related test cases into dedicated file (swap.yml)
* Add new test cases about swap enabling/disabling
* Update documentation
quidame added a commit to quidame/collection-ansible.posix that referenced this issue Mar 27, 2021
* Declare functions swapon() & swapoff(), is_swap() & reswap().
* Apply swapon/swapoff for states mounted, unmounted, remounted and
  absent.
* Move 'swap' related test cases into dedicated file (swap.yml)
* Add new test cases about swap enabling/disabling
* Update documentation
quidame added a commit to quidame/collection-ansible.posix that referenced this issue Mar 28, 2021
* Declare functions swapon() & swapoff(), is_swap() & reswap().
* Apply swapon/swapoff for states mounted, unmounted, remounted and
  absent.
* Override default opts and boot when fstype=swap.
* Do not honor 'fstab' when fstype=swap (fail instead).
* Also fail when fstype=swap and 'path' is not 'none' ('-' for Solaris).
* Update module documentation accordingly.
+ Replace all platform.system() calls by a variable.

refactor integration tests

* Improve readability/understanding of what is tested, and what OS is
  targeted.
* Move 'swap' related test cases into dedicated file (swap.yml).
* Add new test cases about swap enabling/disabling.
* Extend tests to FreeBSD when possible.
@nre-ableton
Copy link

swap creation (LVM/file/partition) - because of variety it is out of scope

This was implemented in the filesystem module, see ansible/ansible#49456.

@quidame
Copy link
Contributor

quidame commented Apr 16, 2021

Hi, it would be nice to see swap management implemented from begin to end, that is not currently the case.

Getting swap online or offline after swap filesystem creation (with filesystem module) and its declaration in /etc/fstab (with mount module) is the last missing piece to manage swap spaces only with dedicated modules (that means without command or shell).

I've implemented such swapon and swapoff commands in the mount module (#135) that mirror for swap fstype what mount and umount do for other fstypes, all this working fine with the same state=mounted and state=unmounted parameters.

The good news are that the draft, that comes with new integration tests to ensure it does the job (swapon when state=mounted; swapoff when state=unmounted), does the job.

The bad news is that I'm not satisfied with it (that may be good news too). The changes introduce a lot of code, and overall, many branches (if/else) to take a special care of swap fstype, that in fact is the only one fstype that is not managed by the mount command ! And THIS is the point. For that reason, my opinion is that swap management has (should have) nothing to do with the mount module, which is to mount devices over mountpoints. The mount module is called mount, it is not called fstab. Putting more stuff in this module for what probably began as a corner case will make this module hard to maintain/debug/evolve, and even to document (blahblah, unless fstype=swap many times). It seems like swap filesystem is the coucou of the mount module. By the way, state=mounted or state=unmounted don't make sense with swap fs and could hurt sysadmins (as me); on the other hand, state=offline would just be one more state to make things more complicated.

For short, I think it would be better to have a dedicated swap module, to setup such devices in fstab and enable/disable them (= make them online/offline = available/unavailable for memory swapping, but also for crash dump storage on FreeBSD, etc). Changes of fstab could be shared in module_utils, and swap-related code could/would/should be removed from mount module after a deprecation period ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants