A lot of our builds have site or subnet specific differences so we use 
Ansible facts to include specific YML files for either additional variables 
or branching the execution.

For example, to choose the proper method to install VMware tools on our 
systems (RHEL 6 vs 7, and internet access or not) we use something like 
this:

- name: "Include the appropriate OS steps."
  include: "{{ role_path }}/tasks/OSsetup-{{ osver }}-{{ 
vmwaretools_local|bool }}.yml"

Basically the "osver" variable is set earlier based on the OS name 
("RedHat" vs "Debian" vs "Ubuntu"), then use the variable 
"vmwaretools_local" to know if we need to get from a local repo 
(internally) or from the VMWare.com Internet site.

On Friday, August 30, 2019 at 9:50:00 AM UTC-5, Cade Lambert wrote:
>
> I wanted to see how you guys go about building dynamic variables.  We have 
> some playbooks/roles that require variables to be built based on various 
> things, such as user input or other variables.  I usually end up building a 
> long line of 'if-then-else' statements, which can be difficult to read and 
> troubleshoot. Is there a better way to go about this?  How do you all 
> tackle this?
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a64f0d23-f5c7-4582-87bd-479fdafef492%40googlegroups.com.

Reply via email to