Awesome, thanks for the responses. This definitely looks like a more
logical, thoughtful approach than cramming a bunch of if-else statements
into a single line. I'll take these back and try reworking my vars file.
Thanks again.
--
You received this message because you are subscribed to
Dang! @Karl Auer beat me to this example. :)
Depending on your needs and comfort level, here are two examples with
sample output.
The first "userlistA" is closer to your original example and has each list
with a name that is not consistent with the server_type variable. That
leads to the
You could use set_fact: stanzas instead, with when: clauses.
- set_fact:
user_list: 'user1, user2, user3'
when: server_type = 'db_server'
Even better, use lists rather than strings. You can always turn one into
the other, and lists are more flexible:
- set_fact:
user_list: ['user1',
On 9/3/19 3:28 PM, Cade Lambert wrote:
> The problem I come across is I'll need logic to decide on the content of a
> variable and that logic will turn into a long
> string. For example, when determining which users to add to a system, we
> might have a variable like:
>
> user_list: "{{
The problem I come across is I'll need logic to decide on the content of a
variable and that logic will turn into a long string. For example, when
determining which users to add to a system, we might have a variable like:
user_list: "{{ 'user1,user2,user3' if server_type=db_server else
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