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: "{{ 'user1,user2,user3' if server_type=db_server else 
> 'user4,user5,user6' if server_type=web_server else
> 'user7,user8,user1' if server_type=standard_server }}'
> 
> These can get pretty long depending on what we're trying to do, and fairly 
> hard to read. I could do multi-line variables
> I guess, but was wondering if there's a more clever way to handle stuff like 
> this.

That looks like the users should be named in group variables, e.g.:

db_server:
   users:
     - user1
     - user2
     - user3

That's better and more flexible than your conditional approach.

Regards
           Racke

> 
> -- 
> 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] 
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/38a5d109-d789-465b-9694-470c0b6b59d7%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/38a5d109-d789-465b-9694-470c0b6b59d7%40googlegroups.com?utm_medium=email&utm_source=footer>.


-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/53fa1c17-f37c-e962-a7d3-b883a105e67c%40linuxia.de.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to