[root@localhost ~]# sysctl -a |grep vm.swappiness
vm.swappiness = 30

[root@localhost ~]# ansible-galaxy init sysctl
– sysctl was created successfully

[root@localhost ~]# ansible-doc sysctl

[root@localhost ~]# vim test.yml

– hosts: localhost
roles:
– sysctl
vars:
sysctl_settings:
– name: vm.swappiness
value: 90

[root@localhost ~]# vim sysctl/tasks/main.yml

# tasks file for sysctl
– name: sysctl settings
sysctl:
name: “{{ item.name }}”
value: “{{ item.value }}”
reload: true
state: “{{ item.state | default(‘present’) }}”
with_items: “{{ sysctl_settings }}”

[root@localhost ~]# ansible-playbook test.yml

PLAY [localhost] *******************************************************************************************************************************

TASK [Gathering Facts] *************************************************************************************************************************
ok: [localhost]

TASK [sysctl : sysctl settings] ****************************************************************************************************************
changed: [localhost] => (item={u’state’: u’present’, u’name’: u’vm.swappiness’, u’value’: 90})

PLAY RECAP *************************************************************************************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0

[root@localhost ~]# sysctl -a |grep vm.swappiness
vm.swappiness = 90

Leave a comment

Your email address will not be published. Required fields are marked *

Blue Captcha Image
Refresh

*

Protected by WP Anti Spam

Hit Counter provided by dental implants orange county