udm_user, homectl: use legacycrypt on Python 3.13+ (#8987)
Use legacycrypt on Python 3.13+.pull/9012/head
parent
8610223d03
commit
29a2df8e6b
|
@ -0,0 +1,3 @@
|
||||||
|
bugfixes:
|
||||||
|
- "homectl - the module now tries to use ``legacycrypt`` on Python 3.13+ (https://github.com/ansible-collections/community.general/issues/4691, https://github.com/ansible-collections/community.general/pull/8987)."
|
||||||
|
- "udm_user - the module now tries to use ``legacycrypt`` on Python 3.13+ (https://github.com/ansible-collections/community.general/issues/4690, https://github.com/ansible-collections/community.general/pull/8987)."
|
|
@ -18,11 +18,11 @@ version_added: 4.4.0
|
||||||
description:
|
description:
|
||||||
- Manages a user's home directory managed by systemd-homed.
|
- Manages a user's home directory managed by systemd-homed.
|
||||||
notes:
|
notes:
|
||||||
- This module does B(not) work with Python 3.13 or newer. It uses the deprecated L(crypt Python module,
|
- This module requires the deprecated L(crypt Python module,
|
||||||
https://docs.python.org/3.12/library/crypt.html) from the Python standard library, which was removed
|
https://docs.python.org/3.12/library/crypt.html) library which was removed from Python 3.13.
|
||||||
from Python 3.13.
|
For Python 3.13 or newer, you need to install L(legacycrypt, https://pypi.org/project/legacycrypt/).
|
||||||
requirements:
|
requirements:
|
||||||
- Python 3.12 or earlier
|
- legacycrypt (on Python 3.13 or newer)
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- community.general.attributes
|
- community.general.attributes
|
||||||
attributes:
|
attributes:
|
||||||
|
@ -284,6 +284,17 @@ else:
|
||||||
HAS_CRYPT = True
|
HAS_CRYPT = True
|
||||||
CRYPT_IMPORT_ERROR = None
|
CRYPT_IMPORT_ERROR = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
import legacycrypt
|
||||||
|
if not HAS_CRYPT:
|
||||||
|
crypt = legacycrypt
|
||||||
|
except ImportError:
|
||||||
|
HAS_LEGACYCRYPT = False
|
||||||
|
LEGACYCRYPT_IMPORT_ERROR = traceback.format_exc()
|
||||||
|
else:
|
||||||
|
HAS_LEGACYCRYPT = True
|
||||||
|
LEGACYCRYPT_IMPORT_ERROR = None
|
||||||
|
|
||||||
|
|
||||||
class Homectl(object):
|
class Homectl(object):
|
||||||
'''#TODO DOC STRINGS'''
|
'''#TODO DOC STRINGS'''
|
||||||
|
@ -606,9 +617,9 @@ def main():
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
if not HAS_CRYPT:
|
if not HAS_CRYPT and not HAS_LEGACYCRYPT:
|
||||||
module.fail_json(
|
module.fail_json(
|
||||||
msg=missing_required_lib('crypt (part of Python 3.13 standard library)'),
|
msg=missing_required_lib('crypt (part of standard library up to Python 3.12) or legacycrypt (PyPI)'),
|
||||||
exception=CRYPT_IMPORT_ERROR,
|
exception=CRYPT_IMPORT_ERROR,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,11 @@ description:
|
||||||
server (UCS).
|
server (UCS).
|
||||||
It uses the python API of the UCS to create a new object or edit it."
|
It uses the python API of the UCS to create a new object or edit it."
|
||||||
notes:
|
notes:
|
||||||
- This module does B(not) work with Python 3.13 or newer. It uses the deprecated L(crypt Python module,
|
- This module requires the deprecated L(crypt Python module,
|
||||||
https://docs.python.org/3.12/library/crypt.html) from the Python standard library, which was removed
|
https://docs.python.org/3.12/library/crypt.html) library which was removed from Python 3.13.
|
||||||
from Python 3.13.
|
For Python 3.13 or newer, you need to install L(legacycrypt, https://pypi.org/project/legacycrypt/).
|
||||||
requirements:
|
requirements:
|
||||||
- Python 3.12 or earlier
|
- legacycrypt (on Python 3.13 or newer)
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- community.general.attributes
|
- community.general.attributes
|
||||||
attributes:
|
attributes:
|
||||||
|
@ -350,6 +350,17 @@ else:
|
||||||
HAS_CRYPT = True
|
HAS_CRYPT = True
|
||||||
CRYPT_IMPORT_ERROR = None
|
CRYPT_IMPORT_ERROR = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
import legacycrypt
|
||||||
|
if not HAS_CRYPT:
|
||||||
|
crypt = legacycrypt
|
||||||
|
except ImportError:
|
||||||
|
HAS_LEGACYCRYPT = False
|
||||||
|
LEGACYCRYPT_IMPORT_ERROR = traceback.format_exc()
|
||||||
|
else:
|
||||||
|
HAS_LEGACYCRYPT = True
|
||||||
|
LEGACYCRYPT_IMPORT_ERROR = None
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
expiry = date.strftime(date.today() + timedelta(days=365), "%Y-%m-%d")
|
expiry = date.strftime(date.today() + timedelta(days=365), "%Y-%m-%d")
|
||||||
|
@ -467,10 +478,10 @@ def main():
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|
||||||
if not HAS_CRYPT:
|
if not HAS_CRYPT and not HAS_LEGACYCRYPT:
|
||||||
module.fail_json(
|
module.fail_json(
|
||||||
msg=missing_required_lib('crypt (part of Python 3.13 standard library)'),
|
msg=missing_required_lib('crypt (part of standard library up to Python 3.12) or legacycrypt (PyPI)'),
|
||||||
exception=CRYPT_IMPORT_ERROR,
|
exception=LEGACYCRYPT_IMPORT_ERROR,
|
||||||
)
|
)
|
||||||
|
|
||||||
username = module.params['username']
|
username = module.params['username']
|
||||||
|
|
|
@ -15,6 +15,11 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
|
- name: Install legacycrypt on Python 3.13+
|
||||||
|
pip:
|
||||||
|
name: legacycrypt
|
||||||
|
when: ansible_python_version is version("3.13", ">=")
|
||||||
|
|
||||||
- name: Check and start systemd-homed service
|
- name: Check and start systemd-homed service
|
||||||
service:
|
service:
|
||||||
name: systemd-homed.service
|
name: systemd-homed.service
|
||||||
|
|
Loading…
Reference in New Issue