Hi,

I try to build a playbook that kind of leaves the trivial ranges usually 
handled in books. Consequentially I did not find anything suitable in the 
books I have and my development skills do not help me further.



Assume this: I want to build a VM that combines multiple bitnami stacks 
(bitnami.com, a stack is actually a preset combination of web-server, 
application and db, with a full-fledged installer for those who never came 
across these).

Logically I made roles out of this:

   - bitnami-redmine
   - bitnami-tracks
   - ...

Now each of the roles needs an individual configuration, e.g.

   - tcp-ports
   - directories
   - users and passwords

At first I used a dicts from the global scope.

Now the tasks of each stack look much alike and I found myself text-editing 
a lot like search&replace for ages including the related human errors.

I was not exactly fond of this solution, so - still learning and 
experimenting with ansible - I changed that to a parameter-dict.

Calling this along the pattern sketched here:

vars:
 redmine-cfg:
   directory: ...
   port: 1234

roles:
 - { role: bitnami-redmine, config: {{ redmine-cfg }} }


Now I learned that dicts do not mix when overwriting. In this special case, 
the defaults do not mix with the parameter. So the parameter dict must be 
complete, or I need to code the defaults into tasks and templates using the 
jinja-syntax and forget about the defaults/main.yml in that role. To 
overcome this, I'd have to code the config values in the global scope as 
individual variables.
I'd value this as "capital punishment" regarding style.

Another thing I learned: it is now impossible to simply access another 
roles parameter because the are all called config. So assuming a 
backup-role I'd depend on, I could not simply access its backup-directory.



I do not know wether my dillemma is apparant from this description. What I 
am looking for is the best practice on "how to instantiate a role with 
specific configuration" with style and least redundant coding, optimally 
avoiding too much search&replace in the code.


Does that make sense? Is there a best practice I could adopt? 
(Let me add ... I am not a native English-speaker/-writer and I am pretty 
new to ansible)

Thanks in advance
Best regards
Koffeiniker


-- 
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/e63dd646-f9b1-4c06-8b66-a4353e6e95e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to