Using Ansible, How Can I Install Pythonbrew System-wide?
I'm trying to create a playbook with Ansible (v 1.3.3) to install Pythonbrew system-wide on a Debian server following the instructions in the Pythonbrew readme file. I am able to
Solution 1:
By peeking at the PythonBrew install script, I was able to figure this out. (And just in time for the deprecation of PythonBrew!)
Here's the playbook that installs PythonBrew without manual intervention. This may be of interest to anyone trying to script PythonBrew to install automatically.
vars.yml
## Python/PythonBrew Settings# TODO: replace old-style Ansible ${vars} with jinja-style {{ vars }}#project_name:MY_PROJECTpython:version:2.7.3pythonbrew:root:/usr/local/pythonbrewbashrc_path:$HOME/.pythonbrew/etc/bashrcpackages:-curl-zlib1g-dev-libsqlite3-dev-libssl-dev-libxml2-libxml2-dev-libxslt1-dev-libmysqlclient-dev-libbz2-dev
pythonbrew.yml
---
## Install and Configure PythonBrew#-name:InstallandconfigurePythonBrewhosts:MY_HOSTuser:rootvars_files:-vars.ymlgather_facts:falsetasks:-name:InstallPythonBrewDebianpackagesapt:pkg=${item}state=installedupdate-cache=yeswith_items:${pythonbrew.packages}-name:InstallPythonBrewsystem-wideshell:curl-kLhttp://xrl.us/pythonbrewinstall|bashexecutable=/bin/bashcreates=${pythonbrew.root}-name:UpdatebashrcforPythonBrewlineinfile:dest=/root/.bashrcregexp='^'line='[[-s${pythonbrew.bashrc_path}]]&&source${pythonbrew.bashrc_path}'state=presentcreate=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:Installpythonbinaryshell:exportPYTHONBREW_ROOT=${pythonbrew.root};source${pythonbrew.root}/etc/bashrc;pythonbrewinstall${python.version}executable=/bin/bash-name:Switchtopythonversionshell:exportPYTHONBREW_ROOT=${pythonbrew.root};source${pythonbrew.root}/etc/bashrc;pythonbrewswitch${python.version}executable=/bin/bash
Post a Comment for "Using Ansible, How Can I Install Pythonbrew System-wide?"