Ansible Variable above hosts
hello its posible to create a variable for multi hosts like this?
vars:
some_vars: "./Prometheus/roles/" # <---- THIS Variable?
- hosts: lxd1
vars_files:
- Prometheus/vars/grafana_vars.yml
become: true
roles:
- '{{ some_vars }}Stouts.grafana' <--- var usage
- hosts: lxd1
vars_files:
- Prometheus/vars/exporters_common_vars.yml
become: true
roles:
- './Prometheus/roles/ansible-prometheus-exporters-common'
Best Answer
No that is not valid syntax in a playbook. There is no way within a playbook to include vars that will apply for all plays.
If you want variables applied to multiple plays, and so multiple hosts hosts define them in your inventory or group_vars.
You could also pass variables from the command line, if you need variables to apply to many plays using the
-e
option.