Hi,
I'm writing a cookbook to deploy a service, of which multiple instances can
run at the same time on the same host.
Each instance requires 3 config files: config_X.yml, config_X.env,
log_X.conf, where X=instance number.
I have a template for each config file.
I want the cookbook to set things up for 3 instances.
Having read the doc, it seems I could go in this direction:
Define the 3 instances in an array variable called instances (each having
an index member), and loop over it:
- include: lib/copy_config_files.yml
with_nested:
- "{{ instances }} "
- [ "config_X.yml", "config_X.env", "log_X.conf" ]
and in the lib/copy_config_files.yml, loop over the config files:
- name: copy mode 1 config
template: ....
when: mode == 1
- name: copy mode 2 config
template: ....
when: mode == 2
- name: "Copy configs"
template: src=templates/{{item[1]}} dest=/etc/{{item[1] |
regex_replace('X',{{item[0].index}})}} owner=root group=root mode=0744
First question: is this the right approach?
Second: what's the best solution to the conditional template for mode1 and
mode2 configs? With this cookbook it is unnecessarily generated multiple
times. Is the solution to extract these to a seperate fil included one
level higher?
thanks in advance for any tips!
Raphaƫl
--
------------------------------
DISCLAIMER.
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the system manager.
This message contains confidential information and is intended only for the
individual named. If you are not the named addressee you should not
disseminate, distribute or copy this e-mail. Please notify the sender
immediately by e-mail if you have received this e-mail by mistake and
delete this e-mail from your system. If you are not the intended recipient
you are notified that disclosing, copying, distributing or taking any
action in reliance on the contents of this information is strictly
prohibited.
--
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/258ca8fc-b3f7-450e-a42f-7eeb65c15cc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.