ansible-collections / ansible.posix

Ansible Collection for Posix
Other
155 stars 150 forks source link

sysctl: create parameter #63

Open tomuxi opened 4 years ago

tomuxi commented 4 years ago
SUMMARY

It could be useful for the sysctl module to have a 'create' parameter similar to many other file related modules. This would make it easier to modify settings in a sysctl file only if it already exists. Having create: no would not create the settings file. Having create: yes (default) would create the settings file if it does not yet exist.

ISSUE TYPE
COMPONENT NAME

sysctl

ADDITIONAL INFORMATION

Having a 'create' parameter would reduce the code necessary to handle a situation when you don't want to create the setting file but only modify a possibly existing one.

- name: Modify the existing sysctl hardening file
  sysctl:
    state: present
    sysctl_file: '/etc/sysctl.d/hardening.conf'
    create: no
    name: '{{ item }}'
    value: '1'
  loop:
  - net.ipv4.conf.all.log_martians
  - net.ipv4.conf.default.log_martians
maxamillion commented 4 years ago

Agreed, this would definitely be useful and I'll be honest I didn't realize this option wasn't already available. I'll add it to my TODO list. :+1: