# module/sysctl - help for review

**URL:** <https://forum.ansible.com/t/module-sysctl-help-for-review/12185>\
**Category:** Ansible Project\
**Created:** [January 5, 2013, 6:42am UTC](https://forum.ansible.com/t/module-sysctl-help-for-review/12185 "2013-01-05T06:42:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![david.chanial](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@david.chanial](https://forum.ansible.com/u/david.chanial)\
**Post date:** [January 5, 2013, 6:42am UTC](https://forum.ansible.com/t/module-sysctl-help-for-review/12185/1 "2013-01-05T06:42:24Z")

</div>

Hi,

_A lot of repliers are appreciated._

I propose a sysctl module for ansible : [https://github.com/ansible/ansible/pull/1810](https://github.com/ansible/ansible/pull/1810)

The idea is simply to permit you to update sysctl.conf :

> ```auto
> - name: Set or update vm.swappiness to 5 in systl.conf, and reload if changed with sysctl -p 
> 
> ```

> ```auto
> **sysctl: name=vm.swappiness value=5 state=present**
> 
> ```

Others examples in DOCUMENTATION visible on [https://github.com/ansible/ansible/pull/1810/files](https://github.com/ansible/ansible/pull/1810/files) ;

First, do you think you will use this module if integrated to ansible core package ?

Second, can you test the module and report issue to this thread, or in the pull request comments ?

For this, you can :

> git clone [https://github.com/davixx/ansible.git](https://github.com/davixx/ansible.git)

> cd ansible

> git checkout sysctl

or simply (not so nice) :

> wget [https://raw.github.com/davixx/ansible/sysctl/library/sysctl](https://raw.github.com/davixx/ansible/sysctl/library/sysctl) -O /path/to/ansible/library/sysctl

Thanks for your time,

---

<div class="post-metadata">

**Author:** ![david.chanial](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@david.chanial](https://forum.ansible.com/u/david.chanial)\
**Post date:** [January 5, 2013, 6:44am UTC](https://forum.ansible.com/t/module-sysctl-help-for-review/12185/2 "2013-01-05T06:44:41Z")

</div>

Please find below the expected end of my first email.

---

<div class="post-metadata">

**Author:** ![Romeo\_Theriault](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@Romeo\_Theriault](https://forum.ansible.com/u/Romeo_Theriault)\
**Post date:** [January 5, 2013, 7:25am UTC](https://forum.ansible.com/t/module-sysctl-help-for-review/12185/3 "2013-01-05T07:25:41Z")

</div>

> Hi,
> 
> _A lot of repliers are appreciated._
> 
> I propose a sysctl module for ansible : [https://github.com/ansible/ansible/pull/1810](https://github.com/ansible/ansible/pull/1810)
> 
> The idea is simply to permit you to update sysctl.conf :
> 
> > ```auto
> > - name: Set or update vm.swappiness to 5 in systl.conf, and reload if changed with sysctl -p 
> > 
> > ```
> 
> > ```auto
> > **sysctl: name=vm.swappiness value=5 state=present**
> > 
> > ```
> 
> Others examples in DOCUMENTATION visible on [https://github.com/ansible/ansible/pull/1810/files](https://github.com/ansible/ansible/pull/1810/files) ;
> 
> First, do you think you will use this module if integrated to ansible core package ?

I would probably use it if it was there, but just to play devils advocate a bit can you explain how this is better than say, using the ‘lineinfile’ module and then having a ‘notify’ which calls `sysctl -p` if the file changed?

Thanks,  
Romeo

---

<div class="post-metadata">

**Author:** ![david.chanial](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@david.chanial](https://forum.ansible.com/u/david.chanial)\
**Post date:** [January 5, 2013, 7:49am UTC](https://forum.ansible.com/t/module-sysctl-help-for-review/12185/4 "2013-01-05T07:49:55Z")

</div>

Hi,

> I would probably use it if it was there, but just to play devils advocate a bit can you explain how this is better than say, using the ‘lineinfile’ module and then having a ‘notify’ which calls `sysctl -p` if the file changed?

sysctl module provide a default, but optional check system :

- before trying change : sysctl check if the key exists and /proc/sys and if she is writeable.

- after the change : sysctl call sysctl -p and verify in /proc/sys if the changed key really have the good value.

Note the ability to append :

- checks=none ; check=before ; check=after ; check=both (default) to the command.
- reload=no ; reload=yes (default) ; if change made to /etc/sysctl.conf

So the added value is :

1. One command (sysctl) instead (lineinfile+notify+command)
2. Checked validity before and after sysctl.conf update.

Thanks for your time,

---

<div class="post-metadata">

**Author:** ![david.chanial](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@david.chanial](https://forum.ansible.com/u/david.chanial)\
**Post date:** [January 6, 2013, 6:12pm UTC](https://forum.ansible.com/t/module-sysctl-help-for-review/12185/5 "2013-01-06T18:12:04Z")

</div>

Hi,

> > >

Another good point for this module is to be used in ad-hoc mode.
