systemli / ansible-role-needrestart

Install and maintain needrestart on debian-like systems
GNU General Public License v3.0
10 stars 11 forks source link

Unexpected Exception, this is probably a bug: join() missing 1 required positional argument: 'a' #53

Closed JKetelaar closed 9 months ago

JKetelaar commented 11 months ago

Whenever I add systemli.needrestart to requirements.yml, I get the following exception:

Starting galaxy role install process
- downloading role 'needrestart', owned by systemli
- downloading role from https://github.com/systemli/ansible-role-needrestart/archive/3.1.0.tar.gz
- extracting systemli.needrestart to /Users/jeroen/.ansible/roles/systemli.needrestart
[WARNING]: Illegal filename '..': '..' is not allowed
ERROR! Unexpected Exception, this is probably a bug: join() missing 1 required positional argument: 'a'
to see the full traceback, use -vvv

With -vvv it shows:

- downloading role 'needrestart', owned by systemli
- downloading role from https://github.com/systemli/ansible-role-needrestart/archive/3.1.0.tar.gz
- extracting systemli.needrestart to /Users/jeroen/.ansible/roles/systemli.needrestart
[WARNING]: - systemli.needrestart was NOT installed successfully: the specified role systemli.needrestart appears to already exist. Use --force to replace it.
ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.
0x46616c6b commented 11 months ago

Did you try to install the role with the --force flag? It seems you have already installed a previous version.

bajo commented 10 months ago

I believe I have the same problem on Mac OS 14.2.1 running on Apple Silicon.

ansible-galaxy install -r requirements.yml -vvv

[WARNING]: Illegal filename '..': '..' is not allowed
ERROR! Unexpected Exception, this is probably a bug: join() missing 1 required positional argument: 'a'
ansible-galaxy [core 2.15.8]
  config file = /root/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /root/ansible/collections
  executable location = /usr/bin/ansible-galaxy
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True
Using /root/ansible/ansible.cfg as config file
Reading requirement file at '/root/ansible/requirements.yml'
found role {'src': 'systemli.needrestart', 'version': '3.1.0', 'name': 'systemli.needrestart', 'scm': None} in yaml file
Starting galaxy role install process
Processing role systemli.needrestart
Created /root/.ansible/galaxy_token
- downloading role 'needrestart', owned by systemli
- downloading role from https://github.com/systemli/ansible-role-needrestart/archive/3.1.0.tar.gz
- extracting systemli.needrestart to /root/ansible/roles/systemli.needrestart
the full traceback was:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/ansible/cli/__init__.py", line 659, in cli_executor
    exit_code = cli.run()
  File "/usr/lib/python3/dist-packages/ansible/cli/galaxy.py", line 719, in run
    return context.CLIARGS['func']()
  File "/usr/lib/python3/dist-packages/ansible/cli/galaxy.py", line 119, in method_wrapper
    return wrapped_method(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/ansible/cli/galaxy.py", line 1373, in execute_install
    self._execute_install_role(role_requirements)
  File "/usr/lib/python3/dist-packages/ansible/cli/galaxy.py", line 1472, in _execute_install_role
    installed = role.install()
  File "/usr/lib/python3/dist-packages/ansible/galaxy/role.py", line 426, in install
    setattr(member, attr, os.path.join(*n_final_parts))
TypeError: join() missing 1 required positional argument: 'a'

I had this problem on multiple different python versions and ansible versions. I removed the role before attempting this again, so this should show the outcome when running on an empty ansible/roles folder.

Even though the galaxy install command fails, I have the following content now.

find roles/systemli.needrestart
roles/systemli.needrestart
roles/systemli.needrestart/.yamllint
roles/systemli.needrestart/meta
roles/systemli.needrestart/meta/main.yml
roles/systemli.needrestart/LICENSE
roles/systemli.needrestart/.editorconfig
roles/systemli.needrestart/defaults
roles/systemli.needrestart/defaults/main.yml
roles/systemli.needrestart/.ansible-lint
roles/systemli.needrestart/.gitignore
roles/systemli.needrestart/README.md
roles/systemli.needrestart/.github
roles/systemli.needrestart/.github/workflows
roles/systemli.needrestart/.github/workflows/auto-merge.yml
roles/systemli.needrestart/.github/workflows/release-drafter.yml
roles/systemli.needrestart/.github/workflows/main.yml
roles/systemli.needrestart/.github/workflows/galaxy.yml
roles/systemli.needrestart/.github/auto-merge.yml
roles/systemli.needrestart/.github/release-drafter.yml
roles/systemli.needrestart/.github/dependabot.yml
roles/systemli.needrestart/files
roles/systemli.needrestart/files/needrestart.conf
roles/systemli.needrestart/files/check_needrestart
roles/systemli.needrestart/molecule
roles/systemli.needrestart/molecule/default
roles/systemli.needrestart/molecule/default/molecule.yml
roles/systemli.needrestart/molecule/default/converge.yml

Not sure if the role is working or not as of now. However, every attempt to install this or different roles/collections results in errors for just this one role.

0x46616c6b commented 10 months ago

Can you share your requirements.yml and ansible.cfg (if you have one)? I would like to reproduce it

t2d commented 10 months ago

I'm pretty sure it's this ansible error https://github.com/ansible/ansible/issues/81965 Please try a functioning version. We pin 2.15.4 for example https://github.com/systemli/github-ansible-workflow/blob/main/.github/workflows/ansible-integration-workflow.yaml#L19 But there are newer fixed versions.

bajo commented 10 months ago

@0x46616c6b

I can replicate this issue with a minimal config of ansible.cfg

[defaults]
deprecation_warnings = False
roles_path = roles
collections_paths = collections
display_skipped_hosts = no
ask_vault_pass = true
interpreter_python = /usr/bin/python3
stdout_callback = debug
host_key_checking = False

and requirements.yml

roles:
  - src: systemli.needrestart
    version: 3.1.0

Output is

ansible-galaxy install -r requirements.yml
Starting galaxy role install process
- downloading role 'needrestart', owned by systemli
- downloading role from https://github.com/systemli/ansible-role-needrestart/archive/3.1.0.tar.gz
- extracting systemli.needrestart to /Volumes/easyname/temp/ansible/roles/systemli.needrestart
[WARNING]: Illegal filename '..': '..' is not allowed
ERROR! Unexpected Exception, this is probably a bug: join() missing 1 required positional argument: 'a'
to see the full traceback, use -vvv

The following files were installed however

❯ find roles
roles
roles/systemli.needrestart
roles/systemli.needrestart/.yamllint
roles/systemli.needrestart/meta
roles/systemli.needrestart/meta/main.yml
roles/systemli.needrestart/LICENSE
roles/systemli.needrestart/.editorconfig
roles/systemli.needrestart/defaults
roles/systemli.needrestart/defaults/main.yml
roles/systemli.needrestart/.ansible-lint
roles/systemli.needrestart/.gitignore
roles/systemli.needrestart/README.md
roles/systemli.needrestart/.github
roles/systemli.needrestart/.github/workflows
roles/systemli.needrestart/.github/workflows/auto-merge.yml
roles/systemli.needrestart/.github/workflows/release-drafter.yml
roles/systemli.needrestart/.github/workflows/main.yml
roles/systemli.needrestart/.github/workflows/galaxy.yml
roles/systemli.needrestart/.github/auto-merge.yml
roles/systemli.needrestart/.github/release-drafter.yml
roles/systemli.needrestart/.github/dependabot.yml
roles/systemli.needrestart/files
roles/systemli.needrestart/files/needrestart.conf
roles/systemli.needrestart/files/check_needrestart
roles/systemli.needrestart/molecule
roles/systemli.needrestart/molecule/default
roles/systemli.needrestart/molecule/default/molecule.yml
roles/systemli.needrestart/molecule/default/converge.yml

I'll try to pin the version to 2.15.4 next to see if the problem is only happening on newer versions despite the claim that it was fixed in newer releases according to the link @t2d provided.

bajo commented 9 months ago

I can confirm that pinning the version of ansible-core to 2.15.4 the issue no longer shows up. I would still hope that a more recent version of ansible-core will eventually fix this again. As I tried with at least 2.15.7 ans 2.15.8 and they still show these issue. Anyway, for me the workaround is ok for now. Thank you for your help.

bajo commented 9 months ago

Just a quick update. Due to reasons unrelated to this issue, we had to upgrade to a more recent version of ansible-core. The version which includes the fix is 2.15.9 as available from ppa:ansible/testing-ansible-8

doobry-systemli commented 9 months ago

Great to hear that the issue got resolved for you!