mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-11 15:15:26 +01:00
Compare commits
2 commits
2cbd5b93fb
...
03e9ed4c58
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03e9ed4c58 | ||
|
|
889ca91b48 |
3 changed files with 1 additions and 36 deletions
|
|
@ -226,7 +226,6 @@ import tempfile
|
|||
import re
|
||||
import shlex
|
||||
import errno
|
||||
import traceback
|
||||
from operator import itemgetter
|
||||
|
||||
from ansible.module_utils._text import to_native
|
||||
|
|
@ -483,8 +482,7 @@ def readfile(module, filename):
|
|||
return f.read()
|
||||
except IOError as e:
|
||||
if e.errno == errno.EACCES:
|
||||
module.fail_json(msg="Permission denied on file or path for authorized keys file: %s" % filename,
|
||||
exception=traceback.format_exc())
|
||||
module.fail_json(msg="Permission denied on file or path for authorized keys file: {}".format(filename))
|
||||
elif e.errno == errno.ENOENT:
|
||||
return ''
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
---
|
||||
# -------------------------------------------------------------
|
||||
# check permissions
|
||||
|
||||
- name: Create a file that is not accessible
|
||||
ansible.builtin.file:
|
||||
state: touch
|
||||
path: "{{ output_dir | expanduser }}/file_permissions"
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0000'
|
||||
|
||||
- name: Try to delete a key from an unreadable file
|
||||
ansible.posix.authorized_key:
|
||||
user: root
|
||||
key: "{{ dss_key_basic }}"
|
||||
state: absent
|
||||
path: "{{ output_dir | expanduser }}/file_permissions"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
|
||||
- name: Assert that the key deletion has failed
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.failed == True
|
||||
|
||||
- name: Remove the file
|
||||
ansible.builtin.file:
|
||||
state: absent
|
||||
path: "{{ output_dir | expanduser }}/file_permissions"
|
||||
|
|
@ -34,6 +34,3 @@
|
|||
|
||||
- name: Test for specifying key as a path
|
||||
ansible.builtin.import_tasks: check_path.yml
|
||||
|
||||
- name: Test for permission denied files
|
||||
ansible.builtin.import_tasks: check_permissions.yml
|
||||
|
|
|
|||
Loading…
Reference in a new issue