sysctl.conf

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

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

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.

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

Sure, I’ll work on the pull request.

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.

In which release would the overall be completed?

Thanks

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.

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