Build a python environment with ansible on centos6

Build a python environment with ansible on centos6

note) How to put ansible in your pyenv __ not __. __ How to create a pyenv environment from your ansible to another centos server __.

The default python environment for centos6 was 2.6, so I tried to put my favorite version with pyenv in ansible-playbook.

python It's a little annoying to put in the package yum required for build. There are some extras, though.

I tested it with vagrant, so user: vagrant You can rewrite the place as appropriate to a user with sudo authority and execute it.

python.yml


---
- hosts: servers
  user: vagrant

  vars:
    python_version: 2.7.6

  tasks:
  - name: install basic pkg
    yum: name={{item}} state=installed
    sudo: yes
    with_items:
    - vim
    - git
    - rsync

  - name: install build python package
    sudo: yes
    yum: name={{item}} state=installed
    with_items:
    - gcc
    - gcc-c++
    - patch
    - readline-devel
    - zlib-devel
    - openssl-devel
    ## for lxml
    - libxml2-devel
    - libxslt-devel
    ## for file copy
    - libselinux-python

  - name: install pyenv
    args:
      ## guard for only once.
      creates: ~/.pyenv
    shell: |
      git clone https://github.com/yyuu/pyenv.git ~/.pyenv
      ## add pyenv env
      (
          echo 'export PYENV_ROOT=~/.pyenv'
          echo 'export PATH=$PYENV_ROOT/bin:$PATH'
          echo 'eval "$(pyenv init -)"'
      ) >> ~/.bashrc
      source ~/.bashrc
      # install python
      pyenv install {{python_version}}
      pyenv rehash
      pyenv global {{python_version}}

  - name: pip install pkgs
    pip: name={{item}}
    with_items:
    - flask
    - lxml
    - uwsgi

Recommended Posts

Build a python environment with ansible on centos6
Build a python3 environment on CentOS7
Create a python environment on centos
Build a python environment on MacOS (Catallina)
A memo with Python2.7 and Python3 on CentOS
Build Python environment with Anaconda on Mac
Build a python virtual environment with pyenv
Build a Python + OpenCV environment on Cloud9
Build a modern Python environment with Neovim
Build a python environment on CentOS 7.7 for your home server
Build a 64-bit Python 2.7 environment with TDM-GCC and MinGW-w64 on Windows 7
Build a Python environment on your Mac with Anaconda and PyCharm
Build a WardPress environment on AWS with pulumi
Build python environment with pyenv on EC2 (ubuntu)
Simply build a Python 3 execution environment on Windows
Build a Python environment on Mac (Mountain Lion)
[Ansible] Install dnf on Centos7 with Python3 interpreter
[Python] Build a Django development environment with Docker
Create a python3 build environment with Sublime Text3
Build a Python development environment on your Mac
Build a Python environment with OSX El capitan
Quickly build a Python Django environment with IntelliJ
Build a Python machine learning environment with a container
Build a Python development environment on Raspberry Pi
Build a python execution environment with VS Code
Build a LAMP environment [CentOS 7]
Build python3 environment with ubuntu 16.04
Build Python environment on Windows
Build python environment with direnv
Build python environment on windows
Build a Python environment offline
Build a Python + bottle + MySQL environment with Docker on RaspberryPi3! [Easy construction]
# 2 Build a Python environment on AWS EC2 instance (ubuntu18.04)
Build a python virtual environment with virtualenv and virtualenvwrapper
Build a machine learning Python environment on Mac OS
Build a python environment for each directory with pyenv-virtualenv
Create a python development environment with vagrant + ansible + fabric
I made a Python3 environment on Ubuntu with direnv.
Build a GVim-based Python development environment on Windows 10 (1) Installation
How to build a Django (python) environment on docker
Build a Python development environment on Mac OS X
Build a Python environment on your Mac using pyenv
Build a machine learning application development environment with Python
Build a python virtual environment with virtualenv and virtualenvwrapper
Build a Python development environment using pyenv on MacOS
How to build a Python environment on amazon linux 2
Building a kubernetes environment with ansible 2
Building a Python environment on Mac
Building a Python environment on Ubuntu
Create a Python environment on Mac (2017/4)
Build Mysql + Python environment with docker
Build a Python + bottle + MySQL environment with Docker on RaspberryPi3! [Trial and error]
Create a virtual environment with Python!
Building a virtual environment with Python 3
Set up Python environment on CentOS
Python3 environment construction with pyenv-virtualenv (CentOS 7.3)
Build Python 3.8 + Pipenv environment on Ubuntu 18.04
Building a kubernetes environment with ansible 1
Build a python machine learning study environment on macOS sierra
How to build a new python virtual environment on Ubuntu
Build a python data analysis environment on Mac (El Capitan)