Doing a make from a ansible playbook

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

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

What is the appropriate way to achieve this:

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

Thanks,
James

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

Hi,

Still haven't gotten this to work:

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

  - name: Compile hdparm
    action: shell chdir=cd /home/jmarcus/hdparm-9.37/ make
    tags:
       - 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

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.

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:

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

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

Thanks,
James

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

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