john84 john84 - 1 year ago 123
Python Question

Provisioning CoreOS with Ansible pip error

I am trying to provision a coreOS box using Ansible. First a bootstapped the box using

This seems to work ad all but pip (located in /home/core/bin) is not added to the path. In a next step I am trying to run a task that installs docker-py:

- name: Install docker-py
pip: name=docker-py

As pip's folder is not in path I did it using ansible:

PATH: /home/core/bin:$PATH

If I am trying to execute this task I get the following error:

fatal: []: FAILED! => {"changed": false, "cmd": "/home/core/bin/pip install docker-py", "failed": true, "msg": "\n:stderr: /home/core/bin/pip: line 2: basename: command not found\n/home/core/bin/pip: line 2: /root/pypy/bin/: No such file or directory\n"}

what I ask is where does
come from it seems this is the problem. Any idea?

Answer Source

You can't use shell-style variable expansion when setting Ansible variables. In this statement...

  PATH: /home/core/bin:$PATH are setting your PATH environment variable to the literal value /home/core/bin:$PATH. In other words, you are blowing away any existing value of $PATH, which is why you're getting "command not found" errors for basic things like basename.

Consider installing pip somewhere in your existing $PATH, modifying $PATH before calling ansible, or calling pip from a shells cript:

- name: install something with pip
  shell: |
    pip install some_module
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download