# pass variable filename as command line argument

**URL:** <https://forum.ansible.com/t/pass-variable-filename-as-command-line-argument/13926>\
**Category:** Ansible Project\
**Created:** [November 18, 2013, 1:43pm UTC](https://forum.ansible.com/t/pass-variable-filename-as-command-line-argument/13926 "2013-11-18T13:43:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cpatanaik](https://avatars.discourse-cdn.com/v4/letter/c/cdc98d/32.png) [@cpatanaik](https://forum.ansible.com/u/cpatanaik)\
**Post date:** [November 18, 2013, 1:43pm UTC](https://forum.ansible.com/t/pass-variable-filename-as-command-line-argument/13926/1 "2013-11-18T13:43:02Z")

</div>

Hi,

I have used var\_files to include a variable file inside of a playbook.

But I would like to know whether it’s possible to pass the file path as a part of the ansible-playbook command itself.

Thanks,  
Chinmaya

---

<div class="post-metadata">

**Author:** ![Timothy\_Appnel](https://avatars.discourse-cdn.com/v4/letter/t/e5b9ba/32.png) [@Timothy\_Appnel](https://forum.ansible.com/u/Timothy_Appnel)\
**Post date:** [November 18, 2013, 9:56pm UTC](https://forum.ansible.com/t/pass-variable-filename-as-command-line-argument/13926/2 "2013-11-18T21:56:25Z")

</div>

I’ve added a var\_file from the command line using a variable inside of the extra-vars option on the command line. Something like…

$ ansible-playbook all some\_plabook.yml --extra-vars=“myvarfile=/path/to/varfile”

Where some\_plabook.yml has a:

vars\_files: {{ myvarfile }}

It’s a bit verbose and ugly as opposed to having an explicit var-file option, but it works.

---

<div class="post-metadata">

**Author:** ![cpatanaik](https://avatars.discourse-cdn.com/v4/letter/c/cdc98d/32.png) [@cpatanaik](https://forum.ansible.com/u/cpatanaik)\
**Post date:** [November 19, 2013, 7:11am UTC](https://forum.ansible.com/t/pass-variable-filename-as-command-line-argument/13926/3 "2013-11-19T07:11:28Z")

</div>

Hi,

That’s exactly what I have been looking for.

Thanks,
