# sysctl.conf

**URL:** <https://forum.ansible.com/t/sysctl-conf/16996>\
**Category:** Ansible Project\
**Created:** [December 9, 2014, 3:41pm UTC](https://forum.ansible.com/t/sysctl-conf/16996 "2014-12-09T15:41:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mzp45](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@Mzp45](https://forum.ansible.com/u/Mzp45)\
**Post date:** [December 9, 2014, 3:41pm UTC](https://forum.ansible.com/t/sysctl-conf/16996/1 "2014-12-09T15:41:27Z")

</div>

Hello,  
Is there a way to create a backup of /etc/sysctl.conf when making a change using the sysctl core module? If not can this feature be added?

Thanks

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [December 10, 2014, 12:08am UTC](https://forum.ansible.com/t/sysctl-conf/16996/2 "2014-12-10T00:08:43Z")

</div>

In general, ansible modules do not perform backups of files that they  
modify. I'm not sure that sysctl is especially special in this  
regard. Is there a reason you need this for sysctl but not for copy,  
or any of the other modules?

-Toshio

---

<div class="post-metadata">

**Author:** ![Mzp45](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@Mzp45](https://forum.ansible.com/u/Mzp45)\
**Post date:** [December 10, 2014, 4:20pm UTC](https://forum.ansible.com/t/sysctl-conf/16996/3 "2014-12-10T16:20:43Z")

</div>

I was thinking an implementation along the lines of the “lineinfile” module where you can edit a file and create a backup at the same time. For the sysctl module if you have to edit a sysctl.conf file then a backup seems like a good failsafe.

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [December 10, 2014, 6:17pm UTC](https://forum.ansible.com/t/sysctl-conf/16996/4 "2014-12-10T18:17:38Z")

</div>

Yeah, I just noticed that backup actually does exist on a lot of the  
file-like modules. I just hadn't noticed them before. So yeah,  
adding a backup parameter that does the same thing for sysctl seems  
like a good idea. Could you open a pull request if you can code it or  
an issue if you can't so that hte idea doesn't get lost?

Thanks,  
-Toshio

---

<div class="post-metadata">

**Author:** ![Mzp45](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@Mzp45](https://forum.ansible.com/u/Mzp45)\
**Post date:** [December 12, 2014, 5:51pm UTC](https://forum.ansible.com/t/sysctl-conf/16996/5 "2014-12-12T17:51:42Z")

</div>

Sure, I’ll work on the pull request.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [December 15, 2014, 11:51am UTC](https://forum.ansible.com/t/sysctl-conf/16996/6 "2014-12-15T11:51:16Z")

</div>

Let’s not add a new backup parameter.

The existing backup=yes/no parameter that only creates local backups needs to be overhauled to do remotes, and we can generalize it at this time.

---

<div class="post-metadata">

**Author:** ![Mzp45](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@Mzp45](https://forum.ansible.com/u/Mzp45)\
**Post date:** [December 15, 2014, 6:35pm UTC](https://forum.ansible.com/t/sysctl-conf/16996/7 "2014-12-15T18:35:38Z")

</div>

In which release would the overall be completed?

Thanks

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [December 15, 2014, 6:42pm UTC](https://forum.ansible.com/t/sysctl-conf/16996/8 "2014-12-15T18:42:21Z")

</div>

Honestly, no idea.

We need to get the v2 refactoring out in 1.9 (worst case 2.0) first, and then we’ll be in a good position to make a generalized backup mechanism.

Until then, something like a “fetch” module call to manually do it would be a good solution.

---

<div class="post-metadata">

**Author:** ![Mzp45](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@Mzp45](https://forum.ansible.com/u/Mzp45)\
**Post date:** [December 16, 2014, 6:41pm UTC](https://forum.ansible.com/t/sysctl-conf/16996/9 "2014-12-16T18:41:22Z")

</div>

I dont know if fetch itself will work for me. All i want to do is create a backup of a file on the client before i edit it using sysctl.  
I guess i could try a fetch first and then a copy back to the destination.

For the overall are you going to add a backup option every time a file gets modified (file modules, sysctl moudles, etc.) ?

Thanks
