Defaults section in vars when designing a role

24 views
Skip to first unread message

Rob Young

unread,
Feb 9, 2015, 1:23:48 PM2/9/15
to ansible...@googlegroups.com
Hi,

I'm trying to design a relatively generic role for managing AWS Elastic Beanstalk applications. Because some of the configuration options need to be the same across a few environments I'd like to have a place towards the top level of the vars file that contains these. I have something working [1] but the tasks file is very verbose. Specifically, the following seems very verbose.

instance_type: "{{ item.1.rds_instance_type|default(eb.defaults[item.1.defaults].rds_instance_type)|default(omit) }}"

Is this a common pattern when writing reusable Ansible roles?
If not, how is this kind of problem usually addressed?
Also, are there any other problems you can see with either file?

Thanks,
Rob

James Cammarata

unread,
Feb 10, 2015, 1:23:43 AM2/10/15
to ansible...@googlegroups.com
Hi Rob, 

I don't think there's anything overly verbose about that. You could use the defaults/main.yml file to put defaults in, rather than using the default() method you're using, but that depends on what you're trying to do to a degree and might not work since you're using with_subelements.

Hope that helps some.

--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f5a372dd-ea79-4727-806b-4fa6eae14012%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages