Skip to content

Commit

Permalink
feat(chocolatey): add chocolatey management support
Browse files Browse the repository at this point in the history
  • Loading branch information
kartnico authored and myii committed Mar 30, 2020
1 parent 5d59759 commit c0c1195
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,24 @@ to install, in the format:

``name: url``


`packages.chocolatey``
^^^^^^^^^^^^^^^^^^^^^^

You can specify:

* ``wanted`` chocolatey packages, which will be installed using chocolatey. Requires you
specify the correct ``chocolatey`` package (see the pillar.example)
* ``unwanted`` chocolatey packages, which will be uninstalled using chocolatey.
* ``required system packages`` on which any of the ``wanted`` system packages
depend for their correct installation.
* ``required states`` on which any of the ``wanted`` packages depend for their
correct installation (ie, ``regedit`` for configurations).

.. note::

You must configure `winrepo-ng <https://github.com/saltstack/salt-winrepo-ng>`_ in order to install chocolatey required package

Testing
-------

Expand Down
43 changes: 43 additions & 0 deletions packages/chocolatey.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{% from "packages/map.jinja" import packages with context %}
{% 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 %}
include:
{% for dep in req_states %}
- {{ dep }}
{% endfor %}
{% endif %}
chocolatey_req_pkgs:
pkg.installed:
- pkgs: {{ req_pkgs | json }}
- retry: {{ packages.retry_options|json }}
### CHOCOLATEY PACKAGES to install
{% for choco, settings in wanted_chocolatey.items() %}
{{ choco }}:
chocolatey.installed:
- name: {{ choco }}
- version: {{ '' if 'version' not in settings else settings.version }}
- source: {{ '' if 'source' not in settings else settings.source }}
- force: {{ False if 'force' not in settings else settings.force }}
- pre_versions: {{ False if 'pre_versions' not in settings else settings.pre_versions }}
- install_args: {{ '' if 'install_args' not in settings else settings.install_args }}
- override_args: {{ False if 'override_args' not in settings else settings.override_args }}
- 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 %}
### CHOCOLATEY PACKAGES to uninstall
{% for uchoco in unwanted_chocolatey %}
{{ uchoco }}:
chocolatey.uninstalled:
- name: {{ uchoco }}
{% endfor %}
6 changes: 6 additions & 0 deletions packages/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ packages:
required:
states: []
pkgs: []
chocolatey:
wanted: []
unwanted: []
required:
states: []
pkgs: []
npms:
wanted: []
unwanted: []
Expand Down
1 change: 1 addition & 0 deletions packages/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ include:
- packages.archives
- packages.snaps
- packages.golang
- packages.chocolatey
6 changes: 6 additions & 0 deletions packages/osfamilymap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ FreeBSD:
pkgs:
- lang/ruby25
- devel/ruby-gems

Windows:
chocolatey:
required:
pkgs:
- chocolatey
11 changes: 11 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ packages:
- kitchen-vagrant
- kwalify

chocolatey:
wanted:
firefox:
install_args: "l=fr-FR"
packagename:
version: '12.04'
source: 'mychocolatey/source'
force: true
unwanted:
- googlechrome

snaps:
wanted:
- hello-world
Expand Down

0 comments on commit c0c1195

Please sign in to comment.