2018-02-12 08:16:03 -03:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: ft=sls
|
2020-01-13 05:33:14 +00:00
|
|
|
|
|
|
|
{#- Get the `tplroot` from `tpldir` #}
|
|
|
|
{%- set tplroot = tpldir.split('/')[0] %}
|
|
|
|
{%- from tplroot ~ "/map.jinja" import packages with context %}
|
2018-02-12 08:16:03 -03:00
|
|
|
|
2020-10-21 12:28:28 -03:00
|
|
|
{%- set req_states = packages.pips.required.states %}
|
|
|
|
{%- set req_pkgs = packages.pips.required.pkgs %}
|
|
|
|
{%- set wanted_pips = packages.pips.wanted %}
|
|
|
|
{%- set unwanted_pips = packages.pips.unwanted %}
|
|
|
|
{%- set pip_config = packages.pips.config %}
|
2018-02-12 08:16:03 -03:00
|
|
|
|
2020-10-21 12:28:28 -03:00
|
|
|
{%- if wanted_pips or unwanted_pips %}
|
|
|
|
|
|
|
|
{%- if req_states %}
|
2019-03-10 22:47:54 -03:00
|
|
|
include:
|
2020-10-21 12:28:28 -03:00
|
|
|
{%- for dep in req_states %}
|
2019-03-10 22:47:54 -03:00
|
|
|
- {{ dep }}
|
2020-10-21 12:28:28 -03:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2019-03-10 22:47:54 -03:00
|
|
|
|
2018-02-12 08:16:03 -03:00
|
|
|
### REQ PKGS (without these, some of the WANTED PIPS will fail to install)
|
|
|
|
pip_req_pkgs:
|
|
|
|
pkg.installed:
|
2019-03-05 20:12:25 -03:00
|
|
|
- pkgs: {{ req_pkgs | json }}
|
2018-02-12 08:16:03 -03:00
|
|
|
|
2020-10-21 12:28:28 -03:00
|
|
|
{%- if pip_config %}
|
2019-02-13 17:52:49 +01:00
|
|
|
pip_config:
|
|
|
|
file.managed:
|
|
|
|
- name: /etc/pip.conf
|
2020-01-13 05:33:14 +00:00
|
|
|
- source: salt://{{ tplroot }}/files/pip.conf
|
2019-02-13 17:52:49 +01:00
|
|
|
- template: jinja
|
|
|
|
- makedirs: True
|
|
|
|
- context:
|
|
|
|
config: {{ pip_config|json }}
|
2020-10-21 12:28:28 -03:00
|
|
|
- require:
|
|
|
|
- pkg: pip_req_pkgs
|
|
|
|
{%- endif %}
|
2019-02-13 17:52:49 +01:00
|
|
|
|
2018-02-12 08:16:03 -03:00
|
|
|
### PYTHON PKGS to install using PIP
|
|
|
|
# (requires the python-pip deb/rpm installed, either by the system or listed in
|
|
|
|
# the required packages
|
2020-10-21 12:28:28 -03:00
|
|
|
{%- for pn in wanted_pips %}
|
2019-02-21 15:20:42 +00:00
|
|
|
packages pips install {{ pn }}:
|
2020-10-21 12:28:28 -03:00
|
|
|
{%- if grains.os_family in ('Suse',) %} ##workaround https://github.com/saltstack-formulas/docker-formula/issues/198
|
2019-02-21 15:20:42 +00:00
|
|
|
cmd.run:
|
|
|
|
- name: /usr/bin/pip install {{ pn }}
|
2020-10-21 12:28:28 -03:00
|
|
|
{%- else %}
|
2018-02-12 08:16:03 -03:00
|
|
|
pip.installed:
|
2019-02-21 16:33:54 +00:00
|
|
|
- name: {{ pn }}
|
2018-02-21 07:10:25 -03:00
|
|
|
- reload_modules: true
|
2020-10-21 12:28:28 -03:00
|
|
|
{%- endif %}
|
2018-02-12 08:16:03 -03:00
|
|
|
- require:
|
|
|
|
- pkg: pip_req_pkgs
|
2020-10-21 12:28:28 -03:00
|
|
|
{%- if req_states %}
|
|
|
|
{%- for dep in req_states %}
|
2018-02-12 08:16:03 -03:00
|
|
|
- sls: {{ dep }}
|
2020-10-21 12:28:28 -03:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if pip_config %}
|
2019-02-13 17:52:49 +01:00
|
|
|
- file: pip_config
|
2020-10-21 12:28:28 -03:00
|
|
|
{%- endif %}
|
2019-06-24 12:21:47 +01:00
|
|
|
- retry: {{ packages.retry_options|json }}
|
2020-10-21 12:28:28 -03:00
|
|
|
{%- endfor %}
|
2018-02-12 08:16:03 -03:00
|
|
|
|
2020-10-21 12:28:28 -03:00
|
|
|
{%- for upn in unwanted_pips %}
|
2019-02-21 15:20:42 +00:00
|
|
|
packages pips remove {{ upn }}:
|
2020-10-21 12:28:28 -03:00
|
|
|
{%- if grains.os_family in ('Suse',) %}
|
2019-02-21 15:20:42 +00:00
|
|
|
cmd.run:
|
2019-03-06 09:41:23 -03:00
|
|
|
- name: /usr/bin/pip uninstall {{ upn }}
|
2020-10-21 12:28:28 -03:00
|
|
|
{%- else %}
|
2019-02-21 16:33:54 +00:00
|
|
|
pip.removed:
|
2019-02-21 15:20:42 +00:00
|
|
|
- name: {{ upn }}
|
2020-10-21 12:28:28 -03:00
|
|
|
{%- endif %}
|
|
|
|
- require:
|
|
|
|
- pkg: pip_req_pkgs
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|