Guys,
I’m trying to create a top-level playbook, based on “include_role:”, instead of “roles:”, however, the “when:” condition isn’t working properly, I think.
Easy to reproduce (the content of “roles/hello-world-X/tasks/main.yml” is in the end):
This works (“include_role:” without the “when:” condition):
$ ansible --version
ansible 2.2.0.0
$ source ~/my-openstack-project-openrc.sh
$ ansible-playbook -i openstack.py hello.yml
I am also seeing when: not work with include_role. The “a” reported above is just the first letter of Thiago’s condition (ansible_hostname | search(“stack-1-sql.*”). I’ve got a boolean, etcd_enabled, so my when: etcd_enabled produces “The conditional check ‘e’ failed”
Is there something new on this topic?
I’m using some Galaxy roles and i would like to avoid any modification. Some of these roles do much more than i need and i would like to do something like:
- name: selective tasks from galaxy role
include_role:
name: someones.role
tasks_from: “{{ item }}”
static: no
with_items:
- prereq.yml
- installa.yml
- starta.yml
- testa.yml
Where the role has also install[b-d].yml included from the main.yml
Here i get the already known
ERROR! Could not find specified file in role: {{ item }}
Regards,
Mario
BTW: $ ansible --version
ansible 2.2.0.0
I’m getting the exact same issue. When using “when” with “include_role”, I get:
The conditional check ‘g’ failed. The error was: error while evaluating conditional (g): ‘g’ is undefined