# ad-hoc module chdir

**URL:** <https://forum.ansible.com/t/ad-hoc-module-chdir/16937>\
**Category:** Ansible Project\
**Created:** [December 2, 2014, 11:44am UTC](https://forum.ansible.com/t/ad-hoc-module-chdir/16937 "2014-12-02T11:44:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serkan\_C](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Serkan\_C](https://forum.ansible.com/u/Serkan_C)\
**Post date:** [December 2, 2014, 11:44am UTC](https://forum.ansible.com/t/ad-hoc-module-chdir/16937/1 "2014-12-02T11:44:19Z")

</div>

Hi,  
Is it possible to pass chdir directive to ad-hoc module?  
I would like to do something like that;  
ansible server -a 'cd /opt/; java -jar export.jar ’ [WRONG, don’t use it]

ansible server -a ‘java -jar export.jar’ -e chdir=/opt/’ [WRONG, don’t use it]

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [December 3, 2014, 12:57am UTC](https://forum.ansible.com/t/ad-hoc-module-chdir/16937/2 "2014-12-03T00:57:41Z")

</div>

If I understand you to mean "ad hoc remote command" then yes. If you  
mean to "any of the ansible modules" then no.

Things you can do:  
ansible server -a 'chdir=/opt/ pwd'

ansible server -m shell 'cd /opt/; pwd'

Things you can't do:

ansible server -m git -a 'cd /opt/ ; dest=./in/opt'

Note: when no module is specified explicitly, the command module is  
used. You can see the chdir parameter and other parameters that  
command takes here: [http://docs.ansible.com/command\_module.html](http://docs.ansible.com/command_module.html)

-Toshio
