Skip to content

Commit

Permalink
Allow dicts as well as lists in wanted and others
Browse files Browse the repository at this point in the history
This can also be used as a workaround for the impossibility of merging
lists in the pillar
(saltstack-formulas#21).
  • Loading branch information
jleproust committed Nov 27, 2020
1 parent 17b91b8 commit a451150
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions packages/pkgs.sls
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,18 @@ include:
### PRE-REQ PKGS (without these, some of the WANTED PKGS will fail to install)
pkg_req_pkgs:
pkg.installed:
{%- if req_packages is mapping %}
- pkgs:
{%- for p, v in req_packages.items() %}
{%- if v %}
- {{ p }}: {{ v }}
{%- else %}
- {{ p }}
{%- endif %}
{%- endfor %}
{%- else %}
- pkgs: {{ req_packages | json }}
{%- endif %}
{%- if req_states %}
- require:
{%- for dep in req_states %}
Expand All @@ -35,7 +46,11 @@ held_pkgs:
{%- if held_packages is mapping %}
- pkgs:
{%- for p, v in held_packages.items() %}
{%- if v %}
- {{ p }}: {{ v }}
{%- else %}
- {{ p }}
{%- endif %}
{%- endfor %}
{%- else %}
- pkgs: {{ held_packages | json }}
Expand All @@ -54,7 +69,18 @@ held_pkgs:
wanted_pkgs:
pkg.installed:
{%- if wanted_packages is mapping %}
- pkgs:
{%- for p, v in wanted_packages.items() %}
{%- if v %}
- {{ p }}: {{ v }}
{%- else %}
- {{ p }}
{%- endif %}
{%- endfor %}
{%- else %}
- pkgs: {{ wanted_packages | json }}
{%- endif %}
{%- if grains['os_family'] not in ['Suse'] %}
- hold: false
{%- endif %}
Expand All @@ -69,6 +95,13 @@ wanted_pkgs:
unwanted_pkgs:
pkg.purged:
{%- if unwanted_packages is mapping %}
- pkgs:
{%- for p, v in unwanted_packages.items() %}
- {{ p }}
{%- endfor %}
{%- else %}
- pkgs: {{ unwanted_packages | json }}
{%- endif %}
{%- endif %}

0 comments on commit a451150

Please sign in to comment.