Hope it is clear.

The directory structure looks like this


playbook.yml
vars/main.yml
roles/my-roles/handlers/main.yml
roles/my-roles/handlers/ocata.yml
roles/my-roles/handlers/kilo.yml



The* roles/my-roles/handlers/main.yml* looks like this

---
- include: "{{ codename }}".yml


The variable *codename* is defined in * vars/main.yml* 


codename: ocata



On Thursday, July 6, 2017 at 11:00:19 AM UTC+8, Mauricio Tavares wrote:
>
> On Fri, Jun 23, 2017 at 3:13 AM, Jeff Li <[email protected] <javascript:>> 
> wrote: 
> > 
> > I solved the problem by  using vars_files directive in playbook. The 
>  directory structure looks like 
> > 
> > playbook.yml 
> > vars/main.yml 
> > roles/my-roles/... 
> > 
> > The playbook.yml  looks like 
> > 
> > --- 
> >   hosts: all 
> >   vars_files: 
> >     - vars/main.yml 
> >   tasks: 
> >     .... 
> >   roles: 
> > 
>       I hate to say but I still do not know how are you selecting 
> which handlers to use. 
> > 
> > On Thursday, June 8, 2017 at 6:20:54 PM UTC+8, Mauricio Tavares wrote: 
> >> 
> >> So I am running ansible 2.3.0.0. What I want to do is to have my 
> >> handlers/main.yml file to include another file (where some handlers 
> >> are defined) whose name depends on a variable defined somewhere else. 
> >> i.e. 
> >> 
> >> - include: stuff"{{ myvariable }}".yml 
> >> 
> >> where myvariable is defined in the file group_vars/all. I also have 
> >> 
> >> [defaults] 
> >> handler_includes_static = True 
> >> 
> >> defined in my ansible.cfg file per 
> >> https://github.com/ansible/ansible/issues/13485. But when I run it I 
> >> get the following message: 
> >> 
> >> ERROR! Error when evaluating variable in include name: stuff"{{ 
> >> myvariable }}".yml. 
> >> 
> >> When using static includes, ensure that any variables used in their 
> >> names are defined in 
> >> vars/vars_files or extra-vars passed in from the command line. Static 
> >> includes cannot use 
> >> variables from inventory sources like group or host vars. 
> >> 
> >> Where does it want me to define myvariable then? Somewhere in, say, 
> >> roles/role_in_question/vars/main.yml? 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Ansible Project" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to [email protected] <javascript:>. 
> > To post to this group, send email to [email protected] 
> <javascript:>. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/b268dafb-3a55-4a24-865e-bf9ccd482d2d%40googlegroups.com.
>  
>
> > 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/580fbe81-65c7-432c-86b8-a7ffb532c193%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to