Recently I have changed my Ansible set-up based on roles. I have a very similar dependency structure as yours:
host1 -> profile1, profile2 host2 -> profile2, profile3 profile1 -> state1, state2 profile2 -> state2, state3 ... Both profiles and states are roles, but I separate them into two roles directories. I then use role dependencies between profiles and states (and states and states). A playbook simply ties hosts to profile roles. A few thing I ran into: * I needed to use a trick to make sure each state role is run only once. See [1]. * No parameters can be passed to state roles; global variables only. (I use a third role category named "configs" with roles that take parameters.) Small annoyances: * Tasks that are skipped because the role already ran still show up in the log. Other than that, it works great! I would give details, but I am still working on it. May post more when I am satisfied -- or someone bugs me :-) [1] https://groups.google.com/d/msg/ansible-project/nd4wMLsb0Jw/7-svzpNpTIQJ Regards, Joost Op dinsdag 3 juni 2014 07:37:03 UTC+2 schreef [email protected]: > > Yes. I'm only new to ansible but am seriously struggling. The playbooks I > can get my head around but the roles are proving very painful. I thought > the idea might be to switch features on/off for each host via variables? > Would that work? > > [Trivial annoyance: i hate the way it requires a bunch of folders with > just one file in them each] > [Related to that sidenote: the folders are going to have lonely main.ymls > for quite a while since the only apparent use of a file in the same > directory is to be 'included' from main.yml? Have I got that wrong?] > > > On Tuesday, June 3, 2014 2:38:45 PM UTC+10, David Carmean wrote: >> >> >> I was happy to see "roles" when I came back to Ansible after a few >> months, but i've been struggling with how to apply them. I think this is >> partly because of cognitive dissonance between my mental model and the >> current terminology. >> >> In my mind, any particular role that a server may fill (and it may fill >> more than one), in turn requires one or more "features" or "feature-sets" >> in order to be able to fulfill that role. In other words, I think of a >> heirarchy that looks like this; >> >> * appstack_X >> ** server_n >> *** role_a >> **** feature_A >> **** feature_E >> **** feature_O >> *** role_b >> **** feature_A >> **** feature_B >> **** feature_G >> >> Anyone else gone through this thought process,or organize their configs >> like 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 [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/5a37e81d-e435-4e45-aafb-521f538b5cfc%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
