mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 19:31:26 -07:00
[PR #8497/f0940d82 backport][stable-9] homectl, udm_user: guard crypt imports (#8499)
homectl, udm_user: guard crypt imports (#8497)
Guard crypt import.
(cherry picked from commit f0940d82dc
)
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
f905a1bc94
commit
f84ebed63f
3 changed files with 50 additions and 4 deletions
|
@ -17,6 +17,12 @@ short_description: Manage user accounts with systemd-homed
|
|||
version_added: 4.4.0
|
||||
description:
|
||||
- Manages a user's home directory managed by systemd-homed.
|
||||
notes:
|
||||
- This module does B(not) work with Python 3.13 or newer. It uses the deprecated L(crypt Python module,
|
||||
https://docs.python.org/3.12/library/crypt.html) from the Python standard library, which was removed
|
||||
from Python 3.13.
|
||||
requirements:
|
||||
- Python 3.12 or earlier
|
||||
extends_documentation_fragment:
|
||||
- community.general.attributes
|
||||
attributes:
|
||||
|
@ -263,12 +269,21 @@ data:
|
|||
}
|
||||
'''
|
||||
|
||||
import crypt
|
||||
import json
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
import traceback
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils.basic import jsonify
|
||||
from ansible.module_utils.common.text.formatters import human_to_bytes
|
||||
|
||||
try:
|
||||
import crypt
|
||||
except ImportError:
|
||||
HAS_CRYPT = False
|
||||
CRYPT_IMPORT_ERROR = traceback.format_exc()
|
||||
else:
|
||||
HAS_CRYPT = True
|
||||
CRYPT_IMPORT_ERROR = None
|
||||
|
||||
|
||||
class Homectl(object):
|
||||
'''#TODO DOC STRINGS'''
|
||||
|
@ -591,6 +606,12 @@ def main():
|
|||
]
|
||||
)
|
||||
|
||||
if not HAS_CRYPT:
|
||||
module.fail_json(
|
||||
msg=missing_required_lib('crypt (part of Python 3.13 standard library)'),
|
||||
exception=CRYPT_IMPORT_ERROR,
|
||||
)
|
||||
|
||||
homectl = Homectl(module)
|
||||
homectl.result['state'] = homectl.state
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue