PyratLabs / ansible-role-k3s

Ansible role for installing k3s as either a standalone server or HA cluster.
BSD 3-Clause "New" or "Revised" License
627 stars 135 forks source link

Unable to install role: 'datetime.datetime' object has no attribute 'times'. #225

Open InRiPa opened 2 months ago

InRiPa commented 2 months ago

Summary

ansible-galaxy install -vvv -f -r requirements.yaml results in

ERROR! Unexpected Exception, this is probably a bug: 'datetime.datetime' object has no attribute 'times' and AttributeError: 'datetime.datetime' object has no attribute 'times'. Did you mean: 'time'?

I upgraded my Dockerfile in order to fix another issue. With that, I run into this issue now. Can anyone reproduce that?

As basic Dockerfile, I'm using

FROM python:3.12-alpine
<... Stuff ...>
RUN apk update && \
    apk upgrade && \
    apk add krb5 && \
    apk add vim && \
    apk add tree && \
    apk add ansible && \
    apk add openssh && \
    apk add doas
<... Stuff ...>

Issue Type

Controller Environment and Configuration

Steps to Reproduce

Having the following yaml file

---
roles:
  - name: xanmanning.k3s
    type: galaxy
collections:
  - name: ansible.posix
    type: galaxy

and running

ansible-galaxy install -f -r requirements.yaml

Expected Result

Install should succeed.

Actual Result

ansible-galaxy install -vvv -f -r requirements.yaml
ansible-galaxy [core 2.17.0]
  config file = None
  configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.12/site-packages/ansible
  ansible collection location = /home/runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-galaxy
  python version = 3.12.4 (main, Jul  3 2024, 00:17:46) [GCC 13.2.1 20240309] (/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True
No config file found; using defaults
Reading requirement file at '/project/yaml-install/requirements.yaml'
found role {'name': 'xanmanning.k3s', 'version': '', 'scm': None} in yaml file
Starting galaxy role install process
Processing role xanmanning.k3s 
Opened /home/runner/.ansible/galaxy_token
- downloading role 'k3s', owned by xanmanning
- downloading role from https://github.com/PyratLabs/ansible-role-k3s/archive/v3.4.4.tar.gz
- extracting xanmanning.k3s to /home/runner/.ansible/roles/xanmanning.k3s
ERROR! Unexpected Exception, this is probably a bug: 'datetime.datetime' object has no attribute 'times'
the full traceback was:

Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/ansible/cli/__init__.py", line 658, in cli_executor
    exit_code = cli.run()
                ^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/ansible/cli/galaxy.py", line 750, in run
    return context.CLIARGS['func']()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/ansible/cli/galaxy.py", line 120, in method_wrapper
    return wrapped_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/ansible/cli/galaxy.py", line 1409, in execute_install
    self._execute_install_role(role_requirements)
  File "/usr/lib/python3.12/site-packages/ansible/cli/galaxy.py", line 1508, in _execute_install_role
    installed = role.install()
                ^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/ansible/galaxy/role.py", line 431, in install
    self._write_galaxy_install_info()
  File "/usr/lib/python3.12/site-packages/ansible/galaxy/role.py", line 214, in _write_galaxy_install_info
    install_date=datetime.datetime.now(datetime.timezone.utc).strftime("%c"),
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Workaround

Using python:3.13-rc-alpine as base, fixed it for me. Maybe helpful for someone who experiences similar issues.