Problem with installing Ansible Foreman plugin

Problem:

Here we go. I followed the docs Foreman :: Plugin documentation index but the first command already stopped me continuing.

:~/repos$ ansible-galaxy collection install theforeman.foreman -vvv
ansible-galaxy [core 2.12.4]
  config file = None
  configured module search path = ['.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = .ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-galaxy
  python version = 3.10.7 (main, May 29 2023, 13:51:48) [GCC 12.2.0]
  jinja version = 3.0.3
  libyaml = True
No config file found; using defaults
Starting galaxy collection install process
Process install dependency map
ERROR! Unexpected Exception, this is probably a bug: CollectionDependencyProvider.find_matches() got an unexpected keyword argument 'identifier'
the full traceback was:

Traceback (most recent call last):
  File "/usr/bin/ansible-galaxy", line 128, in <module>
    exit_code = cli.run()
  File "/usr/lib/python3/dist-packages/ansible/cli/galaxy.py", line 569, in run
    return context.CLIARGS['func']()
  File "/usr/lib/python3/dist-packages/ansible/cli/galaxy.py", line 86, in method_wrapper
    return wrapped_method(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/ansible/cli/galaxy.py", line 1203, in execute_install
    self._execute_install_collection(
  File "/usr/lib/python3/dist-packages/ansible/cli/galaxy.py", line 1230, in _execute_install_collection
    install_collections(
  File "/usr/lib/python3/dist-packages/ansible/galaxy/collection/__init__.py", line 548, in install_collections
    dependency_map = _resolve_depenency_map(
  File "/usr/lib/python3/dist-packages/ansible/galaxy/collection/__init__.py", line 1364, in _resolve_depenency_map
    return collection_dep_resolver.resolve(
  File "/usr/lib/python3/dist-packages/resolvelib/resolvers.py", line 481, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/usr/lib/python3/dist-packages/resolvelib/resolvers.py", line 348, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
  File "/usr/lib/python3/dist-packages/resolvelib/resolvers.py", line 147, in _add_to_criteria
    matches = self._p.find_matches(
TypeError: CollectionDependencyProvider.find_matches() got an unexpected keyword argument 'identifier'
:~/repos$ ansible-galaxy collection install git+https://github.com/theforeman/foreman-ansible-modules.git
Cloning into '.ansible/tmp/ansible-local-32301lms0unno/tmp7f7qy27k/foreman-ansible-modulescvsfyj8d'...
remote: Enumerating objects: 1470, done.
remote: Counting objects: 100% (1470/1470), done.
remote: Compressing objects: 100% (725/725), done.
remote: Total 1470 (delta 1070), reused 888 (delta 703), pack-reused 0
Receiving objects: 100% (1470/1470), 2.55 MiB | 7.76 MiB/s, done.
Resolving deltas: 100% (1070/1070), done.
Your branch is up to date with 'origin/develop'.
Starting galaxy collection install process
Process install dependency map
ERROR! Unexpected Exception, this is probably a bug: CollectionDependencyProvider.find_matches() got an unexpected keyword argument 'identifier'

Expected outcome:

Installing without error messages :grin:

Foreman and Proxy versions:
does not matter here
Foreman and Proxy plugin versions:
does not matter here
Distribution and version:
Ubuntu 22.10

Looks like the provided version 2.12 in Ubuntu 22.10 is not sufficient.
I am using now the Ansible repos in apt and now it works.

:~/repos$ ansible --version
ansible [core 2.14.6]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = .ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.7 (main, May 29 2023, 13:51:48) [GCC 12.2.0] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True

Hey Marcel,

I tried to figure that out, out of curiosity now, tried multiple platforms,
Fedora 36, which also had Python 3.10.11, Ansible 2.12.10 doesn’t have any problems, Fedora 38, and also Ubuntu 23.04 don’t have any problems, but the only one I couldn’t get it working was with Ubuntu 22.10 (Python 3.10.7, Ansible 2.12.4), there it shows this exact error, might be a building thing from their side? :thinking:

Thanks for verification! In the end I don’t waste more time into this. The newer versions work.
Now the hard job starts. Figuring out how to use the Ansible Foreman module. The docs should have more examples :grin:

1 Like

Haha great,
fun times ahead :grin:
Tbh also projected a whole environment to a few playbooks recently, and it might look hard at first but it was actually pretty easy after working off one thing after the other, just by looking at the parameters list :slight_smile:
If you see any improvement, guess you just need to mention it and it will get improved :+1:

For now I would just like to have a good starting point. But I will create a new question here. If it is written down, others might benefit from it.

1 Like

FWIW, our repos carry a ansible-collection-theforeman-foreman package (both RPM and DEB), so you don’t have to fiddle around with Galaxy at all :slight_smile:

Thanks @evgeni !

I never considered to install the packages on my computer TBH :joy: