Skip to content

Commit

Permalink
Merge pull request #35 from AlexNabokikh/chocolatey
Browse files Browse the repository at this point in the history
feat(chocolatey): improved choco packages installation task
  • Loading branch information
AlexNabokikh authored Aug 10, 2022
2 parents 51237b1 + 46a61b3 commit 2f9b559
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ ansible-playbook main.yml --tags "choco,wsl"

## Overriding Defaults

You can override any of the defaults configured in `default.config.yml` by creating a `config.yml` file and setting the overrides in that file. For example, you can customize the installed packages and enable/disable specific tasks with something like:
**NOTE:** You can override any of the defaults configured in `default.config.yml` by creating a `config.yml` file and setting the overrides in that file. For example, you can customize the installed packages and enable/disable specific tasks with something like:

```yaml
configure_hostname: true
Expand All @@ -108,10 +108,17 @@ install_windows_updates: true
update_categories:
- Critical Updates
- Security Updates
- * # Installs all updates

choco_installed_packages:
- googlechrome
- git
# installs latest version of the Google Chrome while ignoring the package checksum
- name: googlechrome
state: latest
choco_args: --ignorechecksum
# installs 2.37.1 version of the git
- name: git
version: "2.37.1"
# installs GO, but won't update it
- golang

install_fonts: true
Expand Down
10 changes: 8 additions & 2 deletions default.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ change_power_plan: true
power_plan: "high performance"

choco_installed_packages:
- adobereader
- auto-dark-mode
# 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
state: latest
choco_args: --ignorechecksum
# installs awscli, but won't update it
- awscli
- Firefox
- git
Expand Down
10 changes: 3 additions & 7 deletions tasks/chocolatey.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
- name: Ensure configured Chocolatey packages are installed.
chocolatey.chocolatey.win_chocolatey:
name: "{{ item.name | default(item) }}"
ignore_checksums: true
state: present
state: "{{ item.state | default('present') }}"
version: "{{ item.version | default(omit) }}"
choco_args: "{{ item.choco_args | default(omit) }}"
loop: "{{ choco_installed_packages }}"

- name: Upgrade installed Chocolatey packages.
chocolatey.chocolatey.win_chocolatey:
name: all
state: latest

- name: Clean chocolatey and nuget cache.
ansible.windows.win_file:
path: "{{ item }}"
Expand Down

0 comments on commit 2f9b559

Please sign in to comment.