CentOS6 python version 2.6.6? Then, the module installed by pip There were some things that didn't work, so install pyenv and upgrade the python version. I created an Ansible playbook for CentOS6. Click here for rbenv http://qiita.com/tbuchi888/items/fd2e8d7e1790d398b281
Do the following as root for CentOS6
gits will be here.
git clone https://gist.github.com/tbuchi888/03f2dccdd7726770cb0522260141ca41
site.yml
---
- include: install_pyenv_without_proxy.yml
The version of python is specified in vars: python_ver: 2.7.8
of the playbook below, so please change it as appropriate.
install_pyenv_without_proxy.yml
---
- hosts: all
gather_facts: no
become: yes
vars:
python_ver: 2.7.8
tasks:
- name: which pyenv
shell: source ~/.bash_profile; which pyenv
register: pyenv_install
failed_when: pyenv_install.rc == 0
- debug: var=pyenv_install
- block:
- debug: msg="---------- block start ----------"
- name: yum install with_items
yum:
name: '{{ item.name }}'
state: latest
register: RESULT
with_items:
- name: gcc
- name: gcc-c++
- name: make
- name: git
- name: openssl-devel
- name: bzip2-devel
- name: zlib-devel
- name: readline-devel
- name: sqlite-devel
- name: bzip2
- name: sqlite
- name: patch
- name: results
debug: var=RESULT.results
- name: git clone pyenv , pyenv-virtualenv
git:
repo: '{{ item.repo }}'
dest: '{{ item.dest }}'
register: RESULT
with_items:
- repo: git://github.com/yyuu/pyenv.git
dest: ~/.pyenv
- repo: git://github.com/yyuu/pyenv-virtualenv.git
dest: ~/.pyenv/plugins/pyenv-virtualenv
- name: results
debug: var=RESULT.results
- name: "install pyenv and python ver.{{ python_ver }}"
shell: '{{ item.cmd }}'
register: RESULT
with_items:
- cmd: echo 'export PYENV_ROOT="${HOME}/.pyenv"' >> ~/.bash_profile
- cmd: echo 'if [ -d "${PYENV_ROOT}" ]; then' >> ~/.bash_profile
- cmd: echo ' export PATH=${PYENV_ROOT}/bin:$PATH' >> ~/.bash_profile
- cmd: echo ' eval "$(pyenv init -)"' >> ~/.bash_profile
- cmd: echo 'fi' >> ~/.bash_profile
- cmd: source ~/.bash_profile; pyenv -v
- cmd: source ~/.bash_profile; python -V
- cmd: source ~/.bash_profile; pyenv install '{{ python_ver }}'
- cmd: source ~/.bash_profile; pyenv global '{{ python_ver }}'
- cmd: source ~/.bash_profile; python -V
- name: results
debug: var=RESULT.results
- debug: msg="---------- block end ----------"
when: pyenv_install.rc == 1
The following is for Vagrant environment
The following is vagrant up
to start the Server of CentOS 6 and build the pyenv environment using Ansible provisoner.
For the box file name, replace it with the box file name of CentOS 6 in your environment. Especially in the case of a 32-bit machine environment, please replace it with the box file name of your own 32-bit version CentOS6.
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
# Please replace it with a BOX name of CentOS6 for one's own 32bit when your host is 32bit machine.
config.vm.box = "geerlingguy/centos6"
# Add ansible provisioner
config.vm.provision "ansible" do |ansible|
ansible.playbook = "site.yml"
end
end
-In the case of Vagrant environment where Ansible provisoner can be used on OSX etc.
-Please prepare the above playbook and other materials before vagrant up
.
-For Ansible environment only
-Prepare your own inventory host file and run the playbook on the CentOS 6 server. ʻAnsible-playbook -i inventory file site.yml`
Ansible provisioner and Vagrant,Virtulbox Host - OS:OSX yosemite --Virtualbox: version 5.0.10 r104061 - Vagrant: Vagrant 1.8.1 - Ansible:
$ansible --version
ansible 2.1.0 (devel c600ab81ee) last updated 2016/04/20 11:11:25 (GMT +900)
lib/ansible/modules/core: (detached HEAD 98322a777f) last updated 2016/04/20 11:11:54 (GMT +900)
lib/ansible/modules/extras: (detached HEAD 1aecfc1e19) last updated 2016/04/20 11:11:55 (GMT +900)
config file =
configured module search path = Default w/o overrides
pyenv install Server - OS: CentOS6.8
Recommended Posts