Skip to content

Commit

Permalink
pam_limits creates custom file if not exist (#26989) (#28616)
Browse files Browse the repository at this point in the history
  • Loading branch information
giovannisciortino authored and samdoran committed Aug 29, 2017
1 parent ef58d34 commit 94707d0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/ansible/modules/system/pam_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
- Comment associated with the limit.
required: false
default: ''
notes:
- If dest file doesn't exists, it is created.
'''

EXAMPLES = '''
Expand Down Expand Up @@ -168,12 +170,17 @@ def main():

if os.path.isfile(limits_conf):
if not os.access(limits_conf, os.W_OK):
module.fail_json(msg="%s is not writable. Use sudo" % (limits_conf) )
module.fail_json(msg="%s is not writable. Use sudo" % limits_conf)
else:
module.fail_json(msg="%s is not visible (check presence, access rights, use sudo)" % (limits_conf) )
limits_conf_dir = os.path.dirname(limits_conf)
if os.path.isdir(limits_conf_dir) and os.access(limits_conf_dir, os.W_OK):
open(limits_conf, 'a').close()
changed = True
else:
module.fail_json(msg="directory %s is not writable (check presence, access rights, use sudo)" % limits_conf_dir)

if use_max and use_min:
module.fail_json(msg="Cannot use use_min and use_max at the same time." )
module.fail_json(msg="Cannot use use_min and use_max at the same time.")

if not (value in ['unlimited', 'infinity', '-1'] or value.isdigit()):
module.fail_json(msg="Argument 'value' can be one of 'unlimited', 'infinity', '-1' or positive number. Refer to manual pages for more details.")
Expand Down

0 comments on commit 94707d0

Please sign in to comment.