Skip to content

Commit

Permalink
Python consistency changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tersmitten committed Mar 15, 2021
1 parent a000cd2 commit 22243a5
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MAINTAINER Mischa ter Smitten <[email protected]>
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y python-minimal python-dev curl && \
apt-get clean
RUN curl -sL https://bootstrap.pypa.io/get-pip.py | python -
RUN curl -sL https://bootstrap.pypa.io/pip/2.7/get-pip.py | python -
RUN rm -rf $HOME/.cache

# ansible
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Set up (the latest version of) virtualenv(wrapper) in Debian-like systems.

#### Variables

* `virtualenv_python_version` [default: `2`]: Python version to install `virtualenv` for.
* `virtualenv_python_version_major` [default: `2`]: Python version to install `supervisor` for.
* `virtualenv_python_version` [default: `virtualenv_python_version`]: Deprecated

## Dependencies

Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# defaults file for virtualenv
# defaults file
---
virtualenv_python_version: 2
2 changes: 1 addition & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# handlers file for virtualenv
# handlers file
---
3 changes: 2 additions & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# meta file for virtualenv
# meta file
---
galaxy_info:
namespace: oefenweb
role_name: virtualenv
author: Mischa ter Smitten
company: Oefenweb.nl B.V.
Expand Down
4 changes: 2 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# tasks file for virtualenv
# tasks file
---
- name: install dependencies
apt:
Expand All @@ -16,7 +16,7 @@
pip:
name: "{{ virtualenv_pip_dependencies }}"
state: latest
executable: "pip{{ virtualenv_python_version | string }}"
executable: "pip{{ virtualenv_python_version_major | string }}"
tags:
- configuration
- virtualenv
Expand Down
10 changes: 5 additions & 5 deletions tests/tasks/pre.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# pre test file for virtualenv
# pre test file
---
- name: pre | install dependencies
- name: install dependencies
apt:
name:
- "python{{ virtualenv_python_version is version('3', '>=') | ternary('3', '') }}"
- "python{{ virtualenv_python_version_major is version('3', '>=') | ternary('3', '') }}"
- curl
state: "{{ apt_install_state | default('latest') }}"
update_cache: true
cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}"

- name: pre | install pip
- name: install pip
shell: >
curl -sL {{ virtualenv_get_pip_url }} | python{{ virtualenv_python_version | string }} -
curl -sL {{ virtualenv_get_pip_url }} | python{{ virtualenv_python_version_major | string }} -
args:
warn: false
changed_when: false
Expand Down
10 changes: 8 additions & 2 deletions tests/test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# test file for virtualenv
# test file
---
- hosts: localhost
connection: local
become: true
pre_tasks:
- name: include variables
include_vars: "{{ item }}"
with_first_found:
- "{{ playbook_dir }}/vars/_{{ ansible_distribution_release }}.yml"
- "{{ playbook_dir }}/vars/_{{ ansible_distribution | lower }}.yml"
- "{{ playbook_dir }}/vars/_default.yml"
- name: include tasks
include: "{{ playbook_dir }}/tasks/pre.yml"
roles:
- ../../
# vars:
# virtualenv_python_version: 3
# virtualenv_python_version_major: 3
8 changes: 7 additions & 1 deletion tests/vagrant.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# test file for virtualenv
# test file
---
- hosts: all
remote_user: vagrant
become: true
pre_tasks:
- name: include variables
include_vars: "{{ item }}"
with_first_found:
- "{{ playbook_dir }}/vars/_{{ ansible_distribution_release }}.yml"
- "{{ playbook_dir }}/vars/_{{ ansible_distribution | lower }}.yml"
- "{{ playbook_dir }}/vars/_default.yml"
- name: include tasks
include: "{{ playbook_dir }}/tasks/pre.yml"
roles:
Expand Down
6 changes: 3 additions & 3 deletions tests/vars/_default.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# vars file for virtualenv
# vars file
---
virtualenv_python_version: 3
virtualenv_get_pip_url: 'https://bootstrap.pypa.io/get-pip.py'
virtualenv_python_version_major: 3
virtualenv_get_pip_url: 'https://bootstrap.pypa.io/pip/get-pip.py'
6 changes: 3 additions & 3 deletions tests/vars/_jessie.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# vars file for virtualenv
# vars file
---
virtualenv_python_version: 2
virtualenv_get_pip_url: 'https://bootstrap.pypa.io/2.7/get-pip.py'
virtualenv_python_version_major: 2
virtualenv_get_pip_url: 'https://bootstrap.pypa.io/pip/2.7/get-pip.py'
6 changes: 3 additions & 3 deletions tests/vars/_stretch.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# vars file for virtualenv
# vars file
---
virtualenv_python_version: 2
virtualenv_get_pip_url: 'https://bootstrap.pypa.io/2.7/get-pip.py'
virtualenv_python_version_major: 2
virtualenv_get_pip_url: 'https://bootstrap.pypa.io/pip/2.7/get-pip.py'
6 changes: 3 additions & 3 deletions tests/vars/_xenial.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# vars file for pip
# vars file
---
virtualenv_python_version: 3
virtualenv_get_pip_url: 'https://bootstrap.pypa.io/3.5/get-pip.py'
virtualenv_python_version_major: 3
virtualenv_get_pip_url: 'https://bootstrap.pypa.io/pip/3.5/get-pip.py'
4 changes: 2 additions & 2 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# vars file for virtualenv
# vars file
---
virtualenv_dependencies:
- "python{{ virtualenv_python_version is version('3', '>=') | ternary('3', '') }}"
- "python{{ virtualenv_python_version_major is version('3', '>=') | ternary('3', '') }}"

virtualenv_pip_dependencies:
- virtualenv
Expand Down

0 comments on commit 22243a5

Please sign in to comment.