Skip to content

Commit c0c1195

Browse files
kartnicomyii
authored andcommitted
feat(chocolatey): add chocolatey management support
1 parent 5d59759 commit c0c1195

File tree

6 files changed

+85
-0
lines changed

6 files changed

+85
-0
lines changed

docs/README.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,24 @@ to install, in the format:
224224

225225
``name: url``
226226

227+
228+
`packages.chocolatey``
229+
^^^^^^^^^^^^^^^^^^^^^^
230+
231+
You can specify:
232+
233+
* ``wanted`` chocolatey packages, which will be installed using chocolatey. Requires you
234+
specify the correct ``chocolatey`` package (see the pillar.example)
235+
* ``unwanted`` chocolatey packages, which will be uninstalled using chocolatey.
236+
* ``required system packages`` on which any of the ``wanted`` system packages
237+
depend for their correct installation.
238+
* ``required states`` on which any of the ``wanted`` packages depend for their
239+
correct installation (ie, ``regedit`` for configurations).
240+
241+
.. note::
242+
243+
You must configure `winrepo-ng <https://github.com/saltstack/salt-winrepo-ng>`_ in order to install chocolatey required package
244+
227245
Testing
228246
-------
229247

packages/chocolatey.sls

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
3+
{% from "packages/map.jinja" import packages with context %}
4+
5+
{% set req_states = packages.chocolatey.required.states %}
6+
{% set req_pkgs = packages.chocolatey.required.pkgs %}
7+
{% set wanted_chocolatey = packages.chocolatey.wanted %}
8+
{% set unwanted_chocolatey = packages.chocolatey.unwanted %}
9+
10+
{% if req_states %}
11+
include:
12+
{% for dep in req_states %}
13+
- {{ dep }}
14+
{% endfor %}
15+
{% endif %}
16+
17+
chocolatey_req_pkgs:
18+
pkg.installed:
19+
- pkgs: {{ req_pkgs | json }}
20+
- retry: {{ packages.retry_options|json }}
21+
22+
### CHOCOLATEY PACKAGES to install
23+
{% for choco, settings in wanted_chocolatey.items() %}
24+
{{ choco }}:
25+
chocolatey.installed:
26+
- name: {{ choco }}
27+
- version: {{ '' if 'version' not in settings else settings.version }}
28+
- source: {{ '' if 'source' not in settings else settings.source }}
29+
- force: {{ False if 'force' not in settings else settings.force }}
30+
- pre_versions: {{ False if 'pre_versions' not in settings else settings.pre_versions }}
31+
- install_args: {{ '' if 'install_args' not in settings else settings.install_args }}
32+
- override_args: {{ False if 'override_args' not in settings else settings.override_args }}
33+
- force_x86: {{ False if 'force_x86' not in settings else settings.force_x86 }}
34+
- package_args: {{ '' if 'package_args' not in settings else settings.package_args }}
35+
- allow_multiple: {{ False if 'allow_multiple' not in settings else settings.allow_multiple }}
36+
{% endfor %}
37+
38+
### CHOCOLATEY PACKAGES to uninstall
39+
{% for uchoco in unwanted_chocolatey %}
40+
{{ uchoco }}:
41+
chocolatey.uninstalled:
42+
- name: {{ uchoco }}
43+
{% endfor %}

packages/defaults.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ packages:
2525
required:
2626
states: []
2727
pkgs: []
28+
chocolatey:
29+
wanted: []
30+
unwanted: []
31+
required:
32+
states: []
33+
pkgs: []
2834
npms:
2935
wanted: []
3036
unwanted: []

packages/init.sls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ include:
1010
- packages.archives
1111
- packages.snaps
1212
- packages.golang
13+
- packages.chocolatey

packages/osfamilymap.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,9 @@ FreeBSD:
4646
pkgs:
4747
- lang/ruby25
4848
- devel/ruby-gems
49+
50+
Windows:
51+
chocolatey:
52+
required:
53+
pkgs:
54+
- chocolatey

pillar.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ packages:
6262
- kitchen-vagrant
6363
- kwalify
6464

65+
chocolatey:
66+
wanted:
67+
firefox:
68+
install_args: "l=fr-FR"
69+
packagename:
70+
version: '12.04'
71+
source: 'mychocolatey/source'
72+
force: true
73+
unwanted:
74+
- googlechrome
75+
6576
snaps:
6677
wanted:
6778
- hello-world

0 commit comments

Comments
 (0)