You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it works fine when running ansible-playbook playbook.yml
But, if it is run with check mode (ie, ansible-playbook --check playbook.yml) then a python exception is generated (see below for error)
Expected Results
Expected to show that a change would occur without the error/exception
Actual Results
TASK [Add ssh key to github] *******************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: module 'datetime' has no attribute 'strftime'
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/home/tom/.ansible/tmp/ansible-tmp-1732488395.5338001-12323-276562370367174/AnsiballZ_github_key.py\", line 107, in <module>\n _ansiballz_main()\n File \"/home/tom/.ansible/tmp/ansible-tmp-1732488395.5338001-12323-276562370367174/AnsiballZ_github_key.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/tom/.ansible/tmp/ansible-tmp-1732488395.5338001-12323-276562370367174/AnsiballZ_github_key.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.github_key', init_globals=dict(_module_fqn='ansible_collections.community.general.plugins.modules.github_key', _modlib_path=modlib_path),\n File \"<frozen runpy>\", line 226, in run_module\n File \"<frozen runpy>\", line 98, in _run_module_code\n File \"<frozen runpy>\", line 88, in _run_code\n File \"/tmp/ansible_community.general.github_key_payload_k4s7yu7c/ansible_community.general.github_key_payload.zip/ansible_collections/community/general/plugins/modules/github_key.py\", line 260, in <module>\n File \"/tmp/ansible_community.general.github_key_payload_k4s7yu7c/ansible_community.general.github_key_payload.zip/ansible_collections/community/general/plugins/modules/github_key.py\", line 251, in main\n File \"/tmp/ansible_community.general.github_key_payload_k4s7yu7c/ansible_community.general.github_key_payload.zip/ansible_collections/community/general/plugins/modules/github_key.py\", line 210, in ensure_key_present\n File \"/tmp/ansible_community.general.github_key_payload_k4s7yu7c/ansible_community.general.github_key_payload.zip/ansible_collections/community/general/plugins/modules/github_key.py\", line 165, in create_key\nAttributeError: module 'datetime' has no attribute 'strftime'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
Code of Conduct
I agree to follow the Ansible Code of Conduct
The text was updated successfully, but these errors were encountered:
felixfontein
added
backport-8
Automatically create a backport for the stable-8 branch
backport-9
Automatically create a backport for the stable-9 branch
backport-10
Automatically create a backport for the stable-10 branch
and removed
backport-8
Automatically create a backport for the stable-8 branch
backport-9
Automatically create a backport for the stable-9 branch
backport-10
Automatically create a backport for the stable-10 branch
labels
Nov 25, 2024
Summary
community.general.github_key fails when run in check mode (eg, when using
ansible-playbook --check ...
)When running without the check flag, the module works fine.
Reviewing the code, I believe this was introduced in PR #8222
Specifically, here:
community.general/plugins/modules/github_key.py
Line 165 in 3c23ce4
I don't have a python environment handy, but I am pretty sure this should be changed to:
Issue Type
Bug Report
Component Name
module is github_key.py
Ansible Version
Community.general Version
Configuration
n/a
OS / Environment
Ubuntu 24.04
Steps to Reproduce
Given a playbook with this task:
it works fine when running
ansible-playbook playbook.yml
But, if it is run with check mode (ie,
ansible-playbook --check playbook.yml
) then a python exception is generated (see below for error)Expected Results
Expected to show that a change would occur without the error/exception
Actual Results
Code of Conduct
The text was updated successfully, but these errors were encountered: