Have you thought of using tags to choose an operating system? Tag the roles 
with something like rhel and then execute a playbook using --tags=rhel  

You can use tags on includes as well which comes in handy.

I've used tags to skip items that I didn't want to run as well with 
--skip-tags=tagname


On Thursday, July 14, 2016 at 12:51:01 PM UTC-4, Patrick Fink wrote:
>
> Hi all,
>
> I have a question regarding role default variables. First, this is my use 
> case: I want to develop reusable, redistributable and configurable roles 
> supporting different operating systems. Some variables differ on the 
> different operating systems. In addition to the defaults/main.yml file that 
> is always automatically loaded, I would like to have a variable file for 
> each operating system, something like rhel.yml, debian.yml etc. As the 
> roles should be redistributable, it should be easy to override these 
> variables, e.g. in the inventory or the playbook.
>
> I really like the approach mentioned in the Ansible Best Practices here: 
> http://docs.ansible.com/ansible/playbooks_best_practices.html#operating-system-and-distribution-variance,
>  
> but it's not on role level. If I would use include_vars, it would be very 
> hard to overwrite those role default variables. So the question is
>
> Is there any built-in mechanism to load more files than the main.yml from 
> a role defaults/ folder which keeps the variable precedence? And if yes, is 
> it possible to load them dynamically based on the operating system?
>
>
> Of course, I'm open to other ideas how to satisfy the use case and keep 
> roles portable, reusable and configurable without always having to modify 
> them.
>
>
> Thanks in advance,
> Patrick
>
>
>
>
>
>

-- 
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/86f9e715-74a6-4980-8168-010b83faa478%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to