# Doing a make from a ansible playbook

**URL:** <https://forum.ansible.com/t/doing-a-make-from-a-ansible-playbook/11784>\
**Category:** Ansible Project\
**Created:** [August 10, 2012, 7:08pm UTC](https://forum.ansible.com/t/doing-a-make-from-a-ansible-playbook/11784 "2012-08-10T19:08:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [August 10, 2012, 7:08pm UTC](https://forum.ansible.com/t/doing-a-make-from-a-ansible-playbook/11784/1 "2012-08-10T19:08:16Z")

</div>

Hi,  
Was just reading the list, and I have been able to complete untar with:

&nbsp;&nbsp;- name: Extract hdparm  
&nbsp;&nbsp;&nbsp;&nbsp;action: command tar xzf /home/jmarcus/hdparm-9.37.tar.gz -C /home/jmarcus/  
&nbsp;&nbsp;&nbsp;&nbsp;tags:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- hdparm

What is the appropriate way to achieve this:

&nbsp;&nbsp;- name: Compile hdparm  
&nbsp;&nbsp;&nbsp;&nbsp;action: command cd ~jmarcus/hdparm-9.37 ; make  
&nbsp;&nbsp;&nbsp;&nbsp;tags:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- hdparm

Thanks,  
James

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [August 10, 2012, 7:28pm UTC](https://forum.ansible.com/t/doing-a-make-from-a-ansible-playbook/11784/2 "2012-08-10T19:28:59Z")

</div>

use the shell module or add a “chdir=path” to the end of the command line

---

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [August 13, 2012, 5:48pm UTC](https://forum.ansible.com/t/doing-a-make-from-a-ansible-playbook/11784/3 "2012-08-13T17:48:56Z")

</div>

Hi,

Still haven't gotten this to work:

&nbsp;&nbsp;- name: Compile hdparm  
&nbsp;&nbsp;&nbsp;&nbsp;action: shell make chdir=cd /home/jmarcus/hdparm-9.37/  
&nbsp;&nbsp;&nbsp;&nbsp;tags:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- hdparm  
and

&nbsp;&nbsp;- name: Compile hdparm  
&nbsp;&nbsp;&nbsp;&nbsp;action: shell chdir=cd /home/jmarcus/hdparm-9.37/ make  
&nbsp;&nbsp;&nbsp;&nbsp;tags:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- hdparm

I have also tried:

action: command make chdir=cd /home/jmarcus/hdparm-9.37/

with and without the trailing /

bash-3.2$ ansible --version  
ansible 0.6  
bash-3.2$ ansible-playbook --version  
ansible-playbook 0.6  
bash-3.2$

Thanks,  
James

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [August 14, 2012, 12:58am UTC](https://forum.ansible.com/t/doing-a-make-from-a-ansible-playbook/11784/4 "2012-08-14T00:58:08Z")

</div>

chdir= works fine for me in 0.7, though you didn't indicate how it  
failed

Easy test:

ansible all -m command -a "touch foo chdir=/tmp"

I would still recommend not building on your production systems -- the  
git module or deploying an RPM/apt package are easy ways to go.

---

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [August 14, 2012, 3:41pm UTC](https://forum.ansible.com/t/doing-a-make-from-a-ansible-playbook/11784/5 "2012-08-14T15:41:59Z")

</div>

Hi,  
Your example works. This was the error I was getting:

TASK: [Compile hdparm] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [cl009.test.net] =\> {"failed": true, "module": "shell", "msg":  
"cannot change to directory 'cd': path does not exist"}

I have updated the config to this and it works:

&nbsp;&nbsp;- name: Extract hdparm  
&nbsp;&nbsp;&nbsp;&nbsp;action: command tar xzf /home/jmarcus/hdparm-9.37.tar.gz -C /home/jmarcus/  
&nbsp;&nbsp;&nbsp;&nbsp;tags:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- hdparm

&nbsp;&nbsp;- name: Compile hdparm  
&nbsp;&nbsp;&nbsp;&nbsp;action: command make chdir=/home/jmarcus/hdparm-9.37/  
&nbsp;&nbsp;&nbsp;&nbsp;tags:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- hdparm

Thanks,  
James

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [August 14, 2012, 4:14pm UTC](https://forum.ansible.com/t/doing-a-make-from-a-ansible-playbook/11784/6 "2012-08-14T16:14:12Z")

</div>

Right, we can’t cd to a directory if it is not there yet 🙂

---

<div class="post-metadata">

**Author:** ![Will\_Thames](https://avatars.discourse-cdn.com/v4/letter/w/dc4da7/32.png) [@Will\_Thames](https://forum.ansible.com/u/Will_Thames)\
**Post date:** [August 15, 2012, 2:42am UTC](https://forum.ansible.com/t/doing-a-make-from-a-ansible-playbook/11784/7 "2012-08-15T02:42:26Z")

</div>

That’s not actually the problem though.

James is using the command in the form  
command chdir=cd /directory tar …

Note the extraneous cd that is absoutely not required - the directory not found message relates to the directory ‘cd’ - it should be  
command chdir=/directory tar …

Will
