使用Ansible,如何在系统范围内安装PythonBrew?

使用Ansible,如何在系统范围内安装PythonBrew?,ansible,pythonbrew,Ansible,Pythonbrew,我正在尝试使用Ansible(v1.3.3)创建一个playbook,以便按照中的说明在Debian服务器上安装Pythonbrew系统范围 我可以安装Pythonbrew,但是我无法安装我想要的Python的特定版本。我怀疑这个问题与Ansible运行的shell环境有关 以下是我的剧本脚本: - name: Install and configure PythonBrew hosts: dev user: root vars_files: - vars.yml gat

我正在尝试使用Ansible(v1.3.3)创建一个playbook,以便按照中的说明在Debian服务器上安装Pythonbrew系统范围

我可以安装Pythonbrew,但是我无法安装我想要的Python的特定版本。我怀疑这个问题与Ansible运行的shell环境有关

以下是我的剧本脚本:

- name: Install and configure PythonBrew
  hosts: dev
  user: root
  vars_files:
    - vars.yml
  gather_facts: false

  tasks:
    - name: Install PythonBrew Debian packages
      apt: pkg=${item} state=installed update-cache=yes
      with_items: ${pythonbrew_packages}

    - name: Install PythonBrew system-wide
      shell: curl -kL http://xrl.us/pythonbrewinstall | bash creates=/usr/local/pythonbrew executable=/bin/bash

    - name: Update bashrc for PythonBrew
      lineinfile:
        dest=~/.bashrc
        regexp='^'
        line='[[ -s $HOME/.pythonbrew/etc/bashrc ]] && source $HOME/.pythonbrew/etc/bashrc'
        state=present
        create=True

    - name: Install python binary
      shell: pythonbrew install -v ${python_version} executable=/bin/bash
当我运行这个剧本时,它失败了,输出如下

失败:[devserver]=>{“已更改”:true,“cmd”:“pythonbrew” 安装-v 2.7.3,“增量”:“0:00:00.016639”,“结束”:“2013-10-11” 15:21:40.989677,“rc”:127,“开始”:“2013-10-11 15:21:40.973038”} stderr:/bin/bash:pythonbrew:未找到命令

在过去的一个小时左右,我一直在调整一些东西,但都没有用。有人对修复这个问题有什么建议吗?

通过看一眼屏幕,我就知道了。(而且正好赶上比赛!)

这是一本不需要人工干预就能安装PythonBrew的剧本。任何试图编写PythonBrew脚本以自动安装的人都可能对此感兴趣

瓦拉斯·伊梅尔 pythonbrew.yml
#
# Python/PythonBrew Settings
# TODO: replace old-style Ansible ${vars} with jinja-style {{ vars }}
#
project_name: MY_PROJECT

python:
  version: 2.7.3

pythonbrew:
  root: /usr/local/pythonbrew
  bashrc_path: $HOME/.pythonbrew/etc/bashrc

  packages:
    - curl
    - zlib1g-dev
    - libsqlite3-dev
    - libssl-dev
    - libxml2
    - libxml2-dev
    - libxslt1-dev
    - libmysqlclient-dev
    - libbz2-dev
---

#
# Install and Configure PythonBrew
#
- name: Install and configure PythonBrew
  hosts: MY_HOST
  user: root
  vars_files:
    - vars.yml
  gather_facts: false

  tasks:
    - name: Install PythonBrew Debian packages
      apt: pkg=${item} state=installed update-cache=yes
      with_items: ${pythonbrew.packages}

    - name: Install PythonBrew system-wide
      shell: curl -kL http://xrl.us/pythonbrewinstall | bash
        executable=/bin/bash
        creates=${pythonbrew.root}

    - name: Update bashrc for PythonBrew
      lineinfile:
        dest=/root/.bashrc
        regexp='^'
        line='[[ -s ${pythonbrew.bashrc_path} ]] && source ${pythonbrew.bashrc_path}'
        state=present
        create=True

    # This step allows install to continue without new shell. Pulled from:
    # https://github.com/utahta/pythonbrew/blob/master/pythonbrew/installer/pythonbrewinstaller.py#L91
    - name: Install python binary
      shell: export PYTHONBREW_ROOT=${pythonbrew.root}; source ${pythonbrew.root}/etc/bashrc; pythonbrew install ${python.version}
        executable=/bin/bash

    - name: Switch to python version
      shell: export PYTHONBREW_ROOT=${pythonbrew.root}; source ${pythonbrew.root}/etc/bashrc; pythonbrew switch ${python.version}
        executable=/bin/bash