How to display the Current ansible-playbook Path?
I’m going to show you how to Use the “playbook_dir” Ansible Magic Variable in Ansible Playbook with a live demo and some simple Ansible code.
I’m Luca Berton and welcome to today’s episode of Ansible Pilot.
Ansible Magic Variables
The path to the directory of the playbook that was passed to the ansible-playbook command line
How to Ansible Magic Variables in Ansible Playbook.
The good news is that Ansible provides some internal variables that come out of the box with some information such as running the Ansible version, inventory details, or execution options.
The full list is available on the official Ansible website https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html
Use “playbook_dir” Ansible Magic Variable in Ansible Playbook
How to display the Current ansible-playbook Path? I’m going to show you how to user the “playbook_dir” Ansible Magic Variable in Ansible Playbook.
Let’s see in action some of the most common Ansible Magic Variables in an Ansible Playbook.
- name: playbook directory demo
- name: print current playbook directory
ansible-pilot $ ansible-playbook -i virtualmachines/demo/inventory file_management/file_playbookdir.ymlPLAY [playbook directory demo]…