diff --git a/plugins/modules/gpg_keypair.py b/plugins/modules/gpg_keypair.py index e656bea0..7318d1c1 100644 --- a/plugins/modules/gpg_keypair.py +++ b/plugins/modules/gpg_keypair.py @@ -18,6 +18,7 @@ description: - "This module allows one to generate or delete GPG private and public keys using GnuPG (gpg)." requirements: - gpg >= 2.1 + - python-dateutil extends_documentation_fragment: - community.crypto.attributes attributes: @@ -367,7 +368,7 @@ def generate_keypair(module, params, matching_keys, check_mode): def run_module(module, params, check_mode=False): if params['expire_date']: try: - dp.parse(params['expire_date']) + dp.isoparse(params['expire_date']) except ValueError: if not (params['expire_date'].isnumeric() or (params['expire_date'][:-1].isnumeric() and params['expire_date'][-1] in ['w', 'm', 'y'])): module.fail_json('Invalid format for expire date') diff --git a/tests/integration/targets/gpg_keypair/meta/main.yaml b/tests/integration/targets/gpg_keypair/meta/main.yaml index 5d6aaab6..26948f2d 100644 --- a/tests/integration/targets/gpg_keypair/meta/main.yaml +++ b/tests/integration/targets/gpg_keypair/meta/main.yaml @@ -5,3 +5,4 @@ dependencies: - setup_gnupg + - setup_python_dateutil diff --git a/tests/integration/targets/setup_python_dateutil/meta/main.yaml b/tests/integration/targets/setup_python_dateutil/meta/main.yaml new file mode 100644 index 00000000..5e0e7d8f --- /dev/null +++ b/tests/integration/targets/setup_python_dateutil/meta/main.yaml @@ -0,0 +1,9 @@ +--- +# Copyright (c) 2024, Austin Lucas Lake <53884490+austinlucaslake@users.noreply.github.com> +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +dependencies: + - setup_python_info + - setup_remote_constraints + - setup_pkg_mgr diff --git a/tests/integration/targets/setup_python_dateutil/tasks/main.yaml b/tests/integration/targets/setup_python_dateutil/tasks/main.yaml new file mode 100644 index 00000000..5ffd5434 --- /dev/null +++ b/tests/integration/targets/setup_python_dateutil/tasks/main.yaml @@ -0,0 +1,16 @@ +--- +# Copyright (c) 2024, Austin Lucas Lake <53884490+austinlucaslake@users.noreply.github.com> +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +#################################################################### +# WARNING: These are designed specifically for Ansible tests # +# and should not be used as examples of how to write Ansible roles # +#################################################################### + +- name: Install python-dateutil (PyPi) + become: true + ansible.builtin.pip: + name: python-dateutil + state: 'latest' + extra_args: "-c {{ remote_constraints }}"