Skip to content

Commit

Permalink
feat(winget): introduced winget package installation task
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexNabokikh committed Dec 12, 2022
1 parent 99a3dce commit 098186c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ This playbook installs and configures most of the software I use on my Windows 1
- **Software**
- Remove Bloatware (see default config for a complete list of Bloatware).
- Install software and packages via Chocolatey selected by the user.
- Install software and packages selected by the user via Chocolatey.
- Install software and packages selected by the user via WinGet.
- **Windows apps & features**
- Install and Enable Optional Windows Features chosen by the user.
- Install and Enable the WSL2 distro selected by the user.
Expand Down Expand Up @@ -91,7 +92,7 @@ powershell.exe -ExecutionPolicy ByPass -File $file -Verbose

### Running a specific set of tagged tasks

You can filter which part of the provisioning process to run by specifying a set of tags using `ansible-playbook` `--tags` flag. The tags available are `choco` , `debloat` , `desktop` , `explorer` , `fonts` , `hostname` , `mouse` , `power` , `sounds` , `start_menu` , `taskbar` , `updates` , `windows_features` , `wsl` .
You can filter which part of the provisioning process to run by specifying a set of tags using `ansible-playbook` `--tags` flag. The tags available are `choco` , `debloat` , `desktop` , `explorer` , `fonts` , `hostname` , `mouse` , `power` , `sounds` , `start_menu` , `taskbar` , `updates` , `windows_features` , `wsl`, `winget`.

```sh
ansible-playbook main.yml --tags "choco,wsl"
Expand Down Expand Up @@ -197,6 +198,9 @@ Packages (installed with Chocolatey):
| include_volumes | (Optional) A list of volumes to be defragmented. | `list` | `["C"]` |
| change_power_plan | (Optional) Whether or not change Power Plan. | `bool` | `true` |
| power_plan | (Optional) Choose a power plan (high_performance, balanced, power_saver). | `string` | `high_performance` |
| winget_packages | (Required) A list of WinGet packages to be installed. | `list` | |
| name (WinGet) | (Required) A name of the WinGet package to be installed. | `string` | |
| source (WinGet) | (Optional) The source of the WinGet package (`msstore` or `winget`). | `string` | |

## Author

Expand Down
10 changes: 8 additions & 2 deletions default.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ choco_installed_packages:
# installs 2019.2.2.20191 version of the adobe reader
- name: adobereader
version: "2022.002.20191"
# installs latest version of the auto-dark-mode while ignoring the package checksum
- name: auto-dark-mode
# installs latest version of the Firefox while ignoring the package checksum
- name: Firefox
state: latest
choco_args: --ignorechecksum
# installs awscli, but won't update it
Expand All @@ -58,6 +58,12 @@ choco_installed_packages:
- vscode
- zoom

winget_packages:
# - name: "Auto Dark Mode"
# source: winget
- name: WinDynamicDesktop
source: winget

install_fonts: true
installed_nerdfonts:
- FiraCode
Expand Down
3 changes: 3 additions & 0 deletions main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
- import_tasks: tasks/chocolatey.yml
tags: ["choco"]

- import_tasks: tasks/winget.yml
tags: ["winget"]

- import_tasks: tasks/windows_features.yml
when: install_windows_features
tags: ["windows_features"]
Expand Down
12 changes: 12 additions & 0 deletions tasks/winget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: Install winget packages.
ansible.windows.win_powershell:
script: |
$app = "{{ item.name | default(item) }}"
if ($(winget list $app) -like "*No installed package found*") {
winget install --accept-package-agreements --accept-source-agreements -h -s "winget" $app
}
else {
winget upgrade $app
}
loop: "{{ winget_packages }}"

0 comments on commit 098186c

Please sign in to comment.