diff --git a/tasks/load_variables.yml b/tasks/load_variables.yml index 1d5600c..4ed307f 100644 --- a/tasks/load_variables.yml +++ b/tasks/load_variables.yml @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index 3716814..6e7eb36 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 }}" @@ -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' }}" \ No newline at end of file + 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