Skip to content

Commit

Permalink
add python 2.7.8 example
Browse files Browse the repository at this point in the history
  • Loading branch information
denglei committed Sep 4, 2014
1 parent 3cb192f commit 6d4d635
Show file tree
Hide file tree
Showing 16 changed files with 104 additions and 0 deletions.
1 change: 1 addition & 0 deletions python_install_2.7.8/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
本文介绍使用ansible的playbook功能在centos或者redhat 6系列系统里安装2.7.8的python.
6 changes: 6 additions & 0 deletions python_install_2.7.8/python_delete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- hosts: "{{host}}"
remote_user: "{{user}}"
gather_facts: True
roles:
- python_delete
7 changes: 7 additions & 0 deletions python_install_2.7.8/python_install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- hosts: "{{host}}"
remote_user: "{{user}}"
gather_facts: True
roles:
- common
- python_install
2 changes: 2 additions & 0 deletions python_install_2.7.8/roles/common/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: restart ntpd
service: name=ntpd state=restarted
16 changes: 16 additions & 0 deletions python_install_2.7.8/roles/common/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
galaxy_info:
author: Deng Lei
description: Install initializtion Software
license: MIT
min_ansible_version: 1.6
platforms:
- name: CentOS
versions:
- 5
- 6
- name: Ubuntu
versions:
- precise
categories:
- system
dependencies: []
3 changes: 3 additions & 0 deletions python_install_2.7.8/roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- name: Install initializtion require software
shell: yum -y install make cmake bc gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel nss_ldap openldap openldap-devel openldap-clients openldap-servers libxslt-devel libevent-devel ntp libtool-ltdl bison libtool vim-enhanced tar wget readline-devel libyaml-devel patch telnet dmidecode
poll: 0
12 changes: 12 additions & 0 deletions python_install_2.7.8/roles/python_delete/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
galaxy_info:
author: Deng Lei
description: Delete Python
license: MIT
min_ansible_version: 1.6
platforms:
- name: CentOS
versions:
- 6
categories:
- Service
dependencies: []
11 changes: 11 additions & 0 deletions python_install_2.7.8/roles/python_delete/tasks/delete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- name: Delete Python Install Dir In RedHat Client
shell: rm -rf {{ python_dir}}/ruby-{{ python_version }}
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
- name: Recovery Old Python Soft Link Script
shell: mv -f /usr/bin/{{ item }}_back /usr/bin/{{ item }}
with_items:
- python
- easy_install
- pip
ignore_errors: yes
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
1 change: 1 addition & 0 deletions python_install_2.7.8/roles/python_delete/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- include: delete.yml
2 changes: 2 additions & 0 deletions python_install_2.7.8/roles/python_delete/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python_version: 2.7.8
python_dir: /usr/local
Binary file not shown.
12 changes: 12 additions & 0 deletions python_install_2.7.8/roles/python_install/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
galaxy_info:
author: Deng Lei
description: Install Python
license: MIT
min_ansible_version: 1.6
platforms:
- name: CentOS
versions:
- 6
categories:
- Service
dependencies: []
3 changes: 3 additions & 0 deletions python_install_2.7.8/roles/python_install/tasks/delete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- name: Delete Python compression Software In Redhat Client
shell: rm -rf /tmp/python-{{ python_version }}.tar.gz
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
24 changes: 24 additions & 0 deletions python_install_2.7.8/roles/python_install/tasks/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- name: Copy Python Software To Redhat Client
copy: src=python-{{ python_version }}.tar.gz dest=/tmp/python-{{ python_version }}.tar.gz owner=root group=root
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
- name: Uncompression Python Software To Redhat Client
shell: tar zxf /tmp/python-{{ python_version }}.tar.gz -C {{ python_dir }}
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
- name: Delete Python Software Variable In Redhat Client
shell: cp -a -f /usr/bin/{{ item }} /usr/bin/{{ item }}_back
with_items:
- python
- easy_install
- pip
ignore_errors: yes
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
- name: Copy Python Variables To Redhat Client
shell: ln -s -f {{ python_dir }}/python-{{ python_version }}/bin/{{ item }} /usr/bin/{{ item }}
with_items:
- python
- easy_install
- pip
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
- name: Modify Yum Variables To Redhat Client
shell: sed -i 's@#!/usr/bin/python.*@#!/usr/bin/python{{ ansible_python_version[:-2] }}@' /usr/bin/yum
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
2 changes: 2 additions & 0 deletions python_install_2.7.8/roles/python_install/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- include: install.yml
- include: delete.yml
2 changes: 2 additions & 0 deletions python_install_2.7.8/roles/python_install/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python_version: 2.7.8
python_dir: /usr/local

0 comments on commit 6d4d635

Please sign in to comment.