Commit bcfe5908 authored by Maciej Delmanowski's avatar Maciej Delmanowski

Merge branch 'netbox-python3' of https://github.com/tumd/debops into tumd-netbox-python3

parents 86942008 01aadd52
...@@ -39,11 +39,13 @@ ...@@ -39,11 +39,13 @@
- '{{ netbox__postgresql__dependent_pgpass }}' - '{{ netbox__postgresql__dependent_pgpass }}'
- role: debops.python - role: debops.python
tags: [ 'role::python', 'skip::python', 'role::gunicorn' ] tags: [ 'role::python', 'skip::python', 'role::gunicorn', 'role::netbox' ]
python__dependent_packages3: python__dependent_packages3:
- '{{ gunicorn__python__dependent_packages3 }}' - '{{ gunicorn__python__dependent_packages3 }}'
- '{{ netbox__python__dependent_packages3 }}'
python__dependent_packages2: python__dependent_packages2:
- '{{ gunicorn__python__dependent_packages2 }}' - '{{ gunicorn__python__dependent_packages2 }}'
- '{{ netbox__python__dependent_packages2 }}'
- role: debops.gunicorn - role: debops.gunicorn
tags: [ 'role::gunicorn', 'skip::gunicorn' ] tags: [ 'role::gunicorn', 'skip::gunicorn' ]
......
...@@ -40,17 +40,12 @@ netbox__domain: '{{ ansible_local.core.domain ...@@ -40,17 +40,12 @@ netbox__domain: '{{ ansible_local.core.domain
netbox__base_packages: netbox__base_packages:
- 'git' - 'git'
- 'build-essential' - 'build-essential'
- 'python-dev'
- 'python-pip'
- 'libxml2-dev' - 'libxml2-dev'
- 'libxslt1-dev' - 'libxslt1-dev'
- 'libffi-dev' - 'libffi-dev'
- 'graphviz' - 'graphviz'
- 'libpq-dev' - 'libpq-dev'
- 'libssl-dev' - 'libssl-dev'
- '{{ "python-virtualenv"
if (ansible_distribution_release in [ "wheezy", "precise" ])
else "virtualenv" }}'
# ]]] # ]]]
# .. envvar:: netbox__packages [[[ # .. envvar:: netbox__packages [[[
...@@ -138,7 +133,7 @@ netbox__git_repo: 'https://github.com/digitalocean/netbox.git' ...@@ -138,7 +133,7 @@ netbox__git_repo: 'https://github.com/digitalocean/netbox.git'
# .. envvar:: netbox__git_version [[[ # .. envvar:: netbox__git_version [[[
# #
# The :command:`git` branch or tag which will be installed. # The :command:`git` branch or tag which will be installed.
netbox__git_version: 'v2.4.9' netbox__git_version: 'master'
# ]]] # ]]]
# .. envvar:: netbox__git_dest [[[ # .. envvar:: netbox__git_dest [[[
...@@ -156,6 +151,17 @@ netbox__git_checkout: '{{ netbox__virtualenv + "/app" }}' ...@@ -156,6 +151,17 @@ netbox__git_checkout: '{{ netbox__virtualenv + "/app" }}'
# Python virtualenv configuration [[[ # Python virtualenv configuration [[[
# ----------------------------------- # -----------------------------------
# .. envvar:: netbox__virtualenv_version [[[
#
# Beginning with v2.5, NetBox will no longer support Python 2.
# When this is set to `3` a **new** Python 3 `virtualenv` environment will be
# created next to the old one.
# Valid values are `3` or an empty string.
netbox__virtualenv_version: '{{ ""
if netbox__git_version|replace("v", "") is version("2.5", "<")
else "3" }}'
# ]]]
# .. envvar:: netbox__virtualenv [[[ # .. envvar:: netbox__virtualenv [[[
# #
# Path where the NetBox ``virtualenv`` directory will be stored. # Path where the NetBox ``virtualenv`` directory will be stored.
...@@ -586,6 +592,22 @@ netbox__app_params: ...@@ -586,6 +592,22 @@ netbox__app_params:
# Configuration variables for other Ansible roles [[[ # Configuration variables for other Ansible roles [[[
# --------------------------------------------------- # ---------------------------------------------------
# .. envvar:: netbox__python__dependent_packages3 [[[
#
# Configuration for the :ref:`debops.python` Ansible role.
netbox__python__dependent_packages3:
- 'python3-dev'
# ]]]
# .. envvar:: netbox__python__dependent_packages2 [[[
#
# Configuration for the :ref:`debops.python` Ansible role.
netbox__python__dependent_packages2:
- 'python-dev'
# ]]]
# .. envvar:: netbox__gunicorn__dependent_applications [[[ # .. envvar:: netbox__gunicorn__dependent_applications [[[
# #
# Configuration for the :ref:`debops.gunicorn` Ansible role. # Configuration for the :ref:`debops.gunicorn` Ansible role.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
- name: Restart gunicorn for netbox - name: Restart gunicorn for netbox
service: service:
name: 'gunicorn' name: 'gunicorn@netbox'
state: 'restarted' state: 'restarted'
when: (not netbox__app_internal_appserver|bool and when: (not netbox__app_internal_appserver|bool and
ansible_local|d() and ansible_local.gunicorn|d() and ansible_local|d() and ansible_local.gunicorn|d() and
......
...@@ -38,16 +38,6 @@ ...@@ -38,16 +38,6 @@
- '{{ netbox__config_media_root }}' - '{{ netbox__config_media_root }}'
- '{{ netbox__config_reports_root }}' - '{{ netbox__config_reports_root }}'
- name: Create Python virtualenv for NetBox
pip:
name: 'wsgiref'
virtualenv: '{{ netbox__virtualenv }}'
become: True
become_user: '{{ netbox__user }}'
register: netbox__register_virtualenv
changed_when: (netbox__register_virtualenv is success and
netbox__register_virtualenv.stdout is search('New python executable in'))
- name: Clone NetBox source code - name: Clone NetBox source code
git: git:
repo: '{{ netbox__git_repo }}' repo: '{{ netbox__git_repo }}'
...@@ -64,6 +54,19 @@ ...@@ -64,6 +54,19 @@
path: '{{ netbox__git_checkout }}' path: '{{ netbox__git_checkout }}'
register: netbox__register_installed register: netbox__register_installed
- name: Check current virtualenv version
stat:
path: '{{ netbox__virtualenv + "/bin/python" }}'
register: netbox__register_virtualenv_version
- name: Remove old python2 based virtualenv
file:
path: '{{ netbox__virtualenv }}'
state: 'absent'
register: netbox__register_virtalenv_deleted
when: ( netbox__virtualenv_version == '3' and
netbox__register_virtualenv_version.stat.lnk_target|d() == 'python2' )
- name: Create NetBox checkout directory - name: Create NetBox checkout directory
file: file:
path: '{{ netbox__git_checkout }}' path: '{{ netbox__git_checkout }}'
...@@ -108,21 +111,22 @@ ...@@ -108,21 +111,22 @@
when: (netbox__register_source.before is undefined or when: (netbox__register_source.before is undefined or
(netbox__register_source.before|d() and netbox__register_target_branch.stdout|d() and (netbox__register_source.before|d() and netbox__register_target_branch.stdout|d() and
netbox__register_source.before != netbox__register_target_branch.stdout) or netbox__register_source.before != netbox__register_target_branch.stdout) or
not netbox__register_installed.stat.exists|bool) not netbox__register_installed.stat.exists|bool or
netbox__register_virtalenv_deleted.changed|bool)
# This is required due to an issue with setuptools - name: Create Python virtualenv for NetBox
# https://github.com/digitalocean/netbox/issues/864 pip:
- name: Upgrade pip and setuptools in the virtualenv name: [ 'pip', 'setuptools' ]
environment: virtualenv: '{{ netbox__virtualenv }}'
VIRTUAL_ENV: '{{ netbox__virtualenv }}' virtualenv_python: '{{ "python" + netbox__virtualenv_version }}'
PATH: '{{ netbox__virtualenv_env_path }}' # This is required due to an issue with setuptools
shell: pip install --upgrade --force-reinstall pip setuptools # https://github.com/digitalocean/netbox/issues/864
args: state: 'forcereinstall'
chdir: '{{ netbox__git_checkout + "/netbox" }}'
executable: '/bin/sh'
become: True become: True
become_user: '{{ netbox__user }}' become_user: '{{ netbox__user }}'
when: netbox__register_checkout is changed register: netbox__register_virtualenv
changed_when: (netbox__register_virtualenv is success and
netbox__register_virtualenv.stdout is search('New python executable in'))
- name: Clean up stale Python bytecode - name: Clean up stale Python bytecode
shell: find . -name '*.pyc' -delete shell: find . -name '*.pyc' -delete
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment