chocolatey / chocolatey-ansible

The Chocolatey module collection for Ansible
GNU General Public License v3.0
47 stars 29 forks source link

`win_chocolatey` / `win_chocolatey_facts` - support `choco cache` #134

Open vexx32 opened 12 months ago

vexx32 commented 12 months ago

Checklist

Is Your Feature Request Related To A Problem? Please describe.

Currently, there is no way to interact with the choco cache command that was introduced in Chocolatey CLI v2.1.0.

Describe The Solution. Why is it needed?

Additional Context

The choco cache list command currently doesn't support --limit-output, so we will have a hard time making a lot of sense of the output until that is addressed:

Related Issues

No response

pauby commented 12 months ago

Do you need to make sense of the results? World checking the exit code not be enough to know if it succeeded or not.

What information would be needed and how would it be useful?

vexx32 commented 12 months ago

For cache remove that's probably enough, but if folks want to do something with the results for cache list it'll be difficult if we can't expose the data in a way that you can do things with it from a playbook.

For example, if folks want to build in some logic that retries on a task failure if and only if there's cached data that might need to be removed or skipped before retrying, they'd probably need that information. Choco exposes the current cache locations and states in its output for choco cache list, so ideally we'd be able to surface the same info here in a way folks can interact with programmatically.

Windos commented 12 months ago

That output from choco cache list does look relatively static (i.e. the format is the same whether items are in the cache or not), so it should be possible to grab the relevant info out via regex and format it as a dictionary if we don't want to wait on --limit-output support.

Equally, the changes to win_chocolatey don't rely on the changes to win_chocolatey_facts so those can be done while waiting on chocolatey/choco#3254

pauby commented 12 months ago

The format is not guaranteed to stay the way it is, so I wouldn't rely on regex'ing the info.

The majority of the work here can be done without having --limit-output available. If that is something that should be kept, we should break that out into a separate issue and focus this one on providing cache commands.