Skip to content

Commit

Permalink
Merge pull request #13 from noelmcloughlin/snapd_support
Browse files Browse the repository at this point in the history
Add support for snapd package manager
  • Loading branch information
javierbertoli authored Mar 14, 2018
2 parents 4a404cb + 57843d3 commit 0bea34b
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,22 @@ driver_config:

platforms:
- name: debian-9
driver_config:
run_command: /lib/systemd/systemd
provision_command:
- apt-get install udev -y
- name: ubuntu-17.10
driver_config:
run_command: /lib/systemd/systemd
provision_command:
- apt-get install udev -y
- name: fedora-27
driver_config:
run_command: /usr/lib/systemd/systemd
- name: centos-7
driver_config:
image: saltstack/centos-7-minimal
run_command: /usr/lib/systemd/systemd

provisioner:
name: salt_solo
Expand Down
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
10 changes: 10 additions & 0 deletions packages/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,13 @@ packages:
required:
states: []
pkgs: []
snaps:
package: snapd
collides: []
symlink: False
service: ['snapd',]
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
4 changes: 3 additions & 1 deletion packages/osmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ Fedora:
- gcc
- python2-pip
- python2-devel

snaps:
collides: ['snap',]
symlink: True
84 changes: 84 additions & 0 deletions packages/snaps.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# -*- 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 %}
{% if packages.snaps.wanted or packages.snaps.unwanted %}
### REQ PKGS (without this, SNAPS can 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 %}
{% if packages.snaps.symlink %}
{# classic confinement requires snaps under /snap or symlink from #}
{# /snap to /var/lib/snapd/snap #}
packages-snap-classic-symlink:
file.symlink:
- name: /snap
- target: /var/lib/snapd/snap
- unless: test -d /snap
- require:
- pkg: pkg_req_pkgs
- pkg: unwanted_pkgs
{% 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 %}
{% endif %}
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 0bea34b

Please sign in to comment.