Open MaKaNu opened 1 month ago
Are you sure that Ansible itself is able to find the role? Try something similar to:
ssbarnea@m1: ~/c/a/ansible-lint/examples fix/working_directory
$ ansible -m import_role -a name=role_detection localhost
[WARNING]: No inventory was parsed, only implicit localhost is available
ssbarnea@m1: ~/c/a/ansible-lint/examples fix/working_directory
$ ansible -m import_role -a name=role_detection222 localhost
[WARNING]: No inventory was parsed, only implicit localhost is available
ERROR! the role 'role_detection222' was not found in ./roles:/Users/ssbarnea/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:.
FAIL: 1
If Ansible itself is not finding the role, is not a valid bug.
The result of ansible -m import_role -a name=base localhost
from the root of my role repo is the following:
localhost | FAILED! => {
"changed": false,
"msg": "Failed to lookup user ansible: \"getpwnam(): name not found: 'ansible'\""
}
This seems fine, since the first task of the role adds ssh pub keys to the user "ansible", which is not available on my local machine.
So I run the command again and override the base_ssh_user
variable:
ansible -m import_role -a name=base localhost -e base_ssh_user=$USER
, which worked and now my local admins have access to my local machine ;)
Prerequisites
pip check
does not report any conflictsEnvironment
What happened
I have role which support (or should support) different distributions.
The role is created with the command
ansible-galaxy init base
let's assume the role only has the following task in
tasks/main.yml
There are a few more tasks, but this task will fail on different distributions.
Further, I've added the molecule scenario with
molecule init scenario
while I was in the role directory.The final structure on the role looks like the following:
When running the command
molecule test
It seems the role is getting included, but it never runs and so it does also not fail on the rockylinux8 docker.Using instead:
it will never be called.
Reproducing example
molecule.yml:
converge.yml: