2018-08-22 00:55:53 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: ft=sls
|
|
|
|
{% from "packages/map.jinja" import packages with context %}
|
|
|
|
|
2018-10-03 15:45:01 +01:00
|
|
|
{% set req_packages = packages.pkgs.required.pkgs + packages.archives.pkgs.required %}
|
2018-08-22 00:55:53 +01:00
|
|
|
include:
|
|
|
|
- packages.pkgs
|
|
|
|
|
|
|
|
extend:
|
|
|
|
pkg_req_pkgs:
|
|
|
|
pkg.installed:
|
2019-03-05 20:12:25 -03:00
|
|
|
- pkgs: {{ req_packages | json }}
|
2018-08-22 00:55:53 +01:00
|
|
|
|
|
|
|
{% set wanted_archives = packages.archives.required.archives %}
|
|
|
|
{% do wanted_archives.update( packages.archives.wanted ) %}
|
|
|
|
{% set unwanted_archives = packages.archives.unwanted %}
|
|
|
|
|
|
|
|
# unwanted 'archive' software
|
|
|
|
{% for file_or_directory in unwanted_archives %}
|
|
|
|
packages-archive-unwanted-{{ file_or_directory }}:
|
|
|
|
file.absent:
|
|
|
|
- name: {{ file_or_directory }}
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
# wanted 'archive' software
|
|
|
|
{% for package, archive in wanted_archives.items() %}
|
2018-09-18 10:27:07 +01:00
|
|
|
{%- set archivename = archive.dl.source.split('/')[-1] %}
|
2018-08-22 00:55:53 +01:00
|
|
|
|
2018-09-18 10:27:07 +01:00
|
|
|
packages-archive-wanted-target-{{ package }}-directory:
|
2018-08-22 00:55:53 +01:00
|
|
|
file.directory:
|
|
|
|
- names:
|
|
|
|
- {{ archive.dest }}
|
2018-12-03 09:59:39 +00:00
|
|
|
{%- if packages.tmpdir != '/tmp' %}
|
|
|
|
- {{ packages.tmpdir }}
|
|
|
|
{%- endif %}
|
2019-08-18 15:47:11 +01:00
|
|
|
- user: {{ packages.rootuser if 'user' not in archive else archive.user }}
|
2018-09-18 10:27:07 +01:00
|
|
|
- mode: {{ '0755' if 'mode' not in archive else archive.mode }}
|
2018-08-22 00:55:53 +01:00
|
|
|
- makedirs: True
|
|
|
|
- require_in:
|
2018-09-18 10:27:07 +01:00
|
|
|
- packages-archive-wanted-download-{{ package }}
|
|
|
|
|
2018-12-03 14:06:46 +00:00
|
|
|
{%- if 'format' in archive.dl and archive.dl.format in packages.archives.types %}
|
2018-09-18 10:27:07 +01:00
|
|
|
|
2018-08-22 00:55:53 +01:00
|
|
|
packages-archive-wanted-download-{{ package }}:
|
|
|
|
cmd.run:
|
2018-09-18 10:27:07 +01:00
|
|
|
- name: curl -s -L -o {{ packages.tmpdir }}/{{ archivename }} {{ archive.dl.source }}
|
2019-01-27 18:44:28 +00:00
|
|
|
- unless: test -f {{ packages.tmpdir }}/{{ archivename }}
|
2019-06-24 12:21:47 +01:00
|
|
|
- retry: {{ packages.retry_options|json }}
|
2018-08-22 00:55:53 +01:00
|
|
|
|
2018-09-18 10:27:07 +01:00
|
|
|
{%- if 'hashsum' in archive.dl and archive.dl.hashsum %}
|
|
|
|
{# see https://github.com/saltstack/salt/pull/41914 #}
|
2018-08-22 00:55:53 +01:00
|
|
|
|
|
|
|
packages-archive-wanted-{{ package }}-check-hashsum:
|
|
|
|
module.run:
|
|
|
|
- name: file.check_hash
|
2018-09-18 10:27:07 +01:00
|
|
|
- path: {{ packages.tmpdir }}/{{ archivename }}
|
2018-08-22 00:55:53 +01:00
|
|
|
- file_hash: {{ archive.dl.hashsum }}
|
|
|
|
- require:
|
2018-09-18 10:27:07 +01:00
|
|
|
- packages-archive-wanted-download-{{ package }}
|
2018-08-22 00:55:53 +01:00
|
|
|
- require_in:
|
|
|
|
- archive: packages-archive-wanted-install-{{ package }}
|
|
|
|
|
2018-09-18 10:27:07 +01:00
|
|
|
{%- endif %}
|
2018-08-22 00:55:53 +01:00
|
|
|
|
2018-09-18 10:27:07 +01:00
|
|
|
packages-archive-wanted-install-{{ package }}:
|
2018-08-22 00:55:53 +01:00
|
|
|
archive.extracted:
|
2018-09-18 10:27:07 +01:00
|
|
|
- source: file://{{ packages.tmpdir }}/{{ archivename }}
|
|
|
|
- name: {{ archive.dest }}/
|
2018-08-22 00:55:53 +01:00
|
|
|
- archive_format: {{ archive.dl.format }}
|
2018-09-18 10:27:07 +01:00
|
|
|
{%- if 'hashurl' in archive.dl and archive.dl.hashurl %}
|
2018-08-22 00:55:53 +01:00
|
|
|
- source_hash: {{ archive.dl.hashurl }}
|
2018-09-18 10:27:07 +01:00
|
|
|
{%- endif %}
|
|
|
|
{%- if 'options' in archive and archive.options %}
|
2018-08-22 00:55:53 +01:00
|
|
|
- options: {{ archive.options }}
|
2018-09-18 10:27:07 +01:00
|
|
|
- enforce_toplevel: {{ 'False' if 'strip-components' in archive.options else 'True' }}
|
|
|
|
{%- endif %}
|
2018-12-03 14:06:46 +00:00
|
|
|
- onlyif: test -d {{ archive.dest }}
|
2018-09-18 10:27:07 +01:00
|
|
|
- require:
|
2018-08-22 00:55:53 +01:00
|
|
|
- packages-archive-wanted-download-{{ package }}
|
|
|
|
|
2018-09-18 10:27:07 +01:00
|
|
|
{%- else %}
|
|
|
|
|
|
|
|
packages-archive-wanted-download-{{ package }}:
|
|
|
|
file.managed:
|
|
|
|
- name: {{ archive.dest }}/{{ archivename }}
|
|
|
|
- source: {{ archive.dl.source }}
|
|
|
|
- mode: {{ '0755' if archive.dl.format in ('bin',) else '0644' if 'mode' not in archive else archive.mode }}
|
2019-08-18 15:47:11 +01:00
|
|
|
- user: {{ packages.rootuser if 'user' not in archive else archive.user }}
|
2018-09-18 10:27:07 +01:00
|
|
|
- makedirs: True
|
|
|
|
{%- if 'hashsum' in archive.dl and archive.dl.hashsum %}
|
|
|
|
- source_hash: {{ archive.dl.hashsum }}
|
|
|
|
{%- else %}
|
|
|
|
- skip_verify: True
|
|
|
|
{%- endif %}
|
2019-06-24 12:21:47 +01:00
|
|
|
- retry: {{ packages.retry_options|json }}
|
2018-09-18 10:27:07 +01:00
|
|
|
|
|
|
|
{% endif %}
|
2018-08-22 00:55:53 +01:00
|
|
|
{%- endfor %}
|