Skip to content

Commit dd53d55

Browse files
committedMar 8, 2023
refactor: ...
1 parent b3d14ac commit dd53d55

File tree

11 files changed

+95
-42
lines changed

11 files changed

+95
-42
lines changed
 

Diff for: ‎.yamllint

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
# Based on ansible-lint config
3+
extends: default
4+
5+
rules:
6+
braces:
7+
max-spaces-inside: 1
8+
level: error
9+
brackets:
10+
max-spaces-inside: 1
11+
level: error
12+
colons:
13+
max-spaces-after: -1
14+
level: error
15+
commas:
16+
max-spaces-after: -1
17+
level: error
18+
comments: disable
19+
comments-indentation: disable
20+
document-start: disable
21+
empty-lines:
22+
max: 3
23+
level: error
24+
hyphens:
25+
level: error
26+
indentation: disable
27+
key-duplicates: enable
28+
line-length: disable
29+
new-line-at-end-of-file: disable
30+
new-lines:
31+
type: unix
32+
trailing-spaces: disable
33+
truthy: disable

Diff for: ‎Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ install: clean
88
clean:
99
rm -fr $(install_dir)
1010

11+
12+
test:
13+
cd tests && ansible-playbook test.yml

Diff for: ‎defaults/main.yml

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
# defaults file for python
3-
version: 3.6.4
2+
# version and path
3+
version: 3.6.8
44
version_short: "{{ version.split('.')[0] }}.{{ version.split('.')[1] }}"
55
python_dir: /usr/local/opt/python{{ version }}
6-
python_exe: "{{ python_dir }}/bin/python{{ version_short }}"
7-
pip_exe: "{{ python_dir }}/bin/pip{{ version_short }}"
6+
python_bin: "{{ python_dir }}/bin/python{{ version_short }}"
7+
pip_bin: "{{ python_dir }}/bin/pip{{ version_short }}"
88

99
checksum: null
1010
checksum_expect: "{{ checksum | default(checksum_defaults[version]) }}"
@@ -15,17 +15,22 @@ link: true
1515
python_link: "/usr/local/bin/python{{ version_short }}"
1616
pip_link: "/usr/local/bin/pip{{ version_short }}"
1717

18-
# source config
19-
source_url: https://www.python.org/ftp/python/{{ version }}/Python-{{ version }}.tar.xz
20-
source_tar: /usr/local/src/Python-{{ version }}.tar.xz
18+
# pythn source
19+
python_source_url_default: https://www.python.org/ftp/python/{{ version }}/Python-{{ version }}.tar.xz
20+
python_source_url: null
21+
python_source_local: /usr/local/src/Python-{{ version }}.tar.xz
2122

2223
checksum_defaults:
2324
# python3.11
2425
3.11.2: a957cffb58a89303b62124896881950b
2526

2627
# python3.10
2728
3.10.10: 7bf85df71bbe7f95e5370b983e6ae684
28-
29+
30+
3.9.7: md5:fddb060b483bc01850a3f412eea1d954
31+
3.8.12: md5:9dd8f82e586b776383c82e27923f8795
32+
3.7.12: md5:352ea082224121a8b7bc4d6d06e5de39
33+
2934
# python3.6
3035
3.6.5: md5:9f49654a4d6f733ff3284ab9d227e9fd
3136
3.6.4: md5:1325134dd525b4a2c3272a1a0214dd54

Diff for: ‎tasks/install-pip.yml

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,2 @@
1-
- name: Download get-pip.py
2-
get_url:
3-
url: https://bootstrap.pypa.io/get-pip.py
4-
dest: /usr/local/src/get-pip.py
5-
validate_certs: no
6-
tags:
7-
- download
8-
9-
10-
- name: Execute get-pip.py
11-
shell: "{{ python_exe }} /usr/local/src/get-pip.py"
1+
- name: Upgrade pip
2+
shell: "{{ python_bin }} -m pip install -U pip"

Diff for: ‎tasks/install-python.yml

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
11
---
2-
- name: Download source of python-{{ version }} from {{ source_url }} to {{ source_tar }}
2+
- name: Download python-{{ version }} source from {{ python_source_url }} to {{ python_source_local }}
33
get_url:
4-
url: "{{ source_url }}"
5-
dest: "{{ source_tar }}"
4+
url: "{{ python_source_url | default(python_source_url_default, true) }}"
5+
dest: "{{ python_source_local }}"
66
validate_certs: no
77
checksum: "{{ checksum_expect }}"
88
tags:
99
- download
1010

1111

12-
- name: Extract source from {{ source_tar }} to /usr/local/src/
12+
- name: Extract source from {{ python_source_local }} to /usr/local/src/
1313
unarchive:
14-
src: "{{ source_tar }}"
14+
src: "{{ python_source_local }}"
1515
dest: /usr/local/src/
1616
remote_src: True
1717

1818

19+
- name: Install requirements for python-{{ version }}
20+
dnf:
21+
name: "{{ item }}"
22+
state: present
23+
loop:
24+
- "{{ require_packages[ansible_os_family] }}"
25+
when: ansible_distribution == 'Alibaba'
26+
27+
1928
- name: Install requirements for python-{{ version }}
2029
package:
2130
name: "{{ item }}"
2231
state: present
23-
with_items:
32+
loop:
2433
- "{{ require_packages[ansible_os_family] }}"
34+
when: ansible_distribution != 'Alibaba'
2535

2636

2737
- name: Compile and install python{{ version }}

Diff for: ‎tasks/link.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
- name: Link to {{ python_link }}. force ? {{ 'yes' if reinstall else 'no' }}
33
file:
4-
src: "{{ python_exe }}"
4+
src: "{{ python_bin }}"
55
dest: "{{ python_link }}"
66
state: link
77
force: "{{ 'yes' if reinstall else 'no' }}"
@@ -12,7 +12,7 @@
1212

1313
- name: Link to {{ pip_link }}. force ? {{ 'yes' if reinstall else 'no' }}
1414
file:
15-
src: "{{ pip_exe }}"
15+
src: "{{ pip_bin }}"
1616
dest: "{{ pip_link }}"
1717
state: link
1818
force: "{{ 'yes' if reinstall else 'no' }}"

Diff for: ‎tasks/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
- name: Check status of python-{{ version }}
99
stat:
10-
path: "{{ python_exe }}"
10+
path: "{{ python_bin }}"
1111
register: python
1212
tags:
1313
- link
@@ -16,7 +16,7 @@
1616

1717
- name: Check status of pip-{{ version }}
1818
stat:
19-
path: "{{ pip_exe }}"
19+
path: "{{ pip_bin }}"
2020
register: pip
2121
tags:
2222
- link

Diff for: ‎tests/inventory

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
[localtest]
2-
127.0.0.1 ansible_user=vagrant ansible_ssh_port=2222
1+
localhost ansible_connection=local
2+

Diff for: ‎tests/requirements.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- src: chrismeyersfsu.provision_docker
2+
name: provision_docker

Diff for: ‎tests/test.yml

+19-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
---
2-
3-
- name: Test install python.
4-
hosts: "{{ host }}"
5-
connection: paramiko
2+
- name: Bring up docker containers
3+
hosts: localhost
4+
gather_facts: false
5+
vars:
6+
inventory:
7+
- name: hello
8+
image: "chrismeyers/centos7"
69
roles:
7-
- { role: ../ansible-python, version: "2.7.14", checksum: "md5:1f6db41ad91d9eb0a6f0c769b8613c5b", link: false }
8-
- { role: ../ansible-python, version: "3.4.8", checksum: "md5:15c44931f2274bfe928d53e0b675a4d8", link: false }
9-
- { role: ../ansible-python, version: "3.5.5", checksum: "md5:f3763edf9824d5d3a15f5f646083b6e0", link: false }
10-
- { role: ../ansible-python, version: "3.6.5", checksum: "md5:9f49654a4d6f733ff3284ab9d227e9fd", link: false }
10+
- role: provision_docker
11+
provision_docker_inventory: "{{ inventory }}"
12+
1113

12-
# vars:
13-
# # source_url: http://127.0.0.1:8000/Python-{{ version }}.tar.xz
14+
- name: Run install python
15+
hosts: docker_containers
16+
vars:
17+
python_source_url: http://127.0.0.1:8000/Python-{{ version }}.tar.xz
18+
roles:
19+
- { role: ../../ansible-python, version: "3.10.0", checksum: "md5:3e7035d272680f80e3ce4e8eb492d580", link: false }
20+
- { role: ../../ansible-python, version: "3.9.7", checksum: "md5:fddb060b483bc01850a3f412eea1d954", link: false }
21+
- { role: ../../ansible-python, version: "3.8.12", checksum: "md5:9dd8f82e586b776383c82e27923f8795", link: false }
22+
- { role: ../../ansible-python, version: "3.7.12", checksum: "md5:352ea082224121a8b7bc4d6d06e5de39", link: false }

Diff for: ‎vars/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
# vars file for python2
3-
version: 3.6.1
3+
version: 3.6.8
44
checksum: null
55
python_dir: /usr/local/opt/python{{ version }}
66
reinstall: false

0 commit comments

Comments
 (0)
Please sign in to comment.