module/sysctl - help for review

Hi,

A lot of repliers are appreciated.

I propose a sysctl module for ansible : https://github.com/ansible/ansible/pull/1810

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

- name: Set or update vm.swappiness to 5 in systl.conf, and reload if changed with sysctl -p 
  **sysctl: name=vm.swappiness value=5 state=present**

Others examples in DOCUMENTATION visible on 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

cd ansible

git checkout sysctl

or simply (not so nice) :

wget https://raw.github.com/davixx/ansible/sysctl/library/sysctl -O /path/to/ansible/library/sysctl

Thanks for your time,

Please find below the expected end of my first email.

Hi,

A lot of repliers are appreciated.

I propose a sysctl module for ansible : https://github.com/ansible/ansible/pull/1810

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

- name: Set or update vm.swappiness to 5 in systl.conf, and reload if changed with sysctl -p 
  **sysctl: name=vm.swappiness value=5 state=present**

Others examples in DOCUMENTATION visible on 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

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,

Hi,

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