diff --git a/README.rst b/README.rst index cece119..ad6e576 100644 --- a/README.rst +++ b/README.rst @@ -127,6 +127,18 @@ You can specify: * ``required states`` on which any of the ``wanted`` packages depend for their correct installation (ie, ``epel`` for RedHat families). +``packages.snaps`` +----------------- + +You can specify: + +* ``wanted`` snapd packages, which will be installed using snap. +* ``unwanted`` snapd packages, which will be uninstalled using snap. +* ``required system packages`` on which any of the ``wanted`` snapd packages + depend for their correct installation. +* ``required states`` on which any of the ``wanted`` packages depend for their + correct installation (ie, ``epel`` for RedHat families). + ``packages.remote_pkgs`` ------------------------ diff --git a/packages/defaults.yaml b/packages/defaults.yaml index 7e2de3f..82a4129 100644 --- a/packages/defaults.yaml +++ b/packages/defaults.yaml @@ -21,3 +21,12 @@ packages: required: states: [] pkgs: [] + snaps: + package: snapd + collides: ['snap',] + service: ['snapd.service', 'snapd.socket',] + wanted: [] + unwanted: [] + required: + states: [] + pkgs: [] diff --git a/packages/init.sls b/packages/init.sls index e96d5dd..8702e3e 100644 --- a/packages/init.sls +++ b/packages/init.sls @@ -6,3 +6,4 @@ include: - packages.remote_pkgs - packages.pips - packages.gems + - packages.snaps diff --git a/packages/snaps.sls b/packages/snaps.sls new file mode 100644 index 0000000..ce79f86 --- /dev/null +++ b/packages/snaps.sls @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls +{% from "packages/map.jinja" import packages with context %} + +{% set req_states = packages.snaps.required.states %} +{% set wanted_snaps = packages.snaps.wanted %} +{% set unwanted_snaps = packages.snaps.unwanted %} + +### REQ PKGS (without these, some WANTED SNAPS fail to install/uninstall) +include: + - packages.pkgs + +extend: + unwanted_pkgs: + pkg.removed: + - pkgs: {{ packages.snaps.collides }} + {% if req_states %} + - require: + {% for dep in req_states %} + - sls: {{ dep }} + {% endfor %} + {% endif %} + pkg_req_pkgs: + pkg.installed: + - pkgs: [ {{ packages.snaps.package }}, ] + {% if req_states %} + - require: + {% for dep in req_states %} + - sls: {{ dep }} + {% endfor %} + {% endif %} + +{% for snap in packages.snaps.service %} +packages-{{ snap }}-service: + service.running: + - name: {{ snap }} + - enable: true + - require: + - pkg: pkg_req_pkgs + - pkg: unwanted_pkgs +{% endfor %} + +### SNAPS to install + +{% for snap in wanted_snaps %} +packages-snapd-{{ snap }}-wanted: + cmd.run: + - name: snap install {{ snap }} + - unless: snap list {{ snap }} + - output_loglevel: quiet + - require: + - pkg: pkg_req_pkgs + - pkg: unwanted_pkgs +{% endfor %} + +### SNAPS to uninstall + +{% for snap in unwanted_snaps %} +packages-snapd-{{ snap }}-unwanted: + cmd.run: + - name: snap remove {{ snap }} + - onlyif: snap list {{ snap }} + - output_loglevel: quiet + - require: + - pkg: pkg_req_pkgs + - pkg: unwanted_pkgs +{% endfor %} + diff --git a/pillar.example b/pillar.example index 9fee7fb..cd39e9a 100644 --- a/pillar.example +++ b/pillar.example @@ -38,6 +38,12 @@ packages: - diff-lcs - kitchen-vagrant - kwalify + snaps: + wanted: + - hello-world + unwanted: + - goodbye-world + remote_pkgs: zoom: 'https://zoom.us/client/latest/zoom_amd64.deb'