From c9fe187e1677cc2645d7ed479ab2d32749d38d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20B=C3=A9rtoli?= Date: Wed, 21 Oct 2020 12:28:28 -0300 Subject: [PATCH] fix(states): deploy packages only if required --- packages/archives.sls | 47 ++++++++++++++------------ packages/chocolatey.sls | 49 +++++++++++++++------------ packages/gems.sls | 43 +++++++++++++---------- packages/map.jinja | 8 ++--- packages/npms.sls | 73 ++++++++++++++++++++-------------------- packages/pips.sls | 61 ++++++++++++++++++--------------- packages/pkgs.sls | 64 ++++++++++++++++++----------------- packages/remote_pkgs.sls | 12 +++---- packages/snaps.sls | 56 +++++++++++++++--------------- 9 files changed, 219 insertions(+), 194 deletions(-) diff --git a/packages/archives.sls b/packages/archives.sls index cb0efe0..88b2801 100644 --- a/packages/archives.sls +++ b/packages/archives.sls @@ -1,8 +1,14 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{% from "packages/map.jinja" import packages with context %} +{%- from "packages/map.jinja" import packages with context %} -{% set req_packages = packages.pkgs.required.pkgs + packages.archives.pkgs.required %} +{%- set wanted_archives = packages.archives.required.archives %} +{%- do wanted_archives.update( packages.archives.wanted ) %} +{%- set unwanted_archives = packages.archives.unwanted %} + +{%- if wanted_archives or unwanted_archives %} + +{%- set req_packages = packages.pkgs.required.pkgs + packages.archives.pkgs.required %} include: - packages.pkgs @@ -11,20 +17,16 @@ extend: pkg.installed: - pkgs: {{ req_packages | json }} -{% 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 %} + {%- for file_or_directory in unwanted_archives %} packages-archive-unwanted-{{ file_or_directory }}: file.absent: - name: {{ file_or_directory }} -{% endfor %} + {%- endfor %} # wanted 'archive' software -{% for package, archive in wanted_archives.items() %} - {%- set archivename = archive.dl.source.split('/')[-1] %} + {%- for package, archive in wanted_archives.items() %} + {%- set archivename = archive.dl.source.split('/')[-1] %} packages-archive-wanted-target-{{ package }}-directory: file.directory: @@ -39,7 +41,7 @@ packages-archive-wanted-target-{{ package }}-directory: - require_in: - packages-archive-wanted-download-{{ package }} - {%- if 'format' in archive.dl and archive.dl.format in packages.archives.types %} + {%- if 'format' in archive.dl and archive.dl.format in packages.archives.types %} packages-archive-wanted-download-{{ package }}: cmd.run: @@ -48,7 +50,7 @@ packages-archive-wanted-download-{{ package }}: - retry: {{ packages.retry_options|json }} {%- if 'hashsum' in archive.dl and archive.dl.hashsum %} - {# see https://github.com/saltstack/salt/pull/41914 #} + {# see https://github.com/saltstack/salt/pull/41914 #} packages-archive-wanted-{{ package }}-check-hashsum: module.run: @@ -67,18 +69,18 @@ packages-archive-wanted-install-{{ package }}: - source: file://{{ packages.tmpdir }}/{{ archivename }} - name: {{ archive.dest }}/ - archive_format: {{ archive.dl.format }} - {%- if 'hashurl' in archive.dl and archive.dl.hashurl %} + {%- if 'hashurl' in archive.dl and archive.dl.hashurl %} - source_hash: {{ archive.dl.hashurl }} - {%- endif %} - {%- if 'options' in archive and archive.options %} + {%- endif %} + {%- if 'options' in archive and archive.options %} - options: {{ archive.options }} - enforce_toplevel: {{ 'False' if 'strip-components' in archive.options else 'True' }} - {%- endif %} + {%- endif %} - onlyif: test -d {{ archive.dest }} - require: - packages-archive-wanted-download-{{ package }} - {%- else %} + {%- else %} packages-archive-wanted-download-{{ package }}: file.managed: @@ -87,12 +89,13 @@ packages-archive-wanted-download-{{ package }}: - mode: {{ '0755' if archive.dl.format in ('bin',) else '0644' if 'mode' not in archive else archive.mode }} - user: {{ packages.rootuser if 'user' not in archive else archive.user }} - makedirs: True - {%- if 'hashsum' in archive.dl and archive.dl.hashsum %} + {%- if 'hashsum' in archive.dl and archive.dl.hashsum %} - source_hash: {{ archive.dl.hashsum }} - {%- else %} + {%- else %} - skip_verify: True - {%- endif %} + {%- endif %} - retry: {{ packages.retry_options|json }} - {% endif %} -{%- endfor %} + {%- endif %} + {%- endfor %} +{%- endif %} diff --git a/packages/chocolatey.sls b/packages/chocolatey.sls index e550d06..9c9265f 100644 --- a/packages/chocolatey.sls +++ b/packages/chocolatey.sls @@ -1,21 +1,22 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{% from "packages/map.jinja" import packages with context %} +{%- from "packages/map.jinja" import packages with context %} -{% if grains['os'] == 'Windows' %} +{%- if grains['os'] == 'Windows' %} -{% if packages.chocolatey %} -{% set req_states = packages.chocolatey.required.states %} -{% set req_pkgs = packages.chocolatey.required.pkgs %} -{% set wanted_chocolatey = packages.chocolatey.wanted %} -{% set unwanted_chocolatey = packages.chocolatey.unwanted %} + {%- if packages.chocolatey %} + {%- set req_states = packages.chocolatey.required.states %} + {%- set req_pkgs = packages.chocolatey.required.pkgs %} + {%- set wanted_chocolatey = packages.chocolatey.wanted %} + {%- set unwanted_chocolatey = packages.chocolatey.unwanted %} -{% if req_states %} + {%- if wanted_chocolatey or unwanted_chocolatey %} + {%- if req_states %} include: - {% for dep in req_states %} + {%- for dep in req_states %} - {{ dep }} - {% endfor %} -{% endif %} + {%- endfor %} + {%- endif %} chocolatey_req_pkgs: pkg.installed: @@ -23,8 +24,8 @@ chocolatey_req_pkgs: - retry: {{ packages.retry_options|json }} ### CHOCOLATEY PACKAGES to install -{% if wanted_chocolatey %} -{% for choco, settings in wanted_chocolatey.items() %} + {%- if wanted_chocolatey %} + {%- for choco, settings in wanted_chocolatey.items() %} {{ choco }}: chocolatey.installed: - name: {{ choco }} @@ -37,17 +38,21 @@ chocolatey_req_pkgs: - force_x86: {{ False if 'force_x86' not in settings else settings.force_x86 }} - package_args: {{ '' if 'package_args' not in settings else settings.package_args }} - allow_multiple: {{ False if 'allow_multiple' not in settings else settings.allow_multiple }} -{% endfor %} -{% endif %} + - require: + - pkg: chocolatey_req_pkgs + {%- endfor %} + {%- endif %} ### CHOCOLATEY PACKAGES to uninstall -{% if unwanted_chocolatey %} -{% for uchoco in unwanted_chocolatey %} + {%- if unwanted_chocolatey %} + {%- for uchoco in unwanted_chocolatey %} {{ uchoco }}: chocolatey.uninstalled: - name: {{ uchoco }} -{% endfor %} -{% endif %} -{% endif %} - -{% endif %} + - require: + - pkg: chocolatey_req_pkgs + {%- endfor %} + {%- endif %} + {%- endif %} + {%- endif %} +{%- endif %} diff --git a/packages/gems.sls b/packages/gems.sls index db2b9cd..f578833 100644 --- a/packages/gems.sls +++ b/packages/gems.sls @@ -1,18 +1,22 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{% from "packages/map.jinja" import packages with context %} -{% set req_states = packages.gems.required.states %} -{% set req_pkgs = packages.gems.required.pkgs %} -{% set wanted_gems = packages.gems.wanted %} -{% set unwanted_gems = packages.gems.unwanted %} +{#- Get the `tplroot` from `tpldir` #} +{%- set tplroot = tpldir.split('/')[0] %} +{%- from tplroot ~ "/map.jinja" import packages with context %} -{% if req_states %} +{%- set req_states = packages.gems.required.states %} +{%- set req_pkgs = packages.gems.required.pkgs %} +{%- set wanted_gems = packages.gems.wanted %} +{%- set unwanted_gems = packages.gems.unwanted %} + +{%- if wanted_gems or unwanted_gems %} + {%- if req_states %} include: - {% for dep in req_states %} + {%- for dep in req_states %} - {{ dep }} - {% endfor %} -{% endif %} + {%- endfor %} + {%- endif %} ### REQ PKGS (without these, some of the WANTED GEMS will fail to install) gem_req_pkgs: @@ -23,25 +27,28 @@ gem_req_pkgs: ### GEMS to install # (requires the ruby/rubygem deb/rpm installed, either by the system or listed in # the required packages -{% for gm in wanted_gems %} + {%- for gm in wanted_gems %} {{ gm }}: gem.installed: - require: - pkg: gem_req_pkgs - {% if req_states %} - {% for dep in req_states %} + {%- if req_states %} + {%- for dep in req_states %} - sls: {{ dep }} - {% endfor %} - {% endif %} + {%- endfor %} + {%- endif %} - retry: {{ packages.retry_options|json }} {#- Not specific to Arch but needed for the newest versions of Ruby #} {%- if grains.os_family == 'Arch' %} - rdoc: True - ri: True {%- endif %} -{% endfor %} + {%- endfor %} -{% for ugm in unwanted_gems %} + {%- for ugm in unwanted_gems %} {{ ugm }}: - gem.removed -{% endfor %} + gem.removed: + - require: + - pkg: gem_req_pkgs + {%- endfor %} +{%- endif %} diff --git a/packages/map.jinja b/packages/map.jinja index 7a042d6..5ec612f 100644 --- a/packages/map.jinja +++ b/packages/map.jinja @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- # vim: ft=jinja -{% import_yaml 'packages/defaults.yaml' as defaults %} -{% import_yaml 'packages/osfamilymap.yaml' as osfamilymap %} -{% import_yaml 'packages/osmap.yaml' as osmap %} +{%- import_yaml 'packages/defaults.yaml' as defaults %} +{%- import_yaml 'packages/osfamilymap.yaml' as osfamilymap %} +{%- import_yaml 'packages/osmap.yaml' as osmap %} -{% set packages = salt['grains.filter_by']( +{%- set packages = salt['grains.filter_by']( defaults, merge = salt['grains.filter_by']( osfamilymap, diff --git a/packages/npms.sls b/packages/npms.sls index 57b550f..b1a9768 100644 --- a/packages/npms.sls +++ b/packages/npms.sls @@ -1,23 +1,23 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{% from "packages/map.jinja" import packages with context %} +{%- from "packages/map.jinja" import packages with context %} -{% set req_states = packages.npms.required.states %} -{% set req_pkgs = packages.npms.required.pkgs %} -{% set wanted_npms = packages.npms.wanted %} -{% set unwanted_npms = packages.npms.unwanted %} - -{% if req_states %} -include: - {% for dep in req_states %} - - {{ dep }} - {% endfor %} -{% endif %} +{%- set req_states = packages.npms.required.states %} +{%- set req_pkgs = packages.npms.required.pkgs %} +{%- set wanted_npms = packages.npms.wanted %} +{%- set unwanted_npms = packages.npms.unwanted %} # As we depend on npm installed, if this state file is invoked every time # if will fail with 'npm not found'. This condition makes sure it's run # only when explicitly asking for adding/removing npms -{% if wanted_npms or unwanted_npms %} +{%- if wanted_npms or unwanted_npms %} + + {%- if req_states %} +include: + {%- for dep in req_states %} + - {{ dep }} + {%- endfor %} + {%- endif %} ### REQ PKGS (without these, some of the WANTED NPMS will fail to install) npm_req_pkgs: @@ -28,7 +28,7 @@ npm_req_pkgs: # (requires the npm binary installed, either by the system or listed in # the required packages -{% if packages.npms.dir is defined %} + {%- if packages.npms.dir is defined %} npms_dir: file.directory: - name: {{ packages.npms.dir }} @@ -36,41 +36,42 @@ npms_dir: - group: {{ packages.rootuser if 'group' not in packages.npms else packages.npms.group }} - mode: {{ '0755' if 'mode' not in packages.npms else packages.npms.mode }} - makedirs: True -{% endif %} + {%- endif %} wanted_npms: npm.installed: - pkgs: {{ wanted_npms | json }} - {% if packages.npms.dir is defined %} + {%- if packages.npms.dir is defined %} - dir: {{ packages.npms.dir }} - {% endif %} - {% if packages.npms.user is defined %} + {%- endif %} + {%- if packages.npms.user is defined %} - user: {{ packages.npms.user }} - {% endif %} - {% if packages.npms.registry is defined %} + {%- endif %} + {%- if packages.npms.registry is defined %} - registry: {{ packages.npms.registry }} - {% endif %} - {% if packages.npms.env is defined %} + {%- endif %} + {%- if packages.npms.env is defined %} - env: {{ packages.npms.env | json }} - {% endif %} - {% if packages.npms.force_reinstall is defined %} + {%- endif %} + {%- if packages.npms.force_reinstall is defined %} - force_reinstall: {{ packages.npms.force_reinstall }} - {% endif %} + {%- endif %} - require: - {% if packages.npms.dir is defined %} + {%- if packages.npms.dir is defined %} - file: npms_dir - {% endif %} + {%- endif %} - pkg: npm_req_pkgs - {% if req_states %} - {% for dep in req_states %} + {%- if req_states %} + {%- for dep in req_states %} - sls: {{ dep }} - {% endfor %} - {% endif %} + {%- endfor %} + {%- endif %} - retry: {{ packages.retry_options|json }} -{% for upn in unwanted_npms %} + {%- for upn in unwanted_npms %} {{ upn }}: - npm.removed -{% endfor %} - -{% endif %} + npm.removed: + - require: + - pkg: npm_req_pkgs + {%- endfor %} +{%- endif %} diff --git a/packages/pips.sls b/packages/pips.sls index ed30c4c..eb51ec2 100644 --- a/packages/pips.sls +++ b/packages/pips.sls @@ -5,25 +5,27 @@ {%- set tplroot = tpldir.split('/')[0] %} {%- from tplroot ~ "/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 %} -{% set pip_config = packages.pips.config %} +{%- 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 %} +{%- set pip_config = packages.pips.config %} -{% if req_states %} +{%- if wanted_pips or unwanted_pips %} + + {%- if req_states %} include: - {% for dep in req_states %} + {%- for dep in req_states %} - {{ dep }} - {% endfor %} -{% endif %} + {%- endfor %} + {%- endif %} ### REQ PKGS (without these, some of the WANTED PIPS will fail to install) pip_req_pkgs: pkg.installed: - pkgs: {{ req_pkgs | json }} -{% if pip_config %} + {%- if pip_config %} pip_config: file.managed: - name: /etc/pip.conf @@ -32,41 +34,46 @@ pip_config: - makedirs: True - context: config: {{ pip_config|json }} -{% endif %} + - require: + - pkg: pip_req_pkgs + {%- endif %} ### 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 %} + {%- 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 + {%- 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 %} + {%- else %} pip.installed: - name: {{ pn }} - reload_modules: true - {%- endif %} + {%- endif %} - require: - pkg: pip_req_pkgs - {% if req_states %} - {% for dep in req_states %} + {%- if req_states %} + {%- for dep in req_states %} - sls: {{ dep }} - {% endfor %} - {% endif %} - {% if pip_config %} + {%- endfor %} + {%- endif %} + {%- if pip_config %} - file: pip_config - {% endif %} + {%- endif %} - retry: {{ packages.retry_options|json }} -{% endfor %} + {%- endfor %} -{% for upn in unwanted_pips %} + {%- for upn in unwanted_pips %} packages pips remove {{ upn }}: - {%- if grains.os_family in ('Suse',) %} + {%- if grains.os_family in ('Suse',) %} cmd.run: - name: /usr/bin/pip uninstall {{ upn }} - {%- else %} + {%- else %} pip.removed: - name: {{ upn }} - {%- endif %} -{% endfor %} + {%- endif %} + - require: + - pkg: pip_req_pkgs + {%- endfor %} +{%- endif %} diff --git a/packages/pkgs.sls b/packages/pkgs.sls index dfefaf1..2be9658 100644 --- a/packages/pkgs.sls +++ b/packages/pkgs.sls @@ -1,72 +1,74 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{% from "packages/map.jinja" import packages with context %} +{%- from "packages/map.jinja" import packages with context %} -{% set req_states = packages.pkgs.required.states %} -{% set req_packages = packages.pkgs.required.pkgs %} -{% set held_packages = packages.pkgs.held %} -{% set wanted_packages = packages.pkgs.wanted %} -{% set unwanted_packages = packages.pkgs.unwanted %} +{%- set req_states = packages.pkgs.required.states %} +{%- set req_packages = packages.pkgs.required.pkgs %} +{%- set held_packages = packages.pkgs.held %} +{%- set wanted_packages = packages.pkgs.wanted %} +{%- set unwanted_packages = packages.pkgs.unwanted %} -{% if req_states %} +{%- if held_packages or wanted_packages %} + {%- if req_states %} include: - {% for dep in req_states %} + {%- for dep in req_states %} - {{ dep }} - {% endfor %} -{% endif %} + {%- endfor %} + {%- endif %} ### PRE-REQ PKGS (without these, some of the WANTED PKGS will fail to install) pkg_req_pkgs: pkg.installed: - pkgs: {{ req_packages | json }} - {% if req_states %} + {%- if req_states %} - require: - {% for dep in req_states %} + {%- for dep in req_states %} - sls: {{ dep }} - {% endfor %} - {% endif %} + {%- endfor %} + {%- endif %} - retry: {{ packages.retry_options|json }} -{% if held_packages != {} %} + {%- if held_packages != {} %} held_pkgs: pkg.installed: - {% if held_packages is mapping %} + {%- if held_packages is mapping %} - pkgs: - {% for p, v in held_packages.items() %} + {%- for p, v in held_packages.items() %} - {{ p }}: {{ v }} - {% endfor %} - {% else %} + {%- endfor %} + {%- else %} - pkgs: {{ held_packages | json }} - {% endif %} - {% if grains['os_family'] not in ['Suse'] %} + {%- endif %} + {%- if grains['os_family'] not in ['Suse'] %} - hold: true - update_holds: true - {% endif %} + {%- endif %} - require: - pkg: pkg_req_pkgs - {% for dep in req_states %} + {%- for dep in req_states %} - sls: {{ dep }} - {% endfor %} + {%- endfor %} - retry: {{ packages.retry_options|json }} -{% endif %} + {%- endif %} wanted_pkgs: pkg.installed: - pkgs: {{ wanted_packages | json }} - {% if grains['os_family'] not in ['Suse'] %} + {%- if grains['os_family'] not in ['Suse'] %} - hold: false - {% endif %} + {%- endif %} - require: - pkg: pkg_req_pkgs - {% if req_states %} - {% for dep in req_states %} + {%- if req_states %} + {%- for dep in req_states %} - sls: {{ dep }} - {% endfor %} - {% endif %} + {%- endfor %} + {%- endif %} - retry: {{ packages.retry_options|json }} unwanted_pkgs: pkg.purged: - pkgs: {{ unwanted_packages | json }} +{%- endif %} diff --git a/packages/remote_pkgs.sls b/packages/remote_pkgs.sls index da1aa4c..e37a46c 100644 --- a/packages/remote_pkgs.sls +++ b/packages/remote_pkgs.sls @@ -1,16 +1,16 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{% from "packages/map.jinja" import packages with context %} +{%- from "packages/map.jinja" import packages with context %} -{% set wanted_rem_pkgs = packages.remote_pkgs %} +{%- set wanted_rem_pkgs = packages.remote_pkgs %} ### REMOTE PKGS to install directly from a remote URL. Must be a deb/rpm file -{% if wanted_rem_pkgs != {} %} +{%- if wanted_rem_pkgs %} remote_packages: pkg.installed: - sources: - {% for package, url in wanted_rem_pkgs.items() %} + {%- for package, url in wanted_rem_pkgs.items() %} - {{ package }}: {{ url }} - {% endfor %} -{% endif %} + {%- endfor %} +{%- endif %} diff --git a/packages/snaps.sls b/packages/snaps.sls index e120753..0bf2751 100644 --- a/packages/snaps.sls +++ b/packages/snaps.sls @@ -1,28 +1,28 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{% from "packages/map.jinja" import packages with context %} +{%- from "packages/map.jinja" import packages with context %} # As we are 'extend'ing pkg_req_pkgs and unwanted_pkgs, we need to concatenate # the attributes correctly (see #17) -{% set req_packages = packages.pkgs.required.pkgs + packages.snaps.packages %} -{% set req_states = packages.pkgs.required.states + packages.snaps.required.states %} -{% set unwanted_packages = packages.pkgs.unwanted + packages.snaps.collides %} +{%- set req_packages = packages.pkgs.required.pkgs + packages.snaps.packages %} +{%- set req_states = packages.pkgs.required.states + packages.snaps.required.states %} +{%- set unwanted_packages = packages.pkgs.unwanted + packages.snaps.collides %} -{% set wanted_snaps = packages.snaps.wanted %} -{% set classic_snaps = packages.snaps.classic %} -{% set unwanted_snaps = packages.snaps.unwanted %} +{%- set wanted_snaps = packages.snaps.wanted %} +{%- set classic_snaps = packages.snaps.classic %} +{%- set unwanted_snaps = packages.snaps.unwanted %} {%- if packages.snaps.packages %} - {% if wanted_snaps or classic_snaps or unwanted_snaps %} + {%- if wanted_snaps or classic_snaps or unwanted_snaps %} ### REQ PKGS (without this, SNAPS can fail to install/uninstall) include: - packages.pkgs - {% if req_states %} - {% for dep in req_states %} + {%- if req_states %} + {%- for dep in req_states %} - {{ dep }} - {% endfor %} - {% endif %} + {%- endfor %} + {%- endif %} extend: unwanted_pkgs: @@ -32,15 +32,15 @@ extend: pkg_req_pkgs: pkg.installed: - pkgs: {{ req_packages | json }} - {% if req_states %} + {%- if req_states %} - require: - {% for dep in req_states %} + {%- for dep in req_states %} - sls: {{ dep }} - {% endfor %} - {% endif %} + {%- endfor %} + {%- endif %} - retry: {{ packages.retry_options|json }} -{% if packages.snaps.symlink %} + {%- if packages.snaps.symlink %} {# classic confinement requires snaps under /snap or symlink from #} {# /snap to /var/lib/snapd/snap #} packages-snap-classic-symlink: @@ -51,9 +51,9 @@ packages-snap-classic-symlink: - require: - pkg: pkg_req_pkgs - pkg: unwanted_pkgs -{% endif %} + {%- endif %} -{% for snap in packages.snaps.service %} + {%- for snap in packages.snaps.service %} packages-{{ snap }}-service: service.running: - name: {{ snap }} @@ -61,10 +61,10 @@ packages-{{ snap }}-service: - require: - pkg: pkg_req_pkgs - pkg: unwanted_pkgs -{% endfor %} + {%- endfor %} ### SNAPS to install -{% for snap in wanted_snaps %} + {%- for snap in wanted_snaps %} packages-snapd-{{ snap }}-wanted: cmd.run: - name: snap install {{ snap }} @@ -74,10 +74,10 @@ packages-snapd-{{ snap }}-wanted: - pkg: pkg_req_pkgs - pkg: unwanted_pkgs - retry: {{ packages.retry_options|json }} -{% endfor %} + {%- endfor %} ### SNAPS to install in classic mode -{% for snap in classic_snaps %} + {%- for snap in classic_snaps %} packages-snapd-{{ snap }}-classic: cmd.run: - name: snap install --classic {{ snap }} @@ -87,10 +87,10 @@ packages-snapd-{{ snap }}-classic: - pkg: pkg_req_pkgs - pkg: unwanted_pkgs - retry: {{ packages.retry_options|json }} -{% endfor %} + {%- endfor %} ### SNAPS to uninstall -{% for snap in unwanted_snaps %} + {%- for snap in unwanted_snaps %} packages-snapd-{{ snap }}-unwanted: cmd.run: - name: snap remove {{ snap }} @@ -99,7 +99,7 @@ packages-snapd-{{ snap }}-unwanted: - require: - pkg: pkg_req_pkgs - pkg: unwanted_pkgs -{% endfor %} + {%- endfor %} - {% endif %} -{% endif %} + {%- endif %} +{%- endif %}