mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-11 15:15:26 +01:00
Compare commits
4 commits
f9750d8974
...
231d04e012
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
231d04e012 | ||
|
|
6da1331018 | ||
|
|
ab8dfefd90 | ||
|
|
889ca91b48 |
5 changed files with 21 additions and 17 deletions
3
changelogs/fragments/639_fix_authorized_key.yml
Normal file
3
changelogs/fragments/639_fix_authorized_key.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- ansible.posix.authorized_key - fixes error on permission denied in authorized_key module (https://github.com/ansible-collections/ansible.posix/issues/462).
|
||||||
3
changelogs/fragments/670-deprecations.yml
Normal file
3
changelogs/fragments/670-deprecations.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
bugfixes:
|
||||||
|
- "firewalld_info - stop returning warnings as return values; this has been deprecated by ansible-core (https://github.com/ansible-collections/ansible.posix/pull/670)."
|
||||||
|
- "mount - stop returning warnings as return values; this has been deprecated by ansible-core (https://github.com/ansible-collections/ansible.posix/pull/670)."
|
||||||
|
|
@ -225,6 +225,7 @@ import os.path
|
||||||
import tempfile
|
import tempfile
|
||||||
import re
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
|
import errno
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
|
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils._text import to_native
|
||||||
|
|
@ -475,16 +476,17 @@ def parsekey(module, raw_key, rank=None):
|
||||||
return (key, key_type, options, comment, rank)
|
return (key, key_type, options, comment, rank)
|
||||||
|
|
||||||
|
|
||||||
def readfile(filename):
|
def readfile(module, filename):
|
||||||
|
|
||||||
if not os.path.isfile(filename):
|
|
||||||
return ''
|
|
||||||
|
|
||||||
f = open(filename)
|
|
||||||
try:
|
try:
|
||||||
return f.read()
|
with open(filename, 'r') as f:
|
||||||
finally:
|
return f.read()
|
||||||
f.close()
|
except IOError as e:
|
||||||
|
if e.errno == errno.EACCES:
|
||||||
|
module.fail_json(msg="Permission denied on file or path for authorized keys file: {}".format(filename))
|
||||||
|
elif e.errno == errno.ENOENT:
|
||||||
|
return ''
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
def parsekeys(module, lines):
|
def parsekeys(module, lines):
|
||||||
|
|
@ -597,7 +599,7 @@ def enforce_state(module, params):
|
||||||
# check current state -- just get the filename, don't create file
|
# check current state -- just get the filename, don't create file
|
||||||
do_write = False
|
do_write = False
|
||||||
params["keyfile"] = keyfile(module, user, do_write, path, manage_dir)
|
params["keyfile"] = keyfile(module, user, do_write, path, manage_dir)
|
||||||
existing_content = readfile(params["keyfile"])
|
existing_content = readfile(module, params["keyfile"])
|
||||||
existing_keys = parsekeys(module, existing_content)
|
existing_keys = parsekeys(module, existing_content)
|
||||||
|
|
||||||
# Add a place holder for keys that should exist in the state=present and
|
# Add a place holder for keys that should exist in the state=present and
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,6 @@ def main():
|
||||||
active_zones=module.params['active_zones'],
|
active_zones=module.params['active_zones'],
|
||||||
collected_zones=list(),
|
collected_zones=list(),
|
||||||
undefined_zones=list(),
|
undefined_zones=list(),
|
||||||
warnings=list(),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Exit with failure message if requirements modules are not installed.
|
# Exit with failure message if requirements modules are not installed.
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ def _set_mount_save_old(module, args):
|
||||||
old_lines = []
|
old_lines = []
|
||||||
exists = False
|
exists = False
|
||||||
changed = False
|
changed = False
|
||||||
escaped_args = dict([(k, _escape_fstab(v)) for k, v in iteritems(args) if k != 'warnings'])
|
escaped_args = dict([(k, _escape_fstab(v)) for k, v in iteritems(args)])
|
||||||
new_line = '%(src)s %(name)s %(fstype)s %(opts)s %(dump)s %(passno)s\n'
|
new_line = '%(src)s %(name)s %(fstype)s %(opts)s %(dump)s %(passno)s\n'
|
||||||
|
|
||||||
if platform.system() == 'SunOS':
|
if platform.system() == 'SunOS':
|
||||||
|
|
@ -804,7 +804,6 @@ def main():
|
||||||
passno='-',
|
passno='-',
|
||||||
fstab=module.params['fstab'],
|
fstab=module.params['fstab'],
|
||||||
boot='yes' if module.params['boot'] else 'no',
|
boot='yes' if module.params['boot'] else 'no',
|
||||||
warnings=[]
|
|
||||||
)
|
)
|
||||||
if args['fstab'] is None:
|
if args['fstab'] is None:
|
||||||
args['fstab'] = '/etc/vfstab'
|
args['fstab'] = '/etc/vfstab'
|
||||||
|
|
@ -816,7 +815,6 @@ def main():
|
||||||
passno='0',
|
passno='0',
|
||||||
fstab=module.params['fstab'],
|
fstab=module.params['fstab'],
|
||||||
boot='yes',
|
boot='yes',
|
||||||
warnings=[]
|
|
||||||
)
|
)
|
||||||
if args['fstab'] is None:
|
if args['fstab'] is None:
|
||||||
args['fstab'] = '/etc/fstab'
|
args['fstab'] = '/etc/fstab'
|
||||||
|
|
@ -834,8 +832,7 @@ def main():
|
||||||
linux_mounts = get_linux_mounts(module)
|
linux_mounts = get_linux_mounts(module)
|
||||||
|
|
||||||
if linux_mounts is None:
|
if linux_mounts is None:
|
||||||
args['warnings'].append('Cannot open file /proc/self/mountinfo.'
|
module.warn('Cannot open file /proc/self/mountinfo. Bind mounts might be misinterpreted.')
|
||||||
' Bind mounts might be misinterpreted.')
|
|
||||||
|
|
||||||
# Override defaults with user specified params
|
# Override defaults with user specified params
|
||||||
for key in ('src', 'fstype', 'passno', 'opts', 'dump', 'fstab'):
|
for key in ('src', 'fstype', 'passno', 'opts', 'dump', 'fstab'):
|
||||||
|
|
@ -847,7 +844,7 @@ def main():
|
||||||
# specified in 'opts', mount module will ignore 'boot'.
|
# specified in 'opts', mount module will ignore 'boot'.
|
||||||
opts = args['opts'].split(',')
|
opts = args['opts'].split(',')
|
||||||
if module.params['boot'] and 'noauto' in opts:
|
if module.params['boot'] and 'noauto' in opts:
|
||||||
args['warnings'].append("Ignore the 'boot' due to 'opts' contains 'noauto'.")
|
module.warn("Ignore the 'boot' due to 'opts' contains 'noauto'.")
|
||||||
elif not module.params['boot']:
|
elif not module.params['boot']:
|
||||||
args['boot'] = 'no'
|
args['boot'] = 'no'
|
||||||
opts.append('noauto')
|
opts.append('noauto')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue