From c0c119524228e30ed19f6fe8714d47b06915ff43 Mon Sep 17 00:00:00 2001 From: kartnico Date: Sat, 14 Sep 2019 21:23:59 +0200 Subject: [PATCH] feat(chocolatey): add chocolatey management support --- docs/README.rst | 18 ++++++++++++++++ packages/chocolatey.sls | 43 +++++++++++++++++++++++++++++++++++++++ packages/defaults.yaml | 6 ++++++ packages/init.sls | 1 + packages/osfamilymap.yaml | 6 ++++++ pillar.example | 11 ++++++++++ 6 files changed, 85 insertions(+) create mode 100644 packages/chocolatey.sls diff --git a/docs/README.rst b/docs/README.rst index 9505e4e..af1d9ad 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -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 `_ in order to install chocolatey required package + Testing ------- diff --git a/packages/chocolatey.sls b/packages/chocolatey.sls new file mode 100644 index 0000000..07a2668 --- /dev/null +++ b/packages/chocolatey.sls @@ -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 %} diff --git a/packages/defaults.yaml b/packages/defaults.yaml index a279106..3c95b09 100644 --- a/packages/defaults.yaml +++ b/packages/defaults.yaml @@ -25,6 +25,12 @@ packages: required: states: [] pkgs: [] + chocolatey: + wanted: [] + unwanted: [] + required: + states: [] + pkgs: [] npms: wanted: [] unwanted: [] diff --git a/packages/init.sls b/packages/init.sls index f75f23a..763e752 100644 --- a/packages/init.sls +++ b/packages/init.sls @@ -10,3 +10,4 @@ include: - packages.archives - packages.snaps - packages.golang + - packages.chocolatey diff --git a/packages/osfamilymap.yaml b/packages/osfamilymap.yaml index dff9353..91cc9a6 100644 --- a/packages/osfamilymap.yaml +++ b/packages/osfamilymap.yaml @@ -46,3 +46,9 @@ FreeBSD: pkgs: - lang/ruby25 - devel/ruby-gems + +Windows: + chocolatey: + required: + pkgs: + - chocolatey diff --git a/pillar.example b/pillar.example index 889d112..344bea8 100644 --- a/pillar.example +++ b/pillar.example @@ -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