diff --git a/chocolatey-packages.sls b/chocolatey-packages.sls new file mode 100644 index 0000000..cf888a4 --- /dev/null +++ b/chocolatey-packages.sls @@ -0,0 +1,26 @@ +include: + - chocolatey + +{% import_yaml "./packages.yaml" as packages %} + +# Install packages which are not installed +{% set installed_pkg_lines = salt['cmd.run']("if (Get-Command choco -ErrorAction SilentlyContinue) { choco list --local-only -r }", shell="powershell").splitlines() %} +{% set installed_pkg = installed_pkg_lines|map('method_call', 'split', '|', 1)|map(attribute=0)|map('lower')|list %} +{% for pkg in packages|difference(installed_pkg) %} +"install {{ pkg }}": + chocolatey.installed: + - name: {{ pkg }} + - require: + - sls: chocolatey +{% endfor %} + +# Update only packages that need updating +{% set outdated_pkg_lines = salt['cmd.run']("if (Get-Command choco -ErrorAction SilentlyContinue) { choco outdated -r --ignore-unfound }", shell="powershell").splitlines() %} +{% set outdated_pkg = outdated_pkg_lines|map('method_call', 'split', '|', 1)|map(attribute=0) %} +{% for pkg in outdated_pkg|difference(['chitubox', 'sketchup', 'autodesk-fusion360']) %} +"update {{ pkg }}": + chocolatey.upgraded: + - name: "{{ pkg }}" + - require: + - chocolateyBootstrap +{% endfor %} diff --git a/top.sls b/top.sls index f54647f..7253abf 100644 --- a/top.sls +++ b/top.sls @@ -19,4 +19,5 @@ base: - enable-wakeonlan - windowsWorkstation - printers + - chocolatey-packages - removeShortcuts diff --git a/windowsWorkstation.sls b/windowsWorkstation.sls index 6ea924f..392df8d 100644 --- a/windowsWorkstation.sls +++ b/windowsWorkstation.sls @@ -1,6 +1,3 @@ -include: - - chocolatey - # don't go to sleep, ideally until the salt run finishes Set standby timeout to 10 hours: powercfg.set_timeout: @@ -8,21 +5,6 @@ Set standby timeout to 10 hours: - value: 600 # ten hours should be plenty - order: 1 -{% import_yaml "packages.yaml" as packages %} -{% for pkg in packages %} -{{ pkg }}: - chocolatey.installed: - - name: {{ pkg }} - - require: - - sls: chocolatey -{% endfor %} - -Upgrade All: - chocolatey.upgraded: - - name: all - - require: - - chocolateyBootstrap - Firefox Policies: file.managed: - name: 'C:\\Program Files\\Mozilla Firefox\distribution\policies.json'