Shell module: <with indispensable

I want to run the command:

- name: install pip
  shell: "python <(curl https://bootstrap.pypa.io/get-pip.py)"

But make a mistake

failed: [default] => {"changed": true, "cmd": "python <(curl https://bootstrap.pypa.io/get-pip.py)", "delta": "0:00:00.002073", "end": "2014-12-03 15:52:01.780837", "rc": 2, "start": "2014-12-03 15:52:01.778764", "warnings": []}
stderr: /bin/sh: 1: Syntax error: "(" unexpected

I tried changing it to something like:

python <$(curl https://bootstrap.pypa.io/get-pip.py)

but that will not work. Any thoughts?

NB: this question is about using an operator <in a shell module, and I know it is better to use aptto install something

+4
source share
3 answers

EDIT: although this answers this question, I think the mgsk answer is the best answer, since I agree that this is not the right way to get around this with Ansible.

This should fix your problem:

- name: install pip
  shell: "python <(curl https://bootstrap.pypa.io/get-pip.py)" executable=/bin/bash

If you are interested in the difference between the two commands:

python <(curl https://bootstrap.pypa.io/get-pip.py)
python <$(curl https://bootstrap.pypa.io/get-pip.py)

, bash, /bin/sh , curl ( python script), python, python script.

- , python script, curl,

+3

command, shell.

get_url , curl, . Ansible , curl get_url :

"warnings": ["Consider using get_url module rather than running curl"]

:

- name: Download pip installer
  get_url:
    url=https://bootstrap.pypa.io/get-pip.py
    dest=/tmp/get-pip.py
    mode=0440

- name: Install pip
  command: /usr/bin/python /tmp/get-pip.py

get_url: http://docs.ansible.com/get_url_module.html

+9
  - name: configure zookeeper /etc/zookeeper/conf/zoo.cfg
    shell: "{{ item }}" 
    with_items:
       if [ -f /etc/zookeeper/conf/zoo_cfg.org ] ;
       then  cp /etc/zookeeper/conf/zoo_cfg.org  /etc/zookeeper/conf/zoo.cfg ;
       else cp /etc/zookeeper/conf/zoo.cfg /etc/zookeeper/conf/zoo_cfg.org;
       fi;
       cat /vagrant/zoo.cfg.j2 >> /etc/zookeeper/conf/zoo.cfg;
0
source

All Articles