W3cubDocs

/Ansible

win_chocolatey - Manage packages using chocolatey

New in version 1.9.

Synopsis

Requirements (on host that executes module)

  • chocolatey >= 0.10.5 (will be upgraded if older)

Options

parameter required default choices comments
allow_empty_checksums
(added in 2.2)
no no
  • yes
  • no
Allow empty checksums to be used.
force
no no
  • yes
  • no
Forces install of the package (even if it already exists).
Using force will cause ansible to always report that a change was made.
ignore_checksums
(added in 2.2)
no no
  • yes
  • no
Ignore checksums altogether.
ignore_dependencies
(added in 2.1)
no no
  • yes
  • no
Ignore dependencies, only install/upgrade the package itself.
install_args
(added in 2.1)
no
Arguments to pass to the native installer.
name
yes
Name of the package to be installed.
This must be a single package name.
params
(added in 2.1)
no
Parameters to pass to the package
proxy_password
(added in 2.4)
no
Proxy password used to install chocolatey and the package.
See notes in proxy_username when dealing with double quotes in a password.
proxy_url
(added in 2.4)
no
Proxy url used to install chocolatey and the package.
proxy_username
(added in 2.4)
no
Proxy username used to install chocolatey and the package.
When dealing with a username with double quote characters ", they need to be escaped with \ beforehand. See examples for more details.
skip_scripts
(added in 2.4)
no no
  • yes
  • no
Do not run chocolateyInstall.ps1 or chocolateyUninstall.ps1 scripts.
source
no
Specify source rather than using default chocolatey repository.
state
no present
  • absent
  • downgrade
  • latest
  • present
  • reinstalled
State of the package on the system.
timeout
(added in 2.3)
no 2700
The time to allow chocolatey to finish before timing out.
aliases: execution_timeout
upgrade
no no
  • yes
  • no
If package is already installed it, try to upgrade to the latest version or to the specified version.
As of Ansible v2.3 this is deprecated, set parameter state to latest for the same result.
version
no
Specific version of the package to be installed.
Ignored when state is set to absent.

Examples

- name: Install git
  win_chocolatey:
    name: git
    state: present

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

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

- name: Install git from specified repository
  win_chocolatey:
    name: git
    source: https://someserver/api/v2/

- name: Uninstall git
  win_chocolatey:
    name: git
    state: absent

- name: install multiple packages
  win_chocolatey:
    name: '{{ item }}'
    state: absent
  with_items:
  - pscx
  - windirstat

- name: uninstall multiple packages
  win_chocolatey:
    name: '{{ item }}'
    state: absent
  with_items:
  - pscx
  - windirstat

- name: Install curl using proxy
  win_chocolatey:
    name: curl
    proxy_url: http://proxy-server:8080/
    proxy_username: joe
    proxy_password: p@ssw0rd

- name: Install curl with proxy credentials that contain quotes
  win_chocolatey:
    name: curl
    proxy_url: http://proxy-server:8080/
    proxy_username: user with \"escaped\" double quotes
    proxy_password: pass with \"escaped\" double quotes

Return Values

Common return values are documented here Return Values, the following are the fields unique to this module:

name description returned type sample
command
The full command used in the chocolatey task.
changed str choco.exe install -r --no-progress -y sysinternals --timeout 2700 --failonunfound
choco_error_log
DEPRECATED, will be removed in 2.6, use stdout instead.
changed, choco task returned a failure str sysinternals not installed. The package was not found with the source(s) listed
stdout
The stdout from the chocolatey task. The verbosity level of the messages are affected by Ansible verbosity setting, see notes for more details.
changed str Chocolatey upgraded 1/1 packages.
choco_bootstrap_output
DEPRECATED, will be removed in 2.6, use stdout instead.
changed, choco task returned a failure str Chocolatey upgraded 1/1 packages.
choco_error_cmd
DEPRECATED, will be removed in 2.6, use command instead.
changed, choco task returned a failure str choco.exe install -r --no-progress -y sysinternals --timeout 2700 --failonunfound
rc
The return code from the chocolatey task.
changed int 0

Notes

Note

  • Provide the version parameter value as a string (e.g. '6.1'), otherwise it is considered to be a floating-point number and depending on the locale could become 6,1, which will cause a failure.
  • When using verbosity 2 or less (-vv) the stdout output will be restricted.
  • When using verbosity 4 (-vvvv) the stdout output will be more verbose.
  • When using verbosity 5 (-vvvvv) the stdout output will include debug output.
  • This module will install or upgrade Chocolatey when needed.

Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.

© 2012–2017 Michael DeHaan
© 2017 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/win_chocolatey_module.html