From 88ccaf106be160f89a0b0c434f3500520725332a Mon Sep 17 00:00:00 2001 From: Rich Murphey Date: Thu, 10 Aug 2017 21:36:14 -0500 Subject: [PATCH] use of multiple chocolatey package names (#28046) * use of multiple chocolatey package names It might be helpful to users, to clarify whether/when must specify a single package. Users who are familiar with chocolatey may be accustomed to installing multiple packages in a single invocation of 'choco install'. I believe win_chocolatey currently accepts multiple package names when state: is latest or present. For instance, this appears to work currently: - win_chocolatey: name: >- pscx windirstat state: latest However, when state: is absent, uninstall is not performed if multiple package are specified. The chocolate.log output suggests that chocolatey is treating the multiple packages as an 'exact' name of a single package name: 2017-08-10 19:04:04,087 2424 [DEBUG] - Command line: "C:\ProgramData\chocolatey\choco.exe" list --local-only --exact pscx windirstat 2017-08-10 19:04:04,087 2424 [DEBUG] - Received arguments: list --local-only --exact pscx windirstat I find the current behavior helpful in terms of accepting multiple package names, even if uninstall must be treated differently. It might be helpful to show an example of how multiple uninstalls can be handled by looping over them. - win_chocolatey: name: "{{ item }}" state: absent with_items: - pscx - windirstat * revise per Jordan Borean. remote colon (:) from text. revise formating. * Update win_chocolatey.py --- lib/ansible/modules/windows/win_chocolatey.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/ansible/modules/windows/win_chocolatey.py b/lib/ansible/modules/windows/win_chocolatey.py index ab90ed6f99..cf54f16c01 100644 --- a/lib/ansible/modules/windows/win_chocolatey.py +++ b/lib/ansible/modules/windows/win_chocolatey.py @@ -38,6 +38,7 @@ options: name: description: - Name of the package to be installed. + - This must be a single package name. required: yes state: description: @@ -147,4 +148,20 @@ EXAMPLES = r''' 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 '''