# sysctl module usage in playbooks

**URL:** <https://forum.ansible.com/t/sysctl-module-usage-in-playbooks/12481>\
**Category:** Ansible Project\
**Created:** [March 11, 2013, 4:46pm UTC](https://forum.ansible.com/t/sysctl-module-usage-in-playbooks/12481 "2013-03-11T16:46:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PhilEv](https://avatars.discourse-cdn.com/v4/letter/p/ee59a6/32.png) [@PhilEv](https://forum.ansible.com/u/PhilEv)\
**Post date:** [March 11, 2013, 4:46pm UTC](https://forum.ansible.com/t/sysctl-module-usage-in-playbooks/12481/1 "2013-03-11T16:46:03Z")

</div>

Hi,

testing ansible (thanks for this amazing SW!)  
I would like to be able to switch ON or OFF a kernel parameter via some code similar to:

- name: Make sure the following item is turned ON  
action: sysctl value=1 name=$item state=present  
with\_items:
- ‘net.ipv4.icmp\_echo\_ignore\_all’

that works well.

to avoid code duplication that just differ by “value=0”  
I’m wondering about any possibility to have something like:

- vars:  
toggle: 1

- name: Make sure the following item are turned ON  
action: sysctl value=$toggle name=$item state=present  
with\_items:

- 'net.ipv4.icmp\_echo\_ignore\_all

so the value to be set is not hardcoded - but calculated/inferred, to be able to switch it from 1 on 0 (enable/disable)  
(use case: switch the value to: 1 - currentValue to activate/deactivate the ping )

I’ve not been able to make this working and suspect this is not working  
What am I missing ?

thanks for your help.

Phil.
