Hello to all,
I need to choose between two variables file depending on an external
parameter.
E.g in a task file
- include_vars: jboss_5.yml
when: "{{ my_app_version | version_compare('8', '=') }}"
- include_vars: jboss_7.yml
when: "{{ my_app_version | version_compare('10', '=') }}"
This files vars contains the java version, the paths, and others info,
useful for the installation.
Because my app use different version of jboss.
Inside tasks I can safely use include_vars and version compare, as showed.
But I want that this mechanism could be used in a playbook, so that all my
play can use variables valorised correctly
right now i must use this workaround that i don't like it
- name: Install app_node_1
hosts: node_1
remote_user: "{{ remote_host_user }}"
sudo: yes
gather_facts: yes
vars_files:
- roles/my_app/vars/{{ my_app_version }}_vars.yml
etc ....
- name: Install app_node_2
hosts: node_2
remote_user: "{{ remote_host_user }}"
sudo: yes
gather_facts: yes
vars_files:
- roles/my_app/vars/{{ my_app_version }}_vars.yml
etc ....
In this case if for example there are two problems
1. there are a repeated code
2. if for example *my app version is 9*, and have the same configuration as
8 for jboss, i need to create another file even if i don't need it.
There are a simple and more linear way to include global vars for playbook,
but with a condition as showed before?
Thx so much.
Diego Mauricio
--
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/9502f4ad-3b1c-418f-9241-045446f77ba2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.