Skip to content

Commit

Permalink
[feature] Added support for Ubuntu 20.04 #189
Browse files Browse the repository at this point in the history
- switched to use /usr/bin/python3 by default
- python-virtualenv > python3-virtualenv
- build in travis using ubuntu 20.04
- add ubuntu 20.04 (focal) to meta info
- handle redis 4/5 and dependencies
- removed step to install python-wheel (installed by pip later)
- simplified python3-virtualenv installation
- pin channels_redis to 2.4 for redis 4 compatibility

Closes #189
  • Loading branch information
PabloCastellano committed Sep 19, 2020
1 parent a0e8d1d commit ea8ad58
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 42 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -10,6 +10,7 @@ env:
- ROLE_NAME: openwisp2
jobs:
- MOLECULE_DISTRO: ubuntu1804
- MOLECULE_DISTRO: ubuntu2004
- MOLECULE_DISTRO: debian10

notifications:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -241,6 +241,8 @@ From here on you can follow the instructions available at the following sections

**Note:** Please remember to [install ansible](#install-ansible).

**ProTip:** Use `molecule test --destroy=never` to speed up between each run.

All done!

How to run tests
Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
@@ -1,4 +1,5 @@
openwisp2_python: python3
ansible_python_interpreter: /usr/bin/python3
openwisp2_network_topology: false
openwisp2_controller_version: "0.7.post1"
openwisp2_network_topology_version: "0.4"
Expand Down
1 change: 1 addition & 0 deletions meta/main.yml
Expand Up @@ -27,6 +27,7 @@ galaxy_info:
# https://github.com/openwisp/ansible-openwisp2/issues/169#issuecomment-592983139
# - xenial
- bionic
- focal
# we don't have the resources now to maintain these distros
# - name: Fedora
# versions:
Expand Down
2 changes: 1 addition & 1 deletion molecule/default/converge.yml
Expand Up @@ -8,7 +8,7 @@
openwisp2_network_topology: true

pre_tasks:
- name: Update apt cache.
- name: Update apt cache
apt: update_cache=true cache_valid_time=600
when: ansible_os_family == 'Debian'

Expand Down
49 changes: 21 additions & 28 deletions tasks/apt.yml
Expand Up @@ -17,18 +17,33 @@
- openssl
- libssl-dev
- libffi-dev
- python-dev
- redis-server
- python3
- virtualenv
- cron
notify:
- reload systemd
- start redis
ignore_errors: yes
retries: 5
delay: 10
register: result
until: result is success

- name: Install redis 5 if available
apt:
name: "redis-server=5:5*"
notify:
- reload systemd
- start redis
ignore_errors: yes
register: use_redis5

- name: Install redis 4 (fallback)
when: use_redis5.failed
apt:
name: "redis-server=5:4*"
notify:
- reload systemd
- start redis
ignore_errors: yes

# On the newer versions of redis, by default redis
# binds to localhost on ipv6 address which wouldn't
# let the service start if the server doesn't have
Expand Down Expand Up @@ -91,33 +106,11 @@
until: result is success

- name: Install python3 packages
when: openwisp2_python == "python3"
apt:
name:
- python3
- python3-pip
- python3-dev
- python-virtualenv
retries: 5
delay: 10
register: result
until: result is success

- name: Install python wheel (optional, allowed to fail)
ignore_errors: yes
apt:
name:
- python-wheel
- python3-wheel
retries: 1
delay: 10
register: result
until: result is success

- name: Install python3-virtualenv
ignore_errors: yes
when: ansible_distribution != 'Ubuntu'
apt: name=python3-virtualenv
- python3-virtualenv
retries: 5
delay: 10
register: result
Expand Down
2 changes: 2 additions & 0 deletions tasks/django.yml
Expand Up @@ -108,6 +108,8 @@
# sets executable only to directories
mode: u=rwX,g=rX,o=rX
recurse: yes
tags:
- molecule-idempotence-notest

- name: collectstatic
notify: reload supervisor
Expand Down
2 changes: 1 addition & 1 deletion tasks/django_secret_key.yml
Expand Up @@ -5,7 +5,7 @@
mode: 0754

- name: generate new django SECRET_KEY
shell: "./generate_django_secret_key.py > .django-secret-key"
shell: "{{ virtualenv_path }}/bin/python ./generate_django_secret_key.py > .django-secret-key"
args:
chdir: "{{ openwisp2_path }}"
creates: "{{ openwisp2_path }}/.django-secret-key"
Expand Down
40 changes: 28 additions & 12 deletions tasks/pip.yml
@@ -1,3 +1,19 @@
- name: Update pip & related tools
pip:
name:
- pip
- setuptools
- wheel
- attrs
state: latest
virtualenv: "{{ virtualenv_path }}"
virtualenv_python: "{{ openwisp2_python }}"
virtualenv_site_packages: yes
retries: 5
delay: 10
register: result
until: result is success

- name: Remove jsonfield2
pip:
name:
Expand Down Expand Up @@ -36,13 +52,9 @@
- "{{ openwisp2_network_topology_pip }}"
when: item is defined and item is string and openwisp2_network_topology

- name: Update pip & related tools
- name: Install cryptography from pip
pip:
name:
- pip
- setuptools
- wheel
- attrs
name: cryptography
state: latest
virtualenv: "{{ virtualenv_path }}"
virtualenv_python: "{{ openwisp2_python }}"
Expand All @@ -52,29 +64,33 @@
register: result
until: result is success

- name: Install cryptography from pip
- name: Install openwisp2 controller and its dependencies
pip:
name: cryptography
name:
- "openwisp-controller~={{ openwisp2_controller_version }}"
- channels_redis
- service_identity
state: latest
virtualenv: "{{ virtualenv_path }}"
virtualenv_python: "{{ openwisp2_python }}"
virtualenv_site_packages: yes
notify: reload supervisor
retries: 5
delay: 10
register: result
until: result is success
tags:
- molecule-idempotence-notest

- name: Install openwisp2 controller and its dependencies
- name: Pin channels_redis to 2.4 for redis 4 compatibility
when: use_redis5.failed
pip:
name:
- "openwisp-controller~={{ openwisp2_controller_version }}"
- channels_redis~=2.4
- service_identity
state: latest
virtualenv: "{{ virtualenv_path }}"
virtualenv_python: "{{ openwisp2_python }}"
virtualenv_site_packages: yes
notify: reload supervisor
retries: 5
delay: 10
register: result
Expand Down

0 comments on commit ea8ad58

Please sign in to comment.