Skip to content

Commit

Permalink
Add Python 3.6+ check for NetBox 2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
lae committed May 2, 2020
1 parent ebcf10e commit 83e3a40
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tasks/load_variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
_path: "{{ _path_exec.stdout }}"
check_mode: false

- name: Capture Default Python Interpreter
- name: Capture the current Python interpreter
set_fact:
_netbox_global_python: "{{ ansible_python_interpreter }}"
when: ansible_python_interpreter is defined
25 changes: 23 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@
set_fact:
ansible_python_interpreter: "{{ netbox_python_binary }}"

- name: Recheck new Python interpreter's version
setup:
gather_subset: min
filter: ansible_python_version

# Can't quite check the effective version of a git installation this early since
# the repo isn't checked out, but most users will be on develop in the first
# place so this dumb check should be good enough.
- name: Ensure the installed Python version is newer than 3.6.0 for NetBox 2.8+
assert:
that:
- "ansible_python_version | version_compare('3.6.0', '>=')"
msg: "NetBox 2.8.0+ requires Python 3.6+. Please either specify an older NetBox version or upgrade to a newer distribution that provides Python 3.6+."
when:
- (netbox_stable and netbox_stable_version | version_compare('2.8.0', '>=') or netbox_git

- name: Create NetBox user group
group:
name: "{{ netbox_group }}"
Expand Down Expand Up @@ -101,6 +117,11 @@
state: started
enabled: yes

- name: Restore Default Python Interpreter
- name: Restore the previous Ansible Python interpreter
set_fact:
ansible_python_interpreter: "{{ _netbox_global_python if _netbox_global_python is defined else 'auto_legacy' }}"
ansible_python_interpreter: "{{ _netbox_global_python if _netbox_global_python is defined else 'auto_legacy' }}"

- name: Recheck the previous Python interpreter's version
setup:
gather_subset: min
filter: ansible_python_version

0 comments on commit 83e3a40

Please sign in to comment.