-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(packages): python2 libvirt library is unusable by Python3 minion
We need a mechanism to select which python library to install depending on the environment of the minion. We do not generated keys when the python library is not available for the current OS. BREAKING CHANGE: the Python2 package is now “python2_pkg”. * libvirt/python.sls: use “switch_python32” macro to select the python package and do nothing if it's not available. * libvirt/keys.sls: ditoo. * libvirt/python.jinja: new macro “switch_python32” to select one of the two arguments based on the environment of the SaltStack minion. * libvirt/defaults.yaml: distinguish python2 and python3 packages. * libvirt/osfamilymap.yaml (Debian): distinguish python2 and python3 packages.
- Loading branch information
Showing
5 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{%- macro switch_python32(python3, python2) %} | ||
{#- | ||
Returns arguments depending on the Python environment of the | ||
SaltStack minion. | ||
A `none` argument is returned as an empty string `''`. | ||
Params: | ||
* python3: the parameter to return in case of a Python3 minion. | ||
* python2: the parameter to return in case of a Python2 minion. | ||
Example: | ||
{%- set package = switch_python32('python3-library', 'python2-library') %} | ||
{%- if package %} | ||
pkg-install-{{ package }}: | ||
pkg.installed: | ||
- name: {{ package }} | ||
{%- endif %} | ||
The `package` will be `python3-library` when the SaltStack minion | ||
runs under Python3 or `python2-library` otherwise. | ||
#} | ||
{%- if salt['grains.get']('pythonversion')[0] == 3 %} | ||
{%- set selected = python3 %} | ||
{%- else %} | ||
{%- set selected = python2 %} | ||
{%- endif %} | ||
{#- Coerce null value to empty string to make tests simpler #} | ||
{%- if not selected or selected is none -%} | ||
{%- else -%} | ||
{{ selected }} | ||
{%- endif -%} | ||
{%- endmacro -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
{% from "libvirt/map.jinja" import libvirt_settings with context %} | ||
{%- from "libvirt/map.jinja" import libvirt_settings with context %} | ||
{%- from "libvirt/python.jinja" import switch_python32 with context %} | ||
{%- set package = switch_python32(libvirt_settings.python3_pkg, libvirt_settings.python2_pkg) %} | ||
{#- Some OS do not have the python3 library #} | ||
{%- if package %} | ||
libvirt-python: | ||
pkg.installed: | ||
- name: {{ libvirt_settings.python_pkg }} | ||
- name: {{ package }} | ||
{%- endif %} |