Skip to content

Commit 688a620

Browse files
committed
Merge pull request #5 from ninthnails/master
Rewrite and RedHat support
2 parents 3ae7e5b + ffdf5fe commit 688a620

File tree

9 files changed

+129
-19
lines changed

9 files changed

+129
-19
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.vagrant
2+

.travis.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
language: python
3+
python: "2.7"
4+
5+
env:
6+
- PYTHONVERSION: 3.5.0
7+
- PYTHONVERSION: 3.3.3
8+
- PYTHONVERSION: 2.7.10
9+
10+
before_install:
11+
- sudo apt-get update -qq
12+
- sudo apt-get install curl -y
13+
14+
install:
15+
- pip install -U ansible
16+
17+
# Add ansible.cfg to pick up roles path.
18+
- "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg"
19+
20+
script:
21+
# Check the role/playbook's syntax.
22+
- "ansible-playbook -i ci/inventory ci/playbook.yml --syntax-check"
23+
24+
# Run the ansible ci playbook
25+
- "ansible-playbook -i ci/inventory ci/playbook.yml --connection=local --sudo -vvvv -e python_version=$PYTHONVERSION -e 'python_path=/usr/local/python/{{ python_version }}'"
26+

Vagrantfile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
Vagrant.configure("2") do |config|
5+
config.ssh.forward_agent = true
6+
config.vm.synced_folder Dir.getwd, "/home/vagrant/roles/ansible-python", nfs: true
7+
8+
# ubuntu 12.04 that Travis CI is using
9+
config.vm.define 'travis', primary: true do |c|
10+
c.vm.network "private_network", ip: "192.168.100.2"
11+
c.vm.box = "precise-server-cloudimg-amd64-vagrant-disk1"
12+
c.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box"
13+
c.vm.provision "shell" do |s|
14+
s.inline = "apt-get update -y; apt-get install python-software-properties; add-apt-repository ppa:rquillo/ansible; apt-get update -y; apt-get install ansible -y"
15+
s.privileged = true
16+
end
17+
end
18+
19+
# ubuntu 14.04 Trusty
20+
config.vm.define 'ubuntu', primary: true do |c|
21+
c.vm.network "private_network", ip: "192.168.100.3"
22+
c.vm.box = "trusty-server-cloudimg-amd64-vagrant-disk1"
23+
c.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
24+
c.vm.provision "shell" do |s|
25+
s.inline = "apt-get update -y; apt-get install -y software-properties-common; apt-add-repository ppa:ansible/ansible; apt-get update -y; apt-get install -y ansible"
26+
s.privileged = true
27+
end
28+
end
29+
30+
# centos 6:
31+
config.vm.define 'centos' do |c|
32+
c.vm.network "private_network", ip: "192.168.100.4"
33+
c.vm.box = "centos65-x86_64-20140116"
34+
c.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box"
35+
c.vm.provision "shell" do |s|
36+
s.inline = "yum update gmp; yum install ansible -y"
37+
s.privileged = true
38+
end
39+
end
40+
41+
# centos 7:
42+
config.vm.define 'centos7' do |c|
43+
c.vm.network "private_network", ip: "192.168.100.5"
44+
c.vm.box = "centos/7"
45+
c.vm.provision "shell" do |s|
46+
s.inline = "yum install -y epel-release; yum install -y ansible"
47+
s.privileged = true
48+
end
49+
end
50+
51+
end

ci/inventory

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[local]
2+
localhost

ci/playbook.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
3+
- name: Test Playbook
4+
hosts: localhost
5+
connection: local
6+
sudo: yes
7+
8+
roles:
9+
- { role: ../../ }
10+
11+
tasks:
12+
- name: Verify python version
13+
command: "{{ python_path }}/bin/python{{ python_base_version }} --version"
14+
register: command_result
15+
failed_when: command_result.stderr != 'Python {{ python_version }}' and command_result.stdout != 'Python {{ python_version }}'
16+

defaults/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
python_version: '3.3.3'
3+
python_base_version: "{{ python_version.split('.')[0:2] | join('.') }}"
4+
python_file_tag: "Python-{{ python_version }}"
5+
python_file_name: "{{ python_file_tag }}.tgz"
6+
python_base_url: http://www.python.org/ftp/python
7+
python_package_url: "{{ python_base_url }}/{{ python_version }}/{{ python_file_name }}"
8+
python_path: /usr/local
9+

tasks/RedHat.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
- name: Install os packages
3+
yum: name={{ [
4+
'"@Development tools"',
5+
'zlib-devel',
6+
'bzip2-devel',
7+
'openssl-devel',
8+
'ncurses-devel',
9+
'sqlite-devel'
10+
] | join(',') }} state=present
11+

tasks/main.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
---
22
- include: Debian.yml
33
when: ansible_os_family == "Debian"
4+
5+
- include: RedHat.yml
6+
when: ansible_os_family == "RedHat"
47

5-
- name: Check if Python {{python_version}} is installed
6-
shell: "{{python_path}}/bin/python{{python_version[:-2]}} --version"
7-
register: command_result
8-
ignore_errors: True
8+
- name: Create folder(s)
9+
file: path=/opt/src state=directory owner=root group=root mode=0755
910

10-
- name: Download python {{python_version}}
11-
get_url: url={{python_base_url}} dest=/tmp/{{python_file_name}}
12-
when: "'not found' in command_result.stderr"
11+
- name: 'Download python {{ python_version }}'
12+
get_url: url={{ python_package_url }} dest=/opt/src/{{ python_file_name }}
1313

14-
- name: Unpack python {{python_version}}
15-
command: tar -xvzf {{python_file_name}} chdir=/tmp
16-
when: "'not found' in command_result.stderr"
14+
- name: 'Unpack python {{ python_version }}'
15+
command: tar -xzf {{ python_file_name }} chdir=/opt/src creates=/opt/src/{{ python_file_tag }}
1716

18-
- name: Compile and install python {{python_version}}
19-
shell: ./configure --prefix={{python_path}}/ && make && make altinstall chdir=/tmp/{{python_file_tag}}
17+
- name: 'Compile and install python {{ python_version }}'
18+
shell: ./configure --prefix={{ python_path }}/ && make && make altinstall chdir=/opt/src/{{ python_file_tag }} creates={{ python_path }}/bin/python{{ python_base_version }}
2019
sudo: true
21-
when: "'not found' in command_result.stderr"

vars/main.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
11
---
2-
python_playbook_version: "0.1.0"
3-
python_version: "3.3.3"
4-
python_file_tag: "Python-{{python_version}}"
5-
python_file_name: "{{python_file_tag}}.tgz"
6-
python_base_url: "http://www.python.org/ftp/python/{{python_version}}/{{python_file_name}}"
7-
python_path: "/usr/local"
2+
python_playbook_version: "0.2.0"

0 commit comments

Comments
 (0)