Role Variables
--------------
-None.
+pyenv_version: Version of pyenv to install.
+python34_version: Version of Python 3.4 to install.
+python35_version: Version of Python 3.5 to install.
+python36_version: Version of Python 3.6 to install.
Dependencies
------------
---
- name: Prepare
hosts: all
- gather_facts: false
- tasks: []
+ gather_facts: true
+ tasks:
+ - name: Install Fedora EPEL repo
+ yum:
+ name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
+ state: present
+ when: ansible_os_family == 'RedHat'
+ become: true
+
+ - name: Install Git
+ package: name=git state=present
+
+ - name: Install Python compile dependencies
+ yum:
+ name:
+ - bzip2-devel
+ - gcc
+ - make
+ - openssl-devel
+ state: present
+ when: ansible_os_family == 'RedHat'
+ become: true
+
+ - name: Install Python compile dependencies
+ apt:
+ name:
+ - libbz2-dev
+ - gcc
+ - make
+ - libssl-dev
+ - wget
+ state: present
+ when: ansible_distribution == 'Ubuntu'
+ become: true
---
-# tasks file for python-install
+- name: Include distro specific variables
+ include_vars: "{{item}}"
+ with_first_found:
+ - '{{ ansible_os_family }}.yml'
+
+- name: Install Python
+ package:
+ name: '{{ python_packages }}'
+ state: present
+ become: true
+
+- name: Install Python via pyenv
+ environment:
+ PYENV_ROOT: /opt/pyenv
+ PATH: '/opt/pyenv/bin:{{ansible_env.PATH}}'
+ PYTHON34_VERSION: '{{python34_version}}'
+ PYTHON35_VERSION: '{{python35_version}}'
+ PYTHON36_VERSION: '{{python36_version}}'
+ block:
+ - name: 'Install pyenv {{pyenv_version}}'
+ git:
+ repo: https://github.com/pyenv/pyenv.git
+ dest: /opt/pyenv
+ version: '{{pyenv_version}}'
+ - name: 'Install Python {{python34_version}}'
+ command: pyenv install -s "$PYTHON34_VERSION"
+ - name: 'Install Python {{python35_version}}'
+ command: pyenv install -s "$PYTHON35_VERSION"
+ - name: 'Install Python {{python36_version}}'
+ command: pyenv install -s "$PYTHON36_VERSION"
+ - name: Set pyenv global
+ command: pyenv global system "$PYTHON36_VERSION" "$PYTHON35_VERSION" "$PYTHON34_VERSION"
+ become: true