Error installing docker-compose using download file

I have a very simple Ansible playbook, all the dependencies installed for docker-compose and docker, but I get an error when installing docker-compose. This is the task of my play for installing docker-compose on CentOS7.

#ensure docker-compose and chmod +x /usr/local/bin/docker-compose - name: Ensure docker-compose is installed and available command: curl -L https://github.com/docker/compose/releases/download/1.7.0-rc1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose - name: Ensure permissions docker-compose command: chmod +x /usr/local/bin/docker-compose 

The following error will appear:

 TASK: [Ensure docker-compose is installed and available] ********************** failed: [nutrilife-aws] => {"changed": true, "cmd": ["curl", "-L", "https://github.com/docker/compose/releases/download/1.7.0-rc1/docker-compose-`uname", "-s`-`uname", "-m`", ">", "/usr/local/bin/docker-compose"], "delta": "0:00:00.004592", "end": "2016-03-26 14:19:41.852780", "rc": 2, "start": "2016-03-26 14:19:41.848188", "warnings": ["Consider using get_url module rather than running curl"]} stderr: curl: option -s`-`uname: is unknown curl: try 'curl --help' or 'curl --manual' for more information FATAL: all hosts have already failed -- aborting PLAY RECAP ******************************************************************** to retry, use: --limit @/home/mmaia/playbook.retry nutrilife-aws : ok=4 changed=0 unreachable=0 failed=1 

I kind of got stuck with this simple mistake for hours. I got a command from the standard docker site and tested directly in the shell and it works. I also tried using double quotes to wrap around the command as a command: "curl ...", but that did not change the error.

+6
source share
2 answers

As helloV pointed out , you need to use shell if you want to use things like shell extension or shell environment variables.

However, in Ansible you are usually better off using higher-level modules and resorting to shell or command modules if you cannot do what you need with another module. This approach gives you better performance control for free, such as easy idempotency and better output visibility.

In your case, you can use get_url (I believe that Ansible will actually warn you if you try to lay out with curl that you can be better with this module) to retrieve things from the Internet.

In your case, your task might look something like this:

  - name: Ensure docker-compose is installed and available get_url: url : https://github.com/docker/compose/releases/download/1.7.0-rc1/docker-compose-{{ ansible_system }}-{{ ansible_userspace_architecture }} dest: /usr/local/bin/docker-compose mode: 'u+x,g+x' 

The above task uses special variables returned by the fact collection on the target host, so that your task works fine on both Linux or OS X systems (you will need a conditional .exe suffix for Windows communication, and obviously another destination path, etc. )

It also uses the mode parameter from the file module to add execute permissions for the user and group so that your chmod task can be avoided.

+13
source

command not processed by the shell. Use shell .

  - name: Ensure docker-compose is installed and available shell: curl -L https://github.com/docker/compose/releases/download/1.7.0-rc1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose 
+5
source

All Articles