Ansible 2 upgrade broke roles directory lookup

75 views
Skip to first unread message

Alastair Brayne

unread,
Mar 28, 2016, 12:04:35 PM3/28/16
to Ansible Project
Hey,

I've just upgraded to Ansible 2 and my playbooks have stopped working. The specific error I get is:

ERROR! the role 'common' was not found in /<obfuscatedpathtomyproject>/roles/ec2/tasks/roles:/<obfuscatedpathtomyproject>/roles/ec2/tasks:/etc/ansible/roles



The error appears to have been in '/<obfuscatedpathtomyproject>/site.yml': line 5, column 7, but may
be elsewhere
in the file depending on the exact syntax problem.


The offending line appears to be:


  roles
:
   
- common
     
^ here




My `sites.yml` looks like:

- include: roles/ec2/tasks/load_ec2_group_foo.yml

- hosts: foo
  roles
:
   
- common
   
- java


My directory structure looks like this:
hosts
 
- app
 
- ec2.py
roles
 
- common
 
- java
site
.yml

No .ansible.cfg file.

Run command:
ansible-playbook -i hosts site.yml



It worked absolutely fine in 1.9. Just broke with the upgrade. I made no other changes.

What I notice and find interesting is that the search path for the roles uses <project>/roles/ec2/tasks/roles, <project>/roles/ec2/tasks, and /etc/ansible/roles. It looks almost like the include statement on line 1 in the site.yml file is setting this path lookup. What it is missing is of course an entry in this list for <project>/roles.

Anyone got any idea why this might be? Does the include now do an internal cd or something and then leave itself in the wrong directory? No idea about the bowels of ansible, I've never dug into it.

Any help much appreciated :)

Thanks
Alastair





t:  07779266625

Uditha Desilva

unread,
Mar 28, 2016, 2:20:43 PM3/28/16
to Ansible Project
It looks like you're implicitly that "included" playbook as your first task, and thus you're mixing up the use of role and include in a rather odd way. Is there any reason why you're invoking it directly?

Johannes Kastl

unread,
Mar 30, 2016, 8:42:55 AM3/30/16
to ansible...@googlegroups.com
Am 28.03.16 schrieb Alastair Brayne:

> My `sites.yml` looks like:
>
> - include: roles/ec2/tasks/load_ec2_group_foo.yml
>
> - hosts: foo
> roles:
> - common
> - java

Any reason why you are not using that like your other roles?

- hosts: foo
roles:
- common
- java
- ec2

Regards,
Johannes

signature.asc
Reply all
Reply to author
Forward
0 new messages