packages-formula/packages/pips.sls

70 lines
1.8 KiB
Text
Raw Normal View History

2018-02-12 08:16:03 -03:00
# -*- coding: utf-8 -*-
# vim: ft=sls
{% from "packages/map.jinja" import packages with context %}
{% 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 %}
2019-02-13 17:52:49 +01:00
{% set pip_config = packages.pips.config %}
2018-02-12 08:16:03 -03:00
{% if req_states %}
include:
{% for dep in req_states %}
- {{ dep }}
{% endfor %}
{% endif %}
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
2019-02-13 17:52:49 +01:00
{% if pip_config %}
pip_config:
file.managed:
- name: /etc/pip.conf
- source: salt://{{ slspath }}/files/pip.conf
- template: jinja
- makedirs: True
- context:
config: {{ pip_config|json }}
{% endif %}
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
{% for pn in wanted_pips %}
packages pips install {{ pn }}:
{%- if grains.os_family in ('Suse',) %} ##workaround https://github.com/saltstack-formulas/docker-formula/issues/198
cmd.run:
- name: /usr/bin/pip install {{ pn }}
{%- else %}
2018-02-12 08:16:03 -03:00
pip.installed:
2019-02-21 16:33:54 +00:00
- name: {{ pn }}
- reload_modules: true
{%- endif %}
2018-02-12 08:16:03 -03:00
- require:
- pkg: pip_req_pkgs
{% if req_states %}
{% for dep in req_states %}
- sls: {{ dep }}
{% endfor %}
{% endif %}
2019-02-13 17:52:49 +01:00
{% if pip_config %}
- file: pip_config
{% endif %}
- retry: {{ packages.retry_options|json }}
2018-02-12 08:16:03 -03:00
{% endfor %}
{% for upn in unwanted_pips %}
packages pips remove {{ upn }}:
{%- if grains.os_family in ('Suse',) %}
cmd.run:
2019-03-06 09:41:23 -03:00
- name: /usr/bin/pip uninstall {{ upn }}
{%- else %}
2019-02-21 16:33:54 +00:00
pip.removed:
- name: {{ upn }}
{%- endif %}
2018-02-12 08:16:03 -03:00
{% endfor %}