问题
I've got this bit in my playbook.
roles:
- {role: cleanup-create, dir: '/standard/', commit: "{{choice}}"}
The file structure is /roles/standard/cleanup-create/tasks/main.yml
And yet I receive this error:
ERROR! the role 'cleanup-create' was not found in /home/myuser/network-ansible-myuser/roles:/home/myuser/network-ansible-myuser:/etc/ansible/roles
The error appears to have been in '/home/myuser/network-ansible-myuser/configure-files.yml': line 15, column 5, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
roles:
- {role: cleanup-create, dir: '/standard', commit: "{{choice}}"}
^ here
Now, the error message seems to be saying my role wasn't found in /roles. However the dir parameter should make it look under /roles/standard.
It was working 5 minutes ago, I swear!
回答1:
There is no dir
special parameter for roles.
It is just an ordinary variable, same as commit
in your example.
You should place all your roles directly in ./roles
folder without any nesting.
回答2:
You can actually set roles_path
configuration variable in ansible.cfg
(or maybe pass it in the command line - try it, I'm not sure if you can do this with roles_path
).
From the doc:
The roles path indicate additional directories beyond the
roles/
subdirectory of a playbook project to search to find Ansible roles
./roles from playbook directory will be searched first, then additional paths will be checked.
You can specify multiple directories to look for roles in
roles_path=/var/opt/my_roles:/var/opt/more_roles
来源:https://stackoverflow.com/questions/40851527/the-dir-parameter-for-calling-roles