Skip to content

Commit

Permalink
Add support for snapd package manager
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmcloughlin committed Mar 13, 2018
1 parent 4a404cb commit 4816786
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
------------------------

Expand Down
9 changes: 9 additions & 0 deletions packages/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@ packages:
required:
states: []
pkgs: []
snaps:
package: snapd
collides: ['snap',]
service: ['snapd.service', 'snapd.socket',]
wanted: []
unwanted: []
required:
states: []
pkgs: []
1 change: 1 addition & 0 deletions packages/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ include:
- packages.remote_pkgs
- packages.pips
- packages.gems
- packages.snaps
68 changes: 68 additions & 0 deletions packages/snaps.sls
Original file line number Diff line number Diff line change
@@ -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 %}
6 changes: 6 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit 4816786

Please sign in to comment.