molecule error: computed fully qualified role name does not follow current galaxy requirements
Asked Answered
C

3

5

I'am totally new to ansible and ansible roles. I have created my first role and want to test it with molecule.

If I run molecule test I get an error saying: Computed fully qualified role name of generate_random_password does not follow current galaxy requirements. Please edit meta/main.yml and assure we can correctly determine full role name:

Full output:

INFO     default scenario test matrix: dependency, lint, cleanup, destroy, syntax, create, prepare, converge, idempotence, side_effect, verify, cleanup, destroy
INFO     Performing prerun...
INFO     Added ANSIBLE_LIBRARY=/home/tom/.cache/ansible-compat/62faec/modules:/home/tom/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Added ANSIBLE_COLLECTIONS_PATH=/home/tom/.cache/ansible-compat/62faec/collections:/home/tom/.ansible/collections:/usr/share/ansible/collections
INFO     Added ANSIBLE_ROLES_PATH=/home/tom/.cache/ansible-compat/62faec/roles:/home/tom/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
ERROR    Computed fully qualified role name of generate_random_password does not follow current galaxy requirements.
Please edit meta/main.yml and assure we can correctly determine full role name:

galaxy_info:
role_name: my_name  # if absent directory name hosting role is used instead
namespace: my_galaxy_namespace  # if absent, author is used instead

Namespace: https://galaxy.ansible.com/docs/contributing/namespaces.html#galaxy-namespace-limitations
Role: https://galaxy.ansible.com/docs/contributing/creating_role.html#role-names

As an alternative, you can add 'role-name' to either skip_list or warn_list.

Traceback (most recent call last):
  File "/home/tom/.local/bin/molecule", line 8, in <module>
    sys.exit(main())
  File "/home/tom/.local/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/tom/.local/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/tom/.local/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/tom/.local/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/tom/.local/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/tom/.local/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/tom/.local/lib/python3.9/site-packages/molecule/command/test.py", line 159, in test
    base.execute_cmdline_scenarios(scenario_name, args, command_args, ansible_args)
  File "/home/tom/.local/lib/python3.9/site-packages/molecule/command/base.py", line 111, in execute_cmdline_scenarios
    scenario.config.runtime.prepare_environment()
  File "/home/tom/.local/lib/python3.9/site-packages/ansible_compat/runtime.py", line 255, in prepare_environment
    self._install_galaxy_role(self.project_dir, ignore_errors=True)
  File "/home/tom/.local/lib/python3.9/site-packages/ansible_compat/runtime.py", line 396, in _install_galaxy_role
    raise InvalidPrerequisiteError(msg)
ansible_compat.errors.InvalidPrerequisiteError: Computed fully qualified role name of generate_random_password does not follow current galaxy requirements.
Please edit meta/main.yml and assure we can correctly determine full role name:

galaxy_info:
role_name: my_name  # if absent directory name hosting role is used instead
namespace: my_galaxy_namespace  # if absent, author is used instead

Namespace: https://galaxy.ansible.com/docs/contributing/namespaces.html#galaxy-namespace-limitations
Role: https://galaxy.ansible.com/docs/contributing/creating_role.html#role-names

As an alternative, you can add 'role-name' to either skip_list or warn_list.

If I'm correct the role name generate_random_password is a valid role name. What do I wrong?

Clairclairaudience answered 20/10, 2021 at 20:9 Comment(3)
Did you create the role with ansible-galaxy init generate_random_password?Muriel
Yes I did. Also tried it with molecule init role generate_random_passwordClairclairaudience
I was getting this error because my role was named test-role-1. I renamed my role to test_role_1 and I had to add the two lines (role_name: test_role_1 & galaxy_name: blahblahblah).Mohan
S
9

I ran into this problem myself and found I needed a namespace: entry in my meta/main.yml. Adding these lines did the trick for me.

galaxy_info:
  role_name: linux_administration
  namespace: glennbell
Stressful answered 1/11, 2021 at 20:20 Comment(0)
M
4

In case anyone is still looking for the answer to this, add the following property to the molecule.yml file

role_name_check: 1

This will skip the role name check for galaxy

Metencephalon answered 1/9, 2023 at 14:20 Comment(1)
As stated in the docs: ansible.readthedocs.io/projects/molecule/configuration/…Matchlock
A
0

Add the following properties to the meta/main.yml:

role_name: generate_random_password
galaxy_name: tbuyvoets

Apparently this isn't included by default in the meta/main.yml file when you run molecule init role <rolename>.

Amphibrach answered 23/10, 2021 at 19:25 Comment(1)
Tried this. Didn't work. Also creating an new empty role with molecule init role generate_random_password and adding these lines to meta/main.yaml didn't work.Clairclairaudience

© 2022 - 2024 — McMap. All rights reserved.