How can I add keys to a hash variable in Ansible YAML -


i've got variable in ansible use pass environment variables task. however, i've got playbook uses role, , i'd tack more values onto variable. how can accomplish this? example, want have different oracle_home depending on type of server i'm running playbook against.

--- group_vars/application.yml environment_vars:   pip_extra_index_url=https://my.local.repo/pypi  --- group_vars/ubuntu.yml environment_vars:   oracle_home: '/usr/lib/oracle/instantclient_11_2'  --- group_vars/centos.yml environment_vars:   oracle_home: '/opt/oracle/instantclient_11_2'  --- roles/test_role/tasks/main.yml - name: install python requirements   pip:     name: my_app==1.0   environment: environment_vars  --- main.yml - hosts: application   roles:      - role: test_role  --- inventory [application:children] ubuntu centos 

i'd way:

environment_vars:   oracle_home: >     {% if ansible_distribution=='centos' %}       /opt/oracle/instantclient_11_2     {% elif ansible_distribution == 'debian' %}       /usr/local/oracle/instantclient_11_2     {% else %}       /dev/null     {% endif %} 

it may need tweaking rid of white space.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -