conda install in playbook

Hi,
We have few python applications need to be installed on Ubuntu 16.04. Before using Ansible, I need to:

  1. Download Anaconda2-4.0.0-Linux-x86_64.sh
  2. Install Anaconda in path /opt/anaconda

bash Anaconda2-4.0.0-Linux-x86_64.sh -b -p /opt/anaconda

  1. Get conda packages, save them in /tmp/anaconda/. For example:

/tmp/anaconda/chaco-4.5.0-np110py27_0.tar.bz2 /tmp/anaconda/conda-4.0.7-py27_0.tar.bz2 ...

  1. Install the above packages:

/opt/anaconda/bin/conda install /tmp/conda/*.bz2 -p /opt/anaconda

Now I am trying to do this in Ansible. I succeeded on step 1 to 3, but failed on step 4. My playbook is:
`

  • name: Install additional Anaconda packages
    command: /opt/anaconda/bin/conda install /tmp/anaconda/*.bz2 -p /opt/anaconda

`

Output:

`

TASK [Install additional Anaconda packages] ************************************
fatal: [192.168.123.165]: FAILED! => {“changed”: true, “cmd”: [“/opt/anaconda/bin/conda”, “install”, “/tmp/anaconda/.bz2", “-p”, “/opt/anaconda”], “delta”: “0:00:03.789005”, “end”: “2017-03-09 09:34:41.225162”, “failed”: true, “rc”: 1, “start”: “2017-03-09 09:34:37.436157”, “stderr”: "Using Anaconda Cloud api site https://api.anaconda.org\nError: Package missing in current linux-64 channels: \n - /tmp/anaconda/.bz2\n\nYou can search for this package on anaconda.org with\n\n anaconda search -t conda /tmp/anaconda/*.bz2\n\nYou may need to install the anaconda-client command line client with\n\n conda install anaconda-client”, “stdout”: “Fetching package metadata: …\nSolving package specifications: .”, “stdout_lines”: [“Fetching package metadata: …”, “Solving package specifications: .”], “warnings”: }
to retry, use: --limit @/etc/ansible/test.retry

PLAY RECAP *********************************************************************
192.168.123.165 : ok=1 changed=0 unreachable=0 failed=1
`

Could someone help me to tell me what is the correct way to do conda install?

Thanks a lot.

From the output, it seams it's trying to find literal name /tmp/anaconda/*.bz2,
I guess the asterisk is not being expanded. It might work with the shell module or you can write it like this instead.

- name: Install additional Anaconda packages
   command: /opt/anaconda/bin/conda install {{ item }} -p /opt/anaconda
   with_items:
     - /tmp/anaconda/chaco-4.5.0-np110py27_0.tar.bz2
     - /tmp/anaconda/conda-4.0.7-py27_0.tar.bz2