summaryrefslogtreecommitdiff
path: root/lib/ansible
diff options
context:
space:
mode:
authorSam Doran <sdoran@ansible.com>2017-10-10 12:01:33 -0400
committerToshio Kuratomi <a.badger@gmail.com>2017-10-10 09:01:53 -0700
commit60874bad3e1af75dbd265a89cae0c8c9d29ff380 (patch)
treeeb98d2a51d2135d341cc679cd419955fd030def7 /lib/ansible
parentccd86d5a001da31313bf3cb2ec478c8f2e130295 (diff)
downloadansible-60874bad3e1af75dbd265a89cae0c8c9d29ff380.tar.gz
Remove sysctl entries when state=absent (#31486)
* Remove sysctl entry when state=absent * Cleanup sysctl integration test syntax * Correct grammar on error message * Add sysctl integration test for state=absent (cherry picked from commit 2610b521bc1cc3578061be12bb20d33ae6f867b7)
Diffstat (limited to 'lib/ansible')
-rw-r--r--lib/ansible/modules/system/sysctl.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/ansible/modules/system/sysctl.py b/lib/ansible/modules/system/sysctl.py
index a51073f78e..4f1c212a43 100644
--- a/lib/ansible/modules/system/sysctl.py
+++ b/lib/ansible/modules/system/sysctl.py
@@ -165,6 +165,9 @@ class SysctlModule(object):
self.write_file = True
elif self.file_values[thisname] is None and self.args['state'] == "absent":
self.changed = False
+ elif self.file_values[thisname] and self.args['state'] == "absent":
+ self.changed = True
+ self.write_file = True
elif self.file_values[thisname] != self.args['value']:
self.changed = True
self.write_file = True
@@ -380,20 +383,20 @@ def main():
)
if module.params['name'] is None:
- module.fail_json(msg="name can not be None")
+ module.fail_json(msg="name cannot be None")
if module.params['state'] == 'present' and module.params['value'] is None:
- module.fail_json(msg="value can not be None")
+ module.fail_json(msg="value cannot be None")
# In case of in-line params
if module.params['name'] == '':
- module.fail_json(msg="name can not be blank")
+ module.fail_json(msg="name cannot be blank")
if module.params['state'] == 'present' and module.params['value'] == '':
- module.fail_json(msg="value can not be blank")
+ module.fail_json(msg="value cannot be blank")
result = SysctlModule(module)
module.exit_json(changed=result.changed)
-# import module snippets
+
if __name__ == '__main__':
main()