Skip to content

chocolatey/chocolatey-ansible

Chocolatey Ansible Collection

Build Status
Build Status

Description

The chocolatey.chocolatey Ansible Collection includes the modules required to configure Chocolatey, as well as manage packages on Windows using Chocolatey. It contains the following modules:

Name Description
win_chocolatey Manage packages using chocolatey
win_chocolatey_config Manage Chocolatey config settings
win_chocolatey_facts Create a facts collection for Chocolatey
win_chocolatey_feature Manage Chocolatey features
win_chocolatey_source Manage Chocolatey sources

Requirements

  • ansible-core >= 2.16, 2.17, 2.18
  • python >= 3.8

Python Dependencies

  • pywinrm

Installation

Before using this collection, you need to install it with the Ansible Galaxy command-line tool:

ansible-galaxy collection install chocolatey.chocolatey

You can also include it in a requirements.yml file and install it with ansible-galaxy collection install -r requirements.yml, using the format:

collections:
  - name: chocolatey.chocolatey

Note that if you install any collections from Ansible Galaxy, they will not be upgraded automatically when you upgrade the Ansible package. To upgrade the collection to the latest available version, run the following command:

ansible-galaxy collection install chocolatey.chocolatey --upgrade

You can also install a specific version of the collection, for example, if you need to downgrade when something is broken in the latest version (please report an issue in this repository). Use the following syntax to install version 1.0.0:

ansible-galaxy collection install chocolatey.chocolatey:==1.0.0

See using Ansible collections for more details.

Use Cases

Some example usages of the modules in this collection are below.

Upgrade all packages with Chocolatey:

- name: Upgrade installed packages
  win_chocolatey:
    name: all
    state: latest

Install version 6.6 of notepadplusplus:

- name: Install notepadplusplus version 6.6
  win_chocolatey:
    name: notepadplusplus
    version: '6.6'

Set the Chocolatey cache location:

- name: Set the cache location
  win_chocolatey_config:
    name: cacheLocation
    state: present
    value: C:\Temp

Use Background Mode for Self-Service (Business Feature):

- name: Use background mode for self-service
  win_chocolatey_feature:
    name: useBackgroundService
    state: enabled

Remove the Community Package Repository (as you have an internal repository; recommended):

- name: Disable Community Repo
  win_chocolatey_source:
    name: chocolatey
    state: absent

Testing

This collection is tested against ansible-core versions >= 2.16, 2.17, 2.18.

Testing is primarily conducted on Ubuntu runners in Azure Pipelines at the latest OS version, with the collection being targeted at a Windows 10 Enterprise 21H2 client machine, using ansible-test to run the tests included in the collection.

Contributing

If you want to develop new content for this collection or improve what's already here, the easiest way to work on the collection is to clone it into one of the configured COLLECTIONS_PATHS, and work on it there.

Testing with ansible-test

The tests directory contains configuration for running integration tests using ansible-test.

You can run the collection's test suites with the commands:

ansible-test windows-integration --docker -v --color

Support

Presently only the latest version of the collection is supported.

If you need to report an issue with the collection, please file an issue on Github.

Release Notes

Release Notes on Github

Related Information

License Information

GPL v3.0 License

See LICENSE to see full text.