Install/Upgrade chocolatey packages as needed, to improve perfomance

This commit is contained in:
Adam Goldsmith 2022-10-05 14:35:49 -04:00
parent e28ec5c8f5
commit 64f3739404
3 changed files with 27 additions and 18 deletions

26
chocolatey-packages.sls Normal file
View File

@ -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 %}

View File

@ -19,4 +19,5 @@ base:
- enable-wakeonlan - enable-wakeonlan
- windowsWorkstation - windowsWorkstation
- printers - printers
- chocolatey-packages
- removeShortcuts - removeShortcuts

View File

@ -1,6 +1,3 @@
include:
- chocolatey
# don't go to sleep, ideally until the salt run finishes # don't go to sleep, ideally until the salt run finishes
Set standby timeout to 10 hours: Set standby timeout to 10 hours:
powercfg.set_timeout: powercfg.set_timeout:
@ -8,21 +5,6 @@ Set standby timeout to 10 hours:
- value: 600 # ten hours should be plenty - value: 600 # ten hours should be plenty
- order: 1 - 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: Firefox Policies:
file.managed: file.managed:
- name: 'C:\\Program Files\\Mozilla Firefox\distribution\policies.json' - name: 'C:\\Program Files\\Mozilla Firefox\distribution\policies.json'