# Swap support PR

**URL:** <https://forum.ansible.com/t/swap-support-pr/17419>\
**Category:** Ansible Developer\
**Created:** [February 2, 2015, 5:01pm UTC](https://forum.ansible.com/t/swap-support-pr/17419 "2015-02-02T17:01:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Umur\_Kontaci](https://avatars.discourse-cdn.com/v4/letter/u/ee7513/32.png) [@Umur\_Kontaci](https://forum.ansible.com/u/Umur_Kontaci)\
**Post date:** [February 2, 2015, 5:01pm UTC](https://forum.ansible.com/t/swap-support-pr/17419/1 "2015-02-02T17:01:52Z")

</div>

Hey everyone,

I’ve just send a PR for a swap module and had some feedback and wanted to discuss this with a wider group.

You can look at the PR at: [https://github.com/ansible/ansible-modules-extras/pull/233](https://github.com/ansible/ansible-modules-extras/pull/233)

Brian (bcoca) had made two points:

1. We already have a mount module for managing ftstab entries and it’s not a good idea to have two modules handling the same file. I am with Brian on this.

2. We do have a filesystem module but it does not handle swap but may be changed to do so. I partially agree with Brian that this module can be modified as to create swap partitions with mkswap and swapon, but one things the module doesn’t do is to remove filesystems. This makes sense because we don’t usually remove filesystems but it is possible to remove swap partitions without having a serious problem.

I also really like a feature and find very useful that creates swaps to make a build on cloud VM and destroy that swap after I’m done. I would like keep that feature is possible.

I understand the need for controlling the module sprawl and integrating features on existing ones but I’m not sure using filesystem module is a good idea, (especially editing it to support removal of filesystems).

What do you think?

---

<div class="post-metadata">

**Author:** ![Giovanni\_Tirloni](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Giovanni\_Tirloni](https://forum.ansible.com/u/Giovanni_Tirloni)\
**Post date:** [February 2, 2015, 6:18pm UTC](https://forum.ansible.com/t/swap-support-pr/17419/2 "2015-02-02T18:18:53Z")

</div>

> Hey everyone,
> 
> I've just send a PR for a swap module and had some feedback and wanted to  
> discuss this with a wider group.
> 
> You can look at the PR  
> at: [https://github.com/ansible/ansible-modules-extras/pull/233](https://github.com/ansible/ansible-modules-extras/pull/233)

Cool, thanks!

> Brian (bcoca) had made two points:  
> 1. We already have a mount module for managing ftstab entries and it's  
> not  
> a good idea to have two modules handling the same file. I am with Brian  
> on  
> this.

+1

> 2. We do have a filesystem module but it does not handle swap but may be  
> changed to do so. I partially agree with Brian that this module can be  
> modified as to create swap partitions with mkswap and swapon, but one  
> things the module doesn't do is to remove filesystems. This makes sense  
> because we don't usually remove filesystems but it is possible to remove  
> swap partitions without having a serious problem.

I'm in favor of adding a 'state' property to the filesystem module. I'm  
not sure how we're dealing with unimplemented features but you could  
focus on swap and raise an warning/exception for other types.

> I also really like a feature and find very useful that creates swaps to  
> make a build on cloud VM and destroy that swap after I'm done. I would  
> like  
> keep that feature is possible.

By not making it permanent, right? IMHO, another property for the  
filesystem module.

Giovanni

---

<div class="post-metadata">

**Author:** ![Umur\_Kontaci](https://avatars.discourse-cdn.com/v4/letter/u/ee7513/32.png) [@Umur\_Kontaci](https://forum.ansible.com/u/Umur_Kontaci)\
**Post date:** [February 2, 2015, 6:25pm UTC](https://forum.ansible.com/t/swap-support-pr/17419/3 "2015-02-02T18:25:59Z")

</div>

Otherwise, it wouldn't use it as swap after a reboot but it will still  
remain in the fs, occupying space.

There's one more thing to consider, if the user removes a swap but doesn't  
remove the entry from fstab, the machine will err on boot since it can't  
find the file/device it's supposed to mount. Any ideas?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [February 2, 2015, 6:30pm UTC](https://forum.ansible.com/t/swap-support-pr/17419/4 "2015-02-02T18:30:29Z")

</div>

I expect any user dealing with fstab to be aware of the pitfalls of  
creating broken entries. I know you created this for a very specific  
use, but it should be just as easy to create a role that takes care of  
doing it correctly instead of internalizing it all in a single module.

Also the file module can be used to remove the swap file, it already  
has state=absent.
