I set those in group_vars/appname-stg.yml, group_vars/appname-dev.yml, etc.
as long as a host only belongs to one environment-grouping, this works
great.
On Monday, May 22, 2017 at 9:18:21 AM UTC-5, Wilfried Anuzet wrote:
>
> Hello to all Ansible guru :)
>
> I write a playbook to deploy a newest Jboss infrastructure.
> I want to use a loop to iterate over a list of items to deploy all the
> datasource I need, all the datasources change based on the environnement
> they're deployed
>
> Here the part of my role to add the datasource:
>
> - name: Add datasources
> command: {{ jboss_home }}/bin/jboss-cli.sh -c controller={{
> jboss_master }}:{{ jboss_master_port }} --user={{ admin_user }} --password
> ={{ admin_password }} --command="data-source add --jndi-name={{
> item.jndi_name }} --name={{ item.ds_name}} --connection-url={{
> item.conn_url }} --driver-name={{ item.driver_name }} --user-name={{
> item.dsusername }} --password={{ item.dspassword }} --profile={{
> item.ds_profile }}"
> with_items:
> - { some vars }
> - { another vars }
> - ...
>
>
> When I launch the playbook I use a different inventory file based on the
> environnement, like:
> ansible-playbook -i testing install-all.yml
> or
> ansible-playbook -i production install-all.yml
>
> What's the best pratices to add datasources based on the environnement
> type ?
> I think about something like:
> command: some_command_with_vars
> with_items:
> - { some_item }
> when: {{ env }}
>
>
> But I have to write three blocks with all item for my three environnement
> (the two other will be skipped everytime I run the playbook).
>
> Is there's a way to load dynamically a file containing a dict with all
> item I need based on the environnement ?
> In that way I have to write three file containing the vairables I need
> inthe vars folder (test.yml, val.yml and prod.yml) and load them
> dynamically based on the environnement variable I can set in the inventory
> file. Something like:
>
> command: some_command_with_vars
> with_items_in:
> - {{ env }}.yml
>
> Am I and the right way ? What I missed here and how do you handle that ?
>
> Thanks :)
>
>
>
>
--
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/8976b4ad-d1c1-429b-a985-a686c97272d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.