Ansible - playbook_dir magic variable

Let's say you've a playbook named foo.yml that exists in the /usr/local directory, like this.

/usr/local/foo.yml

 

The playbook_dir variable will contain the directory that contains the playbook. Here is how you would print the playbook_dir variable.

- name: "output the 'playbook_dir' variable"
  debug:
    msg: "{{ playbook_dir }}"

 

Running this playbook should produce the following.

TASK [output the 'playbook_dir' variable] 
ok: [server1.example.com] => {
    "msg": "/usr/local"
}

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





Please enter 1a947 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |