Compiling some source with Ansible

Dear list,

Our servers run Ubuntu 10.04. We’d like to run the latest Monit on it. This needs to be compiled from source. A snippet:

  • name: move Monit source
    action: copy src=monit-5.3.2.tar.gz dest=/tmp/monit-5.3.2.tar.gz
  • name: untar the source
    action: command tar xzf /tmp/monit-5.3.2.tar.gz
  • name: build the source
    action: command cd /home/vagrant/monit-5.3.2 && make && make install

Evidently the last one doesn’t work. Using the ‘shell’ module seems unsafe so I was thinking of making the last action into three actions (still seems not quite right). One ‘cd’, two ‘make’, three ‘make install’. But even the first action fails with:
failed: [localhost] => command cd /home/my_user/monit-5.3.2 => {“cmd”: [“cd”, “/home/my_user/monit-5.3.2”], “failed”: 1, “msg”: “[Errno 2] No such file or directory”}

I checked, the directory is there. What am I doing wrong? Or better yet how should I do this?

With kind regards,

Dear list,

Our servers run Ubuntu 10.04. We’d like to run the latest Monit on it. This needs to be compiled from source. A snippet:

  • name: move Monit source
    action: copy src=monit-5.3.2.tar.gz dest=/tmp/monit-5.3.2.tar.gz
  • name: untar the source
    action: command tar xzf /tmp/monit-5.3.2.tar.gz
  • name: build the source
    action: command cd /home/vagrant/monit-5.3.2 && make && make install

Evidently the last one doesn’t work. Using the ‘shell’ module seems unsafe so I was thinking of making the last action into three actions (still seems not quite right). One ‘cd’, two ‘make’, three ‘make install’. But even the first action fails with:
failed: [localhost] => command cd /home/my_user/monit-5.3.2 => {“cmd”: [“cd”, “/home/my_user/monit-5.3.2”], “failed”: 1, “msg”: “[Errno 2] No such file or directory”}

I checked, the directory is there. What am I doing wrong? Or better yet how should I do this?

Let me change the question. Building modules on the remote server is not a good configuration management practice – You want to build a package and then install it.

If you don’t want to use the shell module, you can always execute multiple things using with_items. See the playbook docs!