I'm using Ansible 2.1.1.0. In Ansible, is there a way to define a variable in group_vars/all file with a dynamic variable set as an extra var in ansible-playbook command?
I have my play.sh file as follows.
ansible-playbook site.yml -i hosts -e "home_dir=$1"
Then I want to use it as a global variable in group_vars/all file as follows.
my_dir: {{ home_dir }}/sub_dir/my_dir
I know the syntax above is wrong for the all file, and this can be done by using the variable directly in the task yaml file. Is there any way I can use a dynamic 'ansible-playbook extra variable' for defining a 'global variable'?