Anyone ?

Le mercredi 6 mars 2019 12:15:11 UTC+1, Lionel H a écrit :
>
> Hi all,
>
> I have a bunch of nested roles for a specific project.
>
> I'm trying to dynamically invoked roles based on variable I have in the 
> inventory.
> For example, let's say I have a foo variable that is defined for every 
> hosts, the following will fail:
>
> #roles/A/meta.yml
> dependencies:
> - { role: "B/{{foo}}" }
>
> I would expect that it would load the roles in roles/B/<what foo point 
> here>, but rather I have the following error:
> ERROR! 'foo' is undefined.
>
> Strange things, If I invoke foo as a play variable like this:
>
> - hosts: srv
> gather_facts: True
> vars:
> foo: "bar"
> roles:
> - { role: A }
>
> It correctly loads and execute roles/B/bar...
>
> So it seems to not expand inventory variable when passing them to "role" 
> directive.. Is this an expected behavior ? Is there any workaround ? This 
> is kind of annoying because I wanted to dynamically load roles based on 
> inventory variables rather than relying on conditional include using plenty 
> of "when:" statement in the meta directive...
>
> Best regards,
>
> Lionel. 
>

-- 
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/9905ebbc-4874-4b4f-bee7-315d42d8e5c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to