summaryrefslogtreecommitdiffstats
path: root/ansible_collections/chocolatey
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/chocolatey')
-rw-r--r--ansible_collections/chocolatey/chocolatey/FILES.json600
-rw-r--r--ansible_collections/chocolatey/chocolatey/LICENSE674
-rw-r--r--ansible_collections/chocolatey/chocolatey/MANIFEST.json40
-rw-r--r--ansible_collections/chocolatey/chocolatey/README.md114
-rw-r--r--ansible_collections/chocolatey/chocolatey/changelogs/.plugin-cache.yaml40
-rw-r--r--ansible_collections/chocolatey/chocolatey/changelogs/changelog.yaml75
-rw-r--r--ansible_collections/chocolatey/chocolatey/changelogs/config.yaml32
-rw-r--r--ansible_collections/chocolatey/chocolatey/meta/runtime.yml1
-rw-r--r--ansible_collections/chocolatey/chocolatey/plugins/README.md31
-rw-r--r--ansible_collections/chocolatey/chocolatey/plugins/module_utils/Common.psm1185
-rw-r--r--ansible_collections/chocolatey/chocolatey/plugins/module_utils/Config.psm1134
-rw-r--r--ansible_collections/chocolatey/chocolatey/plugins/module_utils/Features.psm194
-rw-r--r--ansible_collections/chocolatey/chocolatey/plugins/module_utils/Packages.psm11160
-rw-r--r--ansible_collections/chocolatey/chocolatey/plugins/module_utils/Sources.psm1271
-rw-r--r--ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey.ps1290
-rw-r--r--ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey.py495
-rw-r--r--ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_config.ps1108
-rw-r--r--ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_config.py67
-rw-r--r--ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_facts.ps165
-rw-r--r--ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_facts.py175
-rw-r--r--ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_feature.ps164
-rw-r--r--ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_feature.py57
-rw-r--r--ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_source.ps1200
-rw-r--r--ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_source.py136
-rw-r--r--ansible_collections/chocolatey/chocolatey/requirements.txt1
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/defaults/main.yml9
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/files/test-package/package.nuspec13
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/files/test-package/tools/chocolateyUninstall.ps19
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/files/test-package/tools/chocolateyinstall.ps166
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/tasks/main.yml87
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/aliases1
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/defaults/main.yml4
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/files/bootstrap.ps125
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/meta/main.yml4
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/tasks/bootstrap_tests.yml54
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/tasks/main.yml27
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/tasks/tests.yml755
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_config/aliases1
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_config/tasks/main.yml32
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_config/tasks/tests.yml141
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_facts/aliases1
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_facts/meta/main.yml4
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_facts/tasks/main.yml96
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_facts/tasks/test_outdated.yml74
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_feature/aliases1
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_feature/filter_plugins/choco_checksum_state.py14
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_feature/tasks/main.yml20
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_feature/tasks/tests.yml95
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/aliases1
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/defaults/main.yml3
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/library/choco_source.ps166
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/tasks/main.yml31
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/tasks/tests.yml373
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/integration/vagrant-inventory.winrm11
-rw-r--r--ansible_collections/chocolatey/chocolatey/tests/requirements.txt2
55 files changed, 7129 insertions, 0 deletions
diff --git a/ansible_collections/chocolatey/chocolatey/FILES.json b/ansible_collections/chocolatey/chocolatey/FILES.json
new file mode 100644
index 00000000..69d065e6
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/FILES.json
@@ -0,0 +1,600 @@
+{
+ "files": [
+ {
+ "name": ".",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "requirements.txt",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "d5d6b7a8cb478ebae62c7a4d87369f5752f2892edd1334560be0c1e7252f7b45",
+ "format": 1
+ },
+ {
+ "name": "README.md",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "13d9b56079473d7edd2e75e5dfa8c6b660b331f46010dd4f3f01f9265fcf4eb4",
+ "format": 1
+ },
+ {
+ "name": "plugins",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "plugins/README.md",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "c82ee692702ec1dd604cdbc38ff252114e5204e1b0627045a66c9451e7a918ac",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/win_chocolatey_feature.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "57e80df8e6dcd192fc561a0a7b46480cf763fef9f44f8b892221f75031e3a118",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/win_chocolatey_config.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "92bcc6c2bad15c2a283ee7fe0cecd734e9b240e40f87e6c3aeafe0f9791592f5",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/win_chocolatey.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "063ec818ff51f33a9aa4608dad943ca9ffcbe53b84821ee2bdcf13d276dae412",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/win_chocolatey_config.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "303591e8fea73ad3c206d84a6e46bdb7840be79ccc00308b9e86b1cc933bcd86",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/win_chocolatey_source.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "b0812f9701b0e67a680a4c1b47d5e1862d8c2d94c341cc407914f67e10b90481",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/win_chocolatey_source.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f8b44537cd8e9a2dcecea5ddf33e83975876dc982b6253a7be6618419d30c4d1",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/win_chocolatey_facts.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a9c8236d8831c9ffbb6860256577c216e3063c93f3eb8b6d91a1b9d724b99e68",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/win_chocolatey_facts.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "0a1a372c739f13c3c312fba6ea107a859f17a6d2a3a839b2ee5c700028857b8a",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/win_chocolatey_feature.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "b927db93d38b0a840956238d25d3887996c863e4c0dea7e90811c91922d7afeb",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/win_chocolatey.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "82abc61f449f7a19ddcfb4c8c26f732fb314455ab4328cdb26c6bf83a091f00f",
+ "format": 1
+ },
+ {
+ "name": "plugins/module_utils",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "plugins/module_utils/Sources.psm1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "02c9b473a1f9bb85d9a6b03a04d1cd80469e229d7cf8ae47edc12be123a807b1",
+ "format": 1
+ },
+ {
+ "name": "plugins/module_utils/Features.psm1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "5921060e1db8ab04b0e409e78a134a40f21a35f3363231eec653a0ad916aa83a",
+ "format": 1
+ },
+ {
+ "name": "plugins/module_utils/Common.psm1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "b3061bf96b117d90f9d114ef6ee408379d6fdee885c164d2ddf3b6db058925da",
+ "format": 1
+ },
+ {
+ "name": "plugins/module_utils/Packages.psm1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "621785112b5fe3552784991b836f19caf6a20eeb7819c5ae88ef974b95f9a05e",
+ "format": 1
+ },
+ {
+ "name": "plugins/module_utils/Config.psm1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "20d1309ebe849bd52dd14b5d70219906708ad54b6bd4ecd81d0eb72c3055b763",
+ "format": 1
+ },
+ {
+ "name": "changelogs",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "changelogs/.plugin-cache.yaml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "460cd508cdfe4e78550d41f82799da2b385c2ef932c6ce2def9586242c7291b1",
+ "format": 1
+ },
+ {
+ "name": "changelogs/config.yaml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "86f5c20527e0f4c34f5a146b7f75abf25ccb80ad9773cd29d60818172bd1a5f7",
+ "format": 1
+ },
+ {
+ "name": "changelogs/changelog.yaml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "ae16d31c0405f5105938ade0d840298a1a54a060fedf5deb2046165b512f994e",
+ "format": 1
+ },
+ {
+ "name": "meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "meta/runtime.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "00d55e0821a4dc0ffa87a17190e1a05365c96cec54ab33c45f6ba649d0e5e6ab",
+ "format": 1
+ },
+ {
+ "name": "LICENSE",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986",
+ "format": 1
+ },
+ {
+ "name": "tests",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/requirements.txt",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "2aab9022ec2491bbca95b4b3007a18ae31dd82c0314e70ad30558c4767568b64",
+ "format": 1
+ },
+ {
+ "name": "tests/integration",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_source",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_source/library",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_source/library/choco_source.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "671eebe42952a97e794f931fa3adf720ede5ff7f70f87e47eb3cb829c88336b0",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_source/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "5663f103af71f218bb9a50a0d25b7dd6cc83f8761d3ef3c93c7f697f6b6bd1c0",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_source/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_source/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e3d3968783e4dd78a412424ffe5f39b02bab9ff07e07b42e91e56eedc3f6a123",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_source/tasks/tests.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "5248736132833a34099a1e498b5d0bff891eba15cc7d7c2696b4a38157be4a51",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_source/defaults",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_source/defaults/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "8ce2dd60dd1e390b58a66799872b0c963333260d073dc422c84b4e6f67e7a243",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_feature",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_feature/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "5663f103af71f218bb9a50a0d25b7dd6cc83f8761d3ef3c93c7f697f6b6bd1c0",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_feature/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_feature/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "c8ff10835a1cd7c34875cae9e11ad27247b0c2b0f94ea1ba0ba15e09a537b84f",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_feature/tasks/tests.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "768167bb9b6e2c7668086534fb80f9c2a6c75a153a9e01134c67ab53aa9886be",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_feature/filter_plugins",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_feature/filter_plugins/choco_checksum_state.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "13f3796b9fec73258e34c83d4fd9441c97551c3c8603822c3e1e3db4878dc59d",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey/files",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey/files/bootstrap.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e0dfdf67688de03cf518902615d62e15fb1bd6d25b8cb8ffdb833e696dc9bc9e",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "d7127ace6c1571fdf343a57b543cd35ed5b5181a330ab6e79ea892bf1ffff082",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "2fb43545e78cd3c17433428ac618a77d84115e07b942e1c7815a4f17d5091d5a",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey/tasks/tests.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "17e5bfc912ffa7f0a98fd4bc47ed3e9435a0a86007a301d678f826e52eaee5a7",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey/tasks/bootstrap_tests.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "d9a65b1816c77b399e1bb743d07f0170268ecf5a7ad8be47be0ffd36d32be547",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f2ff87de8d6a548997a43bb73d09427cdd67389a03cd75870425a16ccbe2e59e",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey/defaults",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey/defaults/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "01a04aa89bcde328dde931e7edead0967c33345fcb54d40f62f66d54044499f9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_facts",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_facts/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "7dc17a9cfdc1347716138c582a57dc85f59309dc5a9bd610cb12334603f3746e",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_facts/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_facts/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "8afc9a00fd56b053c92c47c9ff4ae026a119143807aaab79bb4b969c5a954d50",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_facts/tasks/test_outdated.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "522a75a24ea8ddee34a9bc0f509941d0806933536dca3eb05553cb429f7dd21c",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_facts/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_facts/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f2ff87de8d6a548997a43bb73d09427cdd67389a03cd75870425a16ccbe2e59e",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_chocolatey",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_chocolatey/files",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_chocolatey/files/test-package",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_chocolatey/files/test-package/tools",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_chocolatey/files/test-package/tools/chocolateyinstall.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "76675cb944e6ae4a2f9e0064eeb9dca1daef7b3c7a8fcfa8b21fe2831848083d",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_chocolatey/files/test-package/tools/chocolateyUninstall.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "8910b0e63722f580b03fcf061b7bb50475ff4794af3ee6e2f9e7a01e526434d8",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_chocolatey/files/test-package/package.nuspec",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "4c34e690d87231f1f5739293de8d6d354fa13c454801914583bbec7e2b615197",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_chocolatey/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_chocolatey/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "2a91149efc93e253c2570e944623c5337eecbea461b55eb374db77d571a6c718",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_chocolatey/defaults",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_chocolatey/defaults/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "5b3b2331959ebc286052039c9491e05e7d1044f3c5af3e493626333d09f46c64",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_config",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_config/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "5663f103af71f218bb9a50a0d25b7dd6cc83f8761d3ef3c93c7f697f6b6bd1c0",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_config/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_config/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "232a0d4ea9dec480dca82da0d6a0793f856ec931e2da647d8b3ba21a7f8cfd70",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_chocolatey_config/tasks/tests.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "036b46a3a288f6e0340979b08a6593ebaa866156767c72e3d302acf592eb9601",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/vagrant-inventory.winrm",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "fb2a78d84c21c105be7960d69f267495a6e46d3f5593fcd1c40c99d11c96fb9e",
+ "format": 1
+ }
+ ],
+ "format": 1
+} \ No newline at end of file
diff --git a/ansible_collections/chocolatey/chocolatey/LICENSE b/ansible_collections/chocolatey/chocolatey/LICENSE
new file mode 100644
index 00000000..f288702d
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<https://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<https://www.gnu.org/licenses/why-not-lgpl.html>.
diff --git a/ansible_collections/chocolatey/chocolatey/MANIFEST.json b/ansible_collections/chocolatey/chocolatey/MANIFEST.json
new file mode 100644
index 00000000..4b270640
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/MANIFEST.json
@@ -0,0 +1,40 @@
+{
+ "collection_info": {
+ "namespace": "chocolatey",
+ "name": "chocolatey",
+ "version": "1.4.0",
+ "authors": [
+ "Joel Francis (@vexx32)",
+ "Adil Leghari (@adilio)",
+ "Trond Hindenes (@trondhindenes)",
+ "Peter Mounce (@petemounce)",
+ "Pepe Barbe (@elventear)",
+ "Adam Keech (@smadam813)",
+ "Pierre Templier (@ptemplier)",
+ "Jordan Borean (@jborean93)"
+ ],
+ "readme": "README.md",
+ "tags": [
+ "chocolatey",
+ "windows",
+ "packaging",
+ "package_management"
+ ],
+ "description": "Manage packages using Chocolatey.",
+ "license": [],
+ "license_file": "LICENSE",
+ "dependencies": {},
+ "repository": "https://github.com/chocolatey/chocolatey-ansible",
+ "documentation": "https://github.com/chocolatey/chocolatey-ansible",
+ "homepage": "https://github.com/chocolatey/chocolatey-ansible",
+ "issues": "https://github.com/chocolatey/chocolatey-ansible/issues"
+ },
+ "file_manifest_file": {
+ "name": "FILES.json",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "9acc2eb046f478ff4b091585830987e32bd6ae0a4f4451ccd7e3c484be502f6e",
+ "format": 1
+ },
+ "format": 1
+} \ No newline at end of file
diff --git a/ansible_collections/chocolatey/chocolatey/README.md b/ansible_collections/chocolatey/chocolatey/README.md
new file mode 100644
index 00000000..7728a583
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/README.md
@@ -0,0 +1,114 @@
+# Ansible Collection: chocolatey.chocolatey
+
+| Build Status |
+| :----------------------------------------------: |
+| [![Build Status][pipeline-badge]][pipeline-link] |
+
+The `chocolatey.chocolatey` Ansible Collection includes the modules required to configure Chocolatey, as well as manage packages on Windows using Chocolatey.
+
+## Ansible version compatibility
+
+This collection has been tested against the following Ansible versions:
+**>= 2.12, 2.13, 2.14**
+
+## Installation and Usage
+
+### Installing the Collection from Ansible Galaxy
+
+Before using the Chocolatey collection, you need to install it with the `ansible-galaxy` CLI:
+
+ ansible-galaxy collection install chocolatey.chocolatey
+
+You can also include it in a `requirements.yml` file and install it via `ansible-galaxy collection install -r requirements.yml` using the format:
+
+```yaml
+collections:
+- name: chocolatey.chocolatey
+```
+
+### Modules
+
+This collection provides the following modules you can use in your own roles:
+
+| 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 |
+
+### Examples
+
+Some example usages of the modules in this collection are below.
+
+Upgrade all packages with Chocolatey:
+
+```yaml
+- name: Upgrade installed packages
+ win_chocolatey:
+ name: all
+ state: latest
+```
+
+Install version 6.6 of `notepadplusplus`:
+
+```yaml
+- name: Install notepadplusplus version 6.6
+ win_chocolatey:
+ name: notepadplusplus
+ version: '6.6'
+```
+
+Set the Chocolatey cache location:
+
+```yaml
+- name: Set the cache location
+ win_chocolatey_config:
+ name: cacheLocation
+ state: present
+ value: C:\Temp
+```
+
+Use Background Mode for Self-Service (Business Feature):
+
+```yaml
+- 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):
+
+```yaml
+- name: Disable Community Repo
+ win_chocolatey_source:
+ name: chocolatey
+ state: absent
+```
+
+## Testing and Development
+
+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`](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#collections-paths), and work on it there.
+
+### Testing with `ansible-test`
+
+The `tests` directory contains configuration for running integration tests using [`ansible-test`](https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html).
+
+You can run the collection's test suites with the commands:
+
+```code
+ansible-test windows-integration --docker -v --color
+```
+
+## License
+
+GPL v3.0 License
+
+See [LICENSE](LICENSE) to see full text.
+
+<!-- Link Targets -->
+
+[pipeline-link]: https://dev.azure.com/ChocolateyCI/Chocolatey-Ansible/_build/latest?definitionId=2&branchName=master
+[pipeline-badge]: https://dev.azure.com/ChocolateyCI/Chocolatey-Ansible/_apis/build/status/Chocolatey%20Collection%20CI?branchName=master
diff --git a/ansible_collections/chocolatey/chocolatey/changelogs/.plugin-cache.yaml b/ansible_collections/chocolatey/chocolatey/changelogs/.plugin-cache.yaml
new file mode 100644
index 00000000..58759d34
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/changelogs/.plugin-cache.yaml
@@ -0,0 +1,40 @@
+plugins:
+ become: {}
+ cache: {}
+ callback: {}
+ cliconf: {}
+ connection: {}
+ httpapi: {}
+ inventory: {}
+ lookup: {}
+ module:
+ win_chocolatey:
+ description: Manage packages using chocolatey
+ name: win_chocolatey
+ namespace: ''
+ version_added: 0.1.9
+ win_chocolatey_config:
+ description: Manages Chocolatey config settings
+ name: win_chocolatey_config
+ namespace: ''
+ version_added: 0.2.7
+ win_chocolatey_facts:
+ description: Create a facts collection for Chocolatey
+ name: win_chocolatey_facts
+ namespace: ''
+ version_added: 0.2.8
+ win_chocolatey_feature:
+ description: Manages Chocolatey features
+ name: win_chocolatey_feature
+ namespace: ''
+ version_added: 0.2.7
+ win_chocolatey_source:
+ description: Manages Chocolatey sources
+ name: win_chocolatey_source
+ namespace: ''
+ version_added: 0.2.7
+ netconf: {}
+ shell: {}
+ strategy: {}
+ vars: {}
+version: 1.1.0
diff --git a/ansible_collections/chocolatey/chocolatey/changelogs/changelog.yaml b/ansible_collections/chocolatey/chocolatey/changelogs/changelog.yaml
new file mode 100644
index 00000000..3c3f9c5b
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/changelogs/changelog.yaml
@@ -0,0 +1,75 @@
+# See: https://github.com/ansible-community/antsibull-changelog/blob/main/docs/changelog.yaml-format.md
+ancestor: null
+releases:
+ 1.4.0:
+ release_date: '2022-12-15'
+ changes:
+ release_summary: |
+ 1.4.0 - Deprecate side by side installs, bug fixes, and adding TLS options for bootstrapping.
+ major_changes:
+ - win_chocolatey - Allow users to select the TLS versions used for bootstrapping Chocolatey installation.
+ deprecated_features:
+ - win_chocolatey - Deprecate side-by-side installs.
+ bugfixes:
+ - win_chocolatey - Module fails to execute if powershell version is older than version 5.
+ 1.3.1:
+ release_date: '2022-10-12'
+ changes:
+ release_summary: |
+ 1.3.1 - Bugfix for an issue introduced in collection version 1.3.0
+ bugfixes:
+ - win_chocolatey - Collection version 1.3.0 fails to install packages with explicit version number and state set to present.
+ 1.3.0:
+ release_date: '2022-06-28'
+ changes:
+ release_summary: |
+ 1.3.0 - Add support for bootstrap_script and returning outdated packages
+ major_changes:
+ - win_chocolatey - Added bootstrap_script option to allow users to target a script URL for installing Chocolatey on clients.
+ - win_chocolatey_facts - Added outdated packages list to data returned.
+ minor_changes:
+ - All collection modules - assorted style/linting fixes in documentation and scripts.
+ 1.2.0:
+ release_date: '2022-02-09'
+ changes:
+ release_summary: |
+ 1.2.0 - Bugfixes, support for choco_args and state: upgrade
+ major_changes:
+ - win_chocolatey - Added choco_args option to pass additional arguments directly to Chocolatey.
+ minor_changes:
+ - 'win_chocolatey - Added state: upgrade as an alias for state: latest.'
+ - win_chocolatey - Improved automatic URL handling for getting the install.ps1 script from a custom source URL.
+ - 'win_chocolatey - Removed warning for installing Chocolatey if when specifically installing it with `name: chocolatey`.'
+ - win_chocolatey - Improved handling of Chocolatey bootstrapping installation script.
+ - All modules - Ported away from the Ansible.Legacy format, using Ansible.Basic.Module instead.
+ 1.1.0:
+ release_date: '2021-04-05'
+ changes:
+ release_summary: |
+ 1.1.0 - Bugfixes, behaviour reworks, support for --remove-dependencies
+ minor_changes:
+ - win_chocolatey - Support for removing dependencies added with remove_dependencies option.
+ bugfixes:
+ - win_chocolatey - Module can now handle uninstallation correctly for both side-by-side and normal package installations.
+ - All modules - Added fallback to default choco install path for auxiliary modules to workaround issue in OpenSSH library under Windows. (https://github.com/PowerShell/Win32-OpenSSH#1329)
+ 1.0.0:
+ release_date: '2020-03-30'
+ changes:
+ release_summary: |
+ Initial Release
+ modules:
+ - name: win_chocolatey
+ description: Manage packages using chocolatey
+ namespace: ''
+ - name: win_chocolatey_config
+ description: Manages Chocolatey config settings
+ namespace: ''
+ - name: win_chocolatey_facts
+ description: Create a facts collection for Chocolatey
+ namespace: ''
+ - name: win_chocolatey_feature
+ description: Manages Chocolatey features
+ namespace: ''
+ - name: win_chocolatey_source
+ description: Manages Chocolatey sources
+ namespace: ''
diff --git a/ansible_collections/chocolatey/chocolatey/changelogs/config.yaml b/ansible_collections/chocolatey/chocolatey/changelogs/config.yaml
new file mode 100644
index 00000000..00d40364
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/changelogs/config.yaml
@@ -0,0 +1,32 @@
+changelog_filename_template: ../CHANGELOG.rst
+changelog_filename_version_depth: 0
+changes_file: changelog.yaml
+changes_format: combined
+ignore_other_fragment_extensions: true
+keep_fragments: false
+mention_ancestor: true
+new_plugins_after_name: removed_features
+notesdir: fragments
+prelude_section_name: release_summary
+prelude_section_title: Release Summary
+sanitize_changelog: true
+sections:
+- - major_changes
+ - Major Changes
+- - minor_changes
+ - Minor Changes
+- - breaking_changes
+ - Breaking Changes / Porting Guide
+- - deprecated_features
+ - Deprecated Features
+- - removed_features
+ - Removed Features (previously deprecated)
+- - security_fixes
+ - Security Fixes
+- - bugfixes
+ - Bugfixes
+- - known_issues
+ - Known Issues
+title: Chocolatey.Chocolatey
+trivial_section_name: trivial
+use_fqcn: true
diff --git a/ansible_collections/chocolatey/chocolatey/meta/runtime.yml b/ansible_collections/chocolatey/chocolatey/meta/runtime.yml
new file mode 100644
index 00000000..132a93dc
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/meta/runtime.yml
@@ -0,0 +1 @@
+requires_ansible: '>=2.10.0'
diff --git a/ansible_collections/chocolatey/chocolatey/plugins/README.md b/ansible_collections/chocolatey/chocolatey/plugins/README.md
new file mode 100644
index 00000000..6541cf7c
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/plugins/README.md
@@ -0,0 +1,31 @@
+# Collections Plugins Directory
+
+This directory can be used to ship various plugins inside an Ansible collection. Each plugin is placed in a folder that
+is named after the type of plugin it is in. It can also include the `module_utils` and `modules` directory that
+would contain module utils and modules respectively.
+
+Here is an example directory of the majority of plugins currently supported by Ansible:
+
+```
+└── plugins
+ ├── action
+ ├── become
+ ├── cache
+ ├── callback
+ ├── cliconf
+ ├── connection
+ ├── filter
+ ├── httpapi
+ ├── inventory
+ ├── lookup
+ ├── module_utils
+ ├── modules
+ ├── netconf
+ ├── shell
+ ├── strategy
+ ├── terminal
+ ├── test
+ └── vars
+```
+
+A full list of plugin types can be found at [Working With Plugins](https://docs.ansible.com/ansible/2.9/plugins/plugins.html). \ No newline at end of file
diff --git a/ansible_collections/chocolatey/chocolatey/plugins/module_utils/Common.psm1 b/ansible_collections/chocolatey/chocolatey/plugins/module_utils/Common.psm1
new file mode 100644
index 00000000..ac376637
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/plugins/module_utils/Common.psm1
@@ -0,0 +1,185 @@
+#AnsibleRequires -CSharpUtil Ansible.Basic
+
+$script:module = $null
+
+function Set-ActiveModule {
+ <#
+ .SYNOPSIS
+ Sets the currently active Ansible module.
+
+ .DESCRIPTION
+ Caches a reference to the currently active Ansible module object that
+ to be retrieved and used by other commands, so we can minimise the need
+ to specify values for `-Module` parameters on every command we use.
+ #>
+ [CmdletBinding()]
+ param(
+ # The Ansible.Basic.AnsibleModule to set as active.
+ [Parameter(Mandatory = $true)]
+ [Ansible.Basic.AnsibleModule]
+ $Module
+ )
+
+ $script:module = $Module
+}
+
+function Get-AnsibleModule {
+ <#
+ .SYNOPSIS
+ Retrieves the currently active module object.
+
+ .DESCRIPTION
+ Returns the currently cached module object.
+ #>
+ [CmdletBinding()]
+ param()
+
+ $script:module
+}
+
+function Get-ChocolateyCommand {
+ <#
+ .SYNOPSIS
+ Retrieves a CommandInfo object for `choco.exe` if it is present on the system.
+
+ .DESCRIPTION
+ Returns either a CommandInfo object which contains the path the `choco.exe`
+ or registers a task failure and exits if it cannot be found.
+ #>
+ [CmdletBinding()]
+ param(
+ # If provided, does not terminate the task run when choco.exe is not found.
+ [Parameter()]
+ [switch]
+ $IgnoreMissing
+ )
+
+ $command = Get-Command -Name choco.exe -CommandType Application -ErrorAction SilentlyContinue
+
+ if (-not $command) {
+ $installDir = if ($env:ChocolateyInstall) {
+ $env:ChocolateyInstall
+ }
+ else {
+ "$env:SYSTEMDRIVE\ProgramData\Chocolatey"
+ }
+
+ $command = Get-Command -Name "$installDir\bin\choco.exe" -CommandType Application -ErrorAction SilentlyContinue
+
+ if (-not ($command -or $IgnoreMissing)) {
+ $message = "Failed to find Chocolatey installation, make sure choco.exe is in the PATH env value"
+ Assert-TaskFailed -Message $message
+ }
+ }
+
+ $command
+}
+
+function Assert-TaskFailed {
+ <#
+ .SYNOPSIS
+ Notifies Ansible that the task failed, and exits after providing the necessary details.
+
+ .DESCRIPTION
+ Exits the current Ansible task with a failure state, recording a message as well as
+ any other relevant information for the current task.
+ #>
+ [CmdletBinding()]
+ param(
+ # Message to be returned to the task runner, indicating why the failure happened.
+ [Parameter(Mandatory = $true)]
+ [string]
+ $Message,
+
+ # The Ansible module object to register the failure with.
+ # Defaults to the currently active module.
+ [Parameter()]
+ [Ansible.Basic.AnsibleModule]
+ $Module = (Get-AnsibleModule),
+
+ # The native command call that resulted in the error, if any.
+ [Parameter()]
+ [string]
+ $Command,
+
+ # A hashtable containing `stdout`, `stderr`, and `rc` keys resulting from
+ # a native command execution, which will be copied to the module's Result
+ # dictionary before returning the fail state.
+ [Parameter()]
+ [hashtable]
+ $CommandResult,
+
+ # An exception to provide to the `$module.ExitJson()` method with further
+ # information about the error, if any.
+ [Parameter()]
+ [Exception]
+ $Exception
+ )
+
+ if ($null -ne $CommandResult) {
+ $resultKeys = 'rc', 'stdout', 'stderr'
+
+ foreach ($key in $resultKeys) {
+ $Module.Result.$key = $CommandResult.$key
+ }
+ }
+
+ if ($null -ne $Command) {
+ $Module.Result.command = $Command
+ }
+
+ if ($null -ne $Exception) {
+ $Module.FailJson($Message, $Exception)
+ }
+ else {
+ $Module.FailJson($Message)
+ }
+}
+
+function ConvertFrom-Stdout {
+ <#
+ .SYNOPSIS
+ Trims and splits the stdout from the given result so that individual
+ lines can be processed.
+
+ .DESCRIPTION
+ Retrieves the `stdout` key from the given dictionary and trims and splits
+ the value in a standardised way.
+ #>
+ [CmdletBinding()]
+ param(
+ # The command result dictionary from a native command invocation.
+ [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
+ [hashtable]
+ $CommandResult
+ )
+ process {
+ $CommandResult.stdout.Trim() -split "\r?\n" | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }
+ }
+}
+
+function Set-TaskResultChanged {
+ <#
+ .SYNOPSIS
+ Flags the task result for the module as being changed.
+ #>
+ [CmdletBinding()]
+ param(
+ # The module to set the task result on.
+ # Defaults to the currently active module.
+ [Parameter()]
+ [Ansible.Basic.AnsibleModule]
+ $Module = (Get-AnsibleModule)
+ )
+
+ $Module.Result.changed = $true
+}
+
+Export-ModuleMember -Function @(
+ 'Get-ChocolateyCommand'
+ 'Get-AnsibleModule'
+ 'ConvertFrom-Stdout'
+ 'Set-ActiveModule'
+ 'Set-TaskResultChanged'
+ 'Assert-TaskFailed'
+)
diff --git a/ansible_collections/chocolatey/chocolatey/plugins/module_utils/Config.psm1 b/ansible_collections/chocolatey/chocolatey/plugins/module_utils/Config.psm1
new file mode 100644
index 00000000..693b2051
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/plugins/module_utils/Config.psm1
@@ -0,0 +1,134 @@
+#Requires -Module Ansible.ModuleUtils.ArgvParser
+#Requires -Module Ansible.ModuleUtils.CommandUtil
+
+#AnsibleRequires -PowerShell ansible_collections.chocolatey.chocolatey.plugins.module_utils.Common
+
+function Get-ChocolateyConfig {
+ <#
+ .SYNOPSIS
+ Outputs a hashtable containing the Chocolatey configuration information.
+
+ .DESCRIPTION
+ Inspects the `chocolatey.config` file from the current Chocolatey installation
+ and creates a hashtable containing all the configuration values.
+ #>
+ [CmdletBinding()]
+ param(
+ # A CommandInfo object containing the path to choco.exe.
+ [Parameter(Mandatory = $true)]
+ [System.Management.Automation.CommandInfo]
+ $ChocoCommand
+ )
+
+ # `choco config list -r` does not display easily parsable config entries.
+ # It contains config/sources/feature in the same output, and is in the
+ # structure `configKey = configValue | description`.
+ # If the key or value contains a `=` or `|`, it will make it quite hard to
+ # parse it, compared to reading a well-formed XML file with the same values.
+ $chocoInstall = Split-Path -LiteralPath (Split-Path -LiteralPath $ChocoCommand.Path)
+ $configPath = "$chocoInstall\config\chocolatey.config"
+
+ if (-not (Test-Path -LiteralPath $configPath)) {
+ $message = "Could not find Chocolatey config file at expected path '$configPath'"
+ Assert-TaskFailed -Message $message
+ }
+
+ try {
+ [xml]$configXml = Get-Content -LiteralPath $configPath
+ }
+ catch {
+ $message = "Failed to parse Chocolatey config file at '$configPath': $($_.Exception.Message)"
+ Assert-TaskFailed -Message $message -Exception $_
+ }
+
+ $config = @{}
+
+ foreach ($node in $configXml.chocolatey.config.GetEnumerator()) {
+ # try to parse as a bool, then an int, fallback to string
+ $value = try {
+ [System.Boolean]::Parse($node.value)
+ }
+ catch {
+ try {
+ [System.Int32]::Parse($node.value)
+ }
+ catch {
+ $node.value
+ }
+ }
+
+ $config[$node.key] = $value
+ }
+
+ $config
+}
+
+function Remove-ChocolateyConfig {
+ <#
+ .SYNOPSIS
+ Unsets the given Chocolatey configuration entry, reverting it to the default value.
+ #>
+ [CmdletBinding()]
+ param(
+ # A CommandInfo object containing the path to choco.exe.
+ [Parameter(Mandatory = $true)]
+ [System.Management.Automation.CommandInfo]
+ $ChocoCommand,
+
+ # The name of the configuration entry to unset.
+ [Parameter(Mandatory = $true)]
+ [string]
+ $Name
+ )
+
+ $command = Argv-ToString -Arguments @(
+ $ChocoCommand.Path
+ "config", "unset"
+ "--name", $Name
+ )
+ $result = Run-Command -Command $command
+
+ if ($result.rc -ne 0) {
+ $message = "Failed to unset Chocolatey config for '$Name': $($result.stderr)"
+ Assert-TaskFailed -Message $message -CommandResult $result
+ }
+}
+
+function Set-ChocolateyConfig {
+ <#
+ .SYNOPSIS
+ Sets the given Chocolatey configuration entry to the requested value.
+ #>
+ [CmdletBinding()]
+ param(
+ # A CommandInfo object containing the path to choco.exe.
+ [Parameter(Mandatory = $true)]
+ [System.Management.Automation.CommandInfo]
+ $ChocoCommand,
+
+ # The name of the configuration entry to set.
+ [Parameter(Mandatory = $true)]
+ [string]
+ $Name,
+
+ # The value to set the configuration entry to.
+ [Parameter(Mandatory = $true)]
+ [string]
+ $Value
+ )
+
+ $command = Argv-ToString -Arguments @(
+ $ChocoCommand.Path
+ "config", "set"
+ "--name", $Name
+ "--value", $Value
+ )
+ $result = Run-Command -Command $command
+
+ if ($result.rc -ne 0) {
+ $message = "Failed to set Chocolatey config for '$Name' to '$Value': $($result.stderr)"
+ Assert-TaskFailed -Message $message -CommandResult $result
+ }
+}
+
+Export-ModuleMember -Function Get-ChocolateyConfig, Set-ChocolateyConfig, Remove-ChocolateyConfig
diff --git a/ansible_collections/chocolatey/chocolatey/plugins/module_utils/Features.psm1 b/ansible_collections/chocolatey/chocolatey/plugins/module_utils/Features.psm1
new file mode 100644
index 00000000..991e57e1
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/plugins/module_utils/Features.psm1
@@ -0,0 +1,94 @@
+#Requires -Module Ansible.ModuleUtils.ArgvParser
+#Requires -Module Ansible.ModuleUtils.CommandUtil
+
+#AnsibleRequires -PowerShell ansible_collections.chocolatey.chocolatey.plugins.module_utils.Common
+
+function Get-ChocolateyFeature {
+ <#
+ .SYNOPSIS
+ Retrieves a hashtable containing the feature states of all Chocolatey features.
+
+ .DESCRIPTION
+ Outputs a hashtable where the keys correspond to configuration names, and the
+ values are set to `$true` if the feature is enabled, and `$false` otherwise.
+ #>
+ [CmdletBinding()]
+ param(
+ # A CommandInfo object containing the path to choco.exe.
+ [Parameter(Mandatory = $true)]
+ [System.Management.Automation.CommandInfo]
+ $ChocoCommand
+ )
+
+ $arguments = @(
+ $ChocoCommand.Path
+ "feature", "list"
+ "-r"
+ )
+
+ $command = Argv-ToString -Arguments $arguments
+ $result = Run-Command -Command $command
+
+ if ($result.rc -ne 0) {
+ $message = "Failed to list Chocolatey features: $($result.stderr)"
+ Assert-TaskFailed -Message $message -CommandResult $result
+ }
+
+ # Build a hashtable of features where each feature name has a value of
+ # either `$true` (enabled), or `$false` (disabled)
+ $features = @{}
+ $result |
+ ConvertFrom-Stdout |
+ Where-Object { -not [string]::IsNullOrWhiteSpace($_) } |
+ ForEach-Object {
+ $name, $state, $null = $_ -split "\|"
+ $features.$name = $state -eq "Enabled"
+ }
+
+ $features
+}
+
+function Set-ChocolateyFeature {
+ <#
+ .SYNOPSIS
+ Sets the target Chocolatey feature to the desired state.
+
+ .DESCRIPTION
+ If the `-Enabled` switch is not provided, disables the target Chocolatey feature.
+ Otherwise, enables the target Chocolatey feature.
+ #>
+ [CmdletBinding()]
+ param(
+ # A CommandInfo object containing the path to choco.exe.
+ [Parameter(Mandatory = $true)]
+ [System.Management.Automation.CommandInfo]
+ $ChocoCommand,
+
+ # The name of the target Chocolatey feature.
+ [Parameter(Mandatory = $true)]
+ [string]
+ $Name,
+
+ # If set, enables the targeted feature.
+ [Parameter()]
+ [switch]
+ $Enabled
+ )
+
+ $stateCommand = if ($Enabled) { "enable" } else { "disable" }
+ $arguments = @(
+ $ChocoCommand.Path
+ "feature", $stateCommand
+ "--name", $Name
+ )
+
+ $command = Argv-ToString -Arguments $arguments
+ $result = Run-Command -Command $command
+
+ if ($result.rc -ne 0) {
+ $message = "Failed to set Chocolatey feature $Name to $($stateCommand): $($result.stderr)"
+ Assert-TaskFailed -Message $message -CommandResult $result
+ }
+}
+
+Export-ModuleMember -Function Get-ChocolateyFeature, Set-ChocolateyFeature
diff --git a/ansible_collections/chocolatey/chocolatey/plugins/module_utils/Packages.psm1 b/ansible_collections/chocolatey/chocolatey/plugins/module_utils/Packages.psm1
new file mode 100644
index 00000000..4944b85e
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/plugins/module_utils/Packages.psm1
@@ -0,0 +1,1160 @@
+#Requires -Module Ansible.ModuleUtils.ArgvParser
+#Requires -Module Ansible.ModuleUtils.CommandUtil
+
+#AnsibleRequires -PowerShell ansible_collections.chocolatey.chocolatey.plugins.module_utils.Common
+
+# As of chocolatey 0.9.10, non-zero success exit codes can be returned
+# See https://github.com/chocolatey/choco/issues/512#issuecomment-214284461
+$script:successExitCodes = (0, 1605, 1614, 1641, 3010)
+
+function Get-ChocolateyOutdated {
+ <#
+ .SYNOPSIS
+ Retrieves the list of Chocolatey packages, already present on the local system, for which an update is available.
+ #>
+ [CmdletBinding()]
+ param(
+ # A CommandInfo object containing the path to choco.exe.
+ [Parameter(Mandatory = $true)]
+ [System.Management.Automation.CommandInfo]
+ $ChocoCommand
+ )
+
+ $command = Argv-ToString -Arguments @(
+ $ChocoCommand.Path
+ "outdated"
+ "--limit-output"
+ )
+ $result = Run-Command -Command $command
+
+ # Chocolatey v0.10.12 introduced enhanced exit codes, 2 means no results, e.g. no package
+ if ($result.rc -notin @(0, 2)) {
+ $message = 'Error checking outdated status for installed chocolatey packages'
+ Assert-TaskFailed -Message $message -Command $command -CommandResult $result
+ }
+
+ $result |
+ ConvertFrom-Stdout |
+ ForEach-Object {
+ # Sanity check in case additional output is added in the future.
+ if ($_.Contains('|')) {
+ $package, $current_version, $available_version, $pinned, $null = $_.Split('|')
+
+ @{
+ package = $package
+ current_version = $current_version
+ available_version = $available_version
+ pinned = [System.Boolean]::Parse($pinned)
+ }
+ }
+ }
+}
+
+function Get-ChocolateyPackage {
+ <#
+ .SYNOPSIS
+ Retrieves the list of Chocolatey packages already present on the local system.
+ #>
+ [CmdletBinding()]
+ param(
+ # A CommandInfo object containing the path to choco.exe.
+ [Parameter(Mandatory = $true)]
+ [System.Management.Automation.CommandInfo]
+ $ChocoCommand,
+
+ # The version of packages to retrieve. Defaults to all package versions.
+ [Parameter()]
+ [string]
+ $Version
+ )
+
+ $command = Argv-ToString -Arguments @(
+ $ChocoCommand.Path
+ "list"
+ "--local-only"
+ "--limit-output"
+
+ if ($Version) {
+ '--version', $Version
+ }
+ else {
+ '--all-versions'
+ }
+ )
+ $result = Run-Command -Command $command
+
+ # Chocolatey v0.10.12 introduced enhanced exit codes, 2 means no results, e.g. no package
+ if ($result.rc -notin @(0, 2)) {
+ $message = 'Error checking installation status for chocolatey packages'
+ Assert-TaskFailed -Message $message -Command $command -CommandResult $result
+ }
+
+ $result |
+ ConvertFrom-Stdout |
+ ForEach-Object {
+ # Sanity check in case additional output is added in the future.
+ if ($_.Contains('|')) {
+ $package, $version, $null = $_.Split('|')
+
+ @{
+ package = $package
+ version = $version
+ }
+ }
+ }
+}
+
+function Get-ChocolateyPackageVersion {
+ <#
+ .SYNOPSIS
+ Gets entries of a specific Chocolatey package installed on the local system, if any.
+ #>
+ [CmdletBinding()]
+ param(
+ # A CommandInfo object containing the path to choco.exe.
+ [Parameter(Mandatory = $true)]
+ [System.Management.Automation.CommandInfo]
+ $ChocoCommand,
+
+ # The name of the package to look for.
+ [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
+ [string]
+ $Name,
+
+ # The version of the package to look for.
+ [Parameter()]
+ [string]
+ $Version
+ )
+ begin {
+ $versionSplat = if ([string]::IsNullOrEmpty($Version)) { @{} } else { @{ Version = $Version } }
+
+ # Due to https://github.com/chocolatey/choco/issues/1843, we get a list of all the installed packages and
+ # filter it ourselves. This has the added benefit of being quicker when dealing with multiple packages as we
+ # only call choco.exe once.
+ $installedPackages = Get-ChocolateyPackage @versionSplat -ChocoCommand $ChocoCommand
+
+ # Create a hashtable that will store our package version info.
+ $results = @{}
+ }
+ process {
+ if ($Name -eq 'all') {
+ # All is a special package name that means all installed packages, we set a dummy version so absent, latest
+ # and downgrade will run with all.
+ $results.'all' = @('0.0.0')
+ }
+ else {
+ $packageInfo = $installedPackages | Where-Object { $_.package -eq $Name }
+ if ($null -eq $packageInfo) {
+ $results.$Name = $null
+ }
+ else {
+ $results.$Name = @($packageInfo.version)
+ }
+ }
+ }
+ end {
+ $results
+ }
+}
+
+function Get-CommonChocolateyArgument {
+ <#
+ .SYNOPSIS
+ Retrieves a set of common Chocolatey arguments.
+
+ .DESCRIPTION
+ Retrieves the default set of Chocolatey arguments, constructed to function
+ best in headless environments (disable progress, auto-confirm) as well as
+ setting the verbosity levels of output to match the provided Ansible module.
+ #>
+ [CmdletBinding()]
+ param(
+ # The Ansible module object to check for verbosity levels and check mode.
+ # Defaults to the currently active module.
+ [Parameter()]
+ [Ansible.Basic.AnsibleModule]
+ $Module = (Get-AnsibleModule)
+ )
+
+ # uses global vars like check_mode and verbosity to control the common args
+ # run with Chocolatey
+ "--yes"
+ "--no-progress"
+
+ # global vars that control the arguments
+ if ($Module.CheckMode) {
+ "--what-if"
+ }
+
+ if ($Module.Verbosity -ge 4) {
+ if ($Module.Verbosity -ge 5) {
+ "--debug"
+ }
+
+ "--verbose"
+ }
+ elseif ($Module.Verbosity -le 2) {
+ "--limit-output"
+ }
+}
+
+function ConvertTo-ChocolateyArgument {
+ <#
+ .SYNOPSIS
+ Translates parameters into commonly used Chocolatey command line arguments.
+
+ .DESCRIPTION
+ Takes the provided parameters and outputs an array of raw command line
+ parameters to pass to Chocolatey, including a set of
+ #>
+ [CmdletBinding()]
+ param(
+ # Whether to permit downgrading packages with `choco upgrade`.
+ [Parameter()]
+ [switch]
+ $AllowDowngrade,
+
+ # Whether to ignore missing checksums in packages' downloaded files.
+ [Parameter()]
+ [switch]
+ $AllowEmptyChecksums,
+
+ # Whether to permit multiple side by side installations of the same package.
+ [Parameter()]
+ [switch]
+ $AllowMultiple,
+
+ # Whether to consider pre-release packages as valid selections to install.
+ [Parameter()]
+ [switch]
+ $AllowPrerelease,
+
+ # Set to `x86` to force Chocolatey to install x86 binaries.
+ [Parameter()]
+ [string]
+ $Architecture,
+
+ # Any additional arguments to be passed directly to `choco.exe`
+ [Parameter()]
+ [string[]]
+ $ChocoArgs,
+
+ # Set to force choco to reinstall the package if the package (version)
+ # is already installed.
+ [Parameter()]
+ [switch]
+ $Force,
+
+ # Set to ignore mismatched checksums for files downloaded by packages.
+ [Parameter()]
+ [switch]
+ $IgnoreChecksums,
+
+ # Set to ignore any defined package dependencies.
+ [Parameter()]
+ [switch]
+ $IgnoreDependencies,
+
+ # Installation args to be provided to installers in a given package.
+ [Parameter()]
+ [string]
+ $InstallArgs,
+
+ # Set to have `-InstallArgs` completely overwrite rather than append to
+ # normal arguments provided by the package installation script.
+ [Parameter()]
+ [switch]
+ $OverrideArgs,
+
+ # Add specific package parameters to the package installation.
+ [Parameter()]
+ [string]
+ $PackageParams,
+
+ # Set a proxy URL to use when downloading packages.
+ [Parameter()]
+ [string]
+ $ProxyUrl,
+
+ # Set a username for the proxy used when downloading packages.
+ [Parameter()]
+ [string]
+ $ProxyUsername,
+
+ # Set the password for the proxy used for downloading packages.
+ [Parameter()]
+ [string]
+ $ProxyPassword,
+
+ # Skip any .ps1 scripts for the package and just manage the package files
+ # in the lib folder directly.
+ [Parameter()]
+ [bool]
+ $SkipScripts,
+
+ # Define a specific source or sources to search for the package.
+ [Parameter()]
+ [string]
+ $Source,
+
+ # Set a username to access authenticated sources.
+ [Parameter()]
+ [string]
+ $SourceUsername,
+
+ # Set the password to access authenticated sources.
+ [Parameter()]
+ [string]
+ $SourcePassword,
+
+ # Set a specific timout in seconds to apply to the operation.
+ [Parameter()]
+ [int]
+ $Timeout,
+
+ # The version for the package to install or uninstall.
+ [Parameter()]
+ [string]
+ $Version
+ )
+
+ "--fail-on-unfound"
+
+ # Include common arguments for installing/updating a Chocolatey package
+ Get-CommonChocolateyArgument
+
+ if ($AllowDowngrade) { "--allow-downgrade" }
+ if ($AllowEmptyChecksums) { "--allow-empty-checksums" }
+ if ($AllowMultiple) { "--allow-multiple" }
+ if ($AllowPrerelease) { "--prerelease" }
+ if ($Architecture -eq "x86") { "--x86" }
+ if ($Force) { "--force" }
+ if ($IgnoreChecksums) { "--ignore-checksums" }
+ if ($IgnoreDependencies) { "--ignore-dependencies" }
+ if ($InstallArgs) { "--install-arguments", $InstallArgs }
+ if ($OverrideArgs) { "--override-arguments" }
+ if ($PackageParams) { "--package-parameters", $PackageParams }
+ if ($ProxyUrl) { "--proxy", $ProxyUrl }
+ if ($ProxyUsername) { "--proxy-user", $ProxyUsername }
+ if ($ProxyPassword) { "--proxy-password", $ProxyPassword }
+ if ($SkipScripts) { "--skip-scripts" }
+ if ($Source) { "--source", $Source }
+
+ if ($SourceUsername) {
+ "--user", $SourceUsername
+ "--password", $SourcePassword
+ }
+
+ if ($PSBoundParameters.ContainsKey('Timeout')) { "--timeout", $Timeout }
+ if ($Version) { "--version", $Version }
+ if ($ChocoArgs) { $ChocoArgs }
+}
+
+function Get-ChocolateyPin {
+ <#
+ .SYNOPSIS
+ Gets a hashtable containing all configured pins for installed packages.
+
+ .DESCRIPTION
+ Outputs a hashtable with keys corresponding to installed package names,
+ and the values as a collection of version numbers.
+ #>
+ [CmdletBinding()]
+ param(
+ # A CommandInfo object containing the path to choco.exe.
+ [Parameter(Mandatory = $true)]
+ [System.Management.Automation.CommandInfo]
+ $ChocoCommand
+ )
+
+ $command = Argv-ToString -Arguments @(
+ $ChocoCommand.Path
+ "pin", "list"
+ "--limit-output"
+ )
+ $result = Run-Command -Command $command
+
+ if ($result.rc -ne 0) {
+ $message = "Error getting list of pinned packages"
+ Assert-TaskFailed -Message $message -Command $command -CommandResult $result
+ }
+
+ $pins = @{}
+
+ $result |
+ ConvertFrom-Stdout |
+ ForEach-Object {
+ $package, $version, $null = $_.Split('|')
+
+ if ($pins.ContainsKey($package)) {
+ $pins.$package.Add($version)
+ }
+ else {
+ $pins.$package = [System.Collections.Generic.List[string]]@( $version )
+ }
+ }
+
+ $pins
+}
+
+function Set-ChocolateyPin {
+ <#
+ .SYNOPSIS
+ Sets the pin configuration for the target package.
+ #>
+ [CmdletBinding()]
+ param(
+ # A CommandInfo object containing the path to choco.exe.
+ [Parameter(Mandatory = $true)]
+ [System.Management.Automation.CommandInfo]
+ $ChocoCommand,
+
+ # The name of the package to pin.
+ [Parameter(Mandatory = $true)]
+ [string]
+ $Name,
+
+ # Set to pin the package, otherwise it will be unpinned.
+ [Parameter()]
+ [switch]
+ $Pin,
+
+ # The specific version to pin.
+ [Parameter()]
+ [string]
+ $Version
+ )
+
+ if ($Pin) {
+ $action = "add"
+ $errorMessage = "Error pinning package '$name'"
+ }
+ else {
+ $action = "remove"
+ $errorMessage = "Error unpinning package '$name'"
+ }
+
+ $arguments = @(
+ $ChocoCommand.Path,
+ "pin", $action
+ "--name", $name
+
+ if ($Version) {
+ $errorMessage = "$errorMessage at '$Version'"
+ "--version", $Version
+ }
+
+ Get-CommonChocolateyArgument
+ )
+
+ $command = Argv-ToString -Arguments $arguments
+ $result = Run-Command -Command $command
+ if ($result.rc -ne 0) {
+ Assert-TaskFailed -Message $errorMessage -Command $command -CommandResult $result
+ }
+
+ Set-TaskResultChanged
+}
+
+function Update-ChocolateyPackage {
+ <#
+ .SYNOPSIS
+ Updates one or more Chocolatey packages.
+ #>
+ [CmdletBinding()]
+ param(
+ # A CommandInfo object containing the path to choco.exe.
+ [Parameter(Mandatory = $true)]
+ [System.Management.Automation.CommandInfo]
+ $ChocoCommand,
+
+ # The package or packages to upgrade.
+ [Parameter(Mandatory = $true)]
+ [string[]]
+ $Package,
+
+ # The current module, will be used to set the response codes and
+ # any other information needing to be returned.
+ # Defaults to the currently active module.
+ [Parameter()]
+ [Ansible.Basic.AnsibleModule]
+ $Module = (Get-AnsibleModule),
+
+ # Whether to permit downgrading packages with `choco upgrade`.
+ [Parameter()]
+ [switch]
+ $AllowDowngrade,
+
+ # Whether to ignore missing checksums in packages' downloaded files.
+ [Parameter()]
+ [switch]
+ $AllowEmptyChecksums,
+
+ # Whether to permit multiple side by side installations of the same package.
+ [Parameter()]
+ [switch]
+ $AllowMultiple,
+
+ # Whether to consider pre-release packages as valid selections to install.
+ [Parameter()]
+ [switch]
+ $AllowPrerelease,
+
+ # Set to `x86` to force Chocolatey to install x86 binaries.
+ [Parameter()]
+ [string]
+ $Architecture,
+
+ # Any additional arguments to be passed directly to `choco.exe`
+ [Parameter()]
+ [string[]]
+ $ChocoArgs,
+
+ # Set to force choco to reinstall the package if the package (version)
+ # is already installed.
+ [Parameter()]
+ [switch]
+ $Force,
+
+ # Set to ignore mismatched checksums for files downloaded by packages.
+ [Parameter()]
+ [switch]
+ $IgnoreChecksums,
+
+ # Set to ignore any defined package dependencies.
+ [Parameter()]
+ [switch]
+ $IgnoreDependencies,
+
+ # Installation args to be provided to installers in a given package.
+ [Parameter()]
+ [string]
+ $InstallArgs,
+
+ # Set to have `-InstallArgs` completely overwrite rather than append to
+ # normal arguments provided by the package installation script.
+ [Parameter()]
+ [switch]
+ $OverrideArgs,
+
+ # Add specific package parameters to the package installation.
+ [Parameter()]
+ [string]
+ $PackageParams,
+
+ # Set a proxy URL to use when downloading packages.
+ [Parameter()]
+ [string]
+ $ProxyUrl,
+
+ # Set a username for the proxy used when downloading packages.
+ [Parameter()]
+ [string]
+ $ProxyUsername,
+
+ # Set the password for the proxy used for downloading packages.
+ [Parameter()]
+ [string]
+ $ProxyPassword,
+
+ # Skip any .ps1 scripts for the package and just manage the package files
+ # in the lib folder directly.
+ [Parameter()]
+ [bool]
+ $SkipScripts,
+
+ # Define a specific source or sources to search for the package.
+ [Parameter()]
+ [string]
+ $Source,
+
+ # Set a username to access authenticated sources.
+ [Parameter()]
+ [string]
+ $SourceUsername,
+
+ # Set the password to access authenticated sources.
+ [Parameter()]
+ [string]
+ $SourcePassword,
+
+ # Set a specific timout in seconds to apply to the operation.
+ [Parameter()]
+ [int]
+ $Timeout,
+
+ # The version for the package to upgrade.
+ [Parameter()]
+ [string]
+ $Version
+ )
+
+ $commonParams = $PSBoundParameters -as [hashtable]
+ $commonParams.Remove('Package')
+ $commonParams.Remove('ChocoCommand')
+ if ($PSBoundParameters.ContainsKey('Module')) {
+ $commonParams.Remove('Module')
+ }
+
+ $arguments = @(
+ $ChocoCommand.Path
+ "upgrade"
+ $Package
+ ConvertTo-ChocolateyArgument @commonParams
+ )
+
+ $command = Argv-ToString -Arguments $arguments
+ $result = Run-Command -Command $command
+ $Module.Result.rc = $result.rc
+
+ if ($result.rc -notin $script:successExitCodes) {
+ $message = "Error updating package(s) '$($Package -join ", ")'"
+ Assert-TaskFailed -Message $message -Command $command -CommandResult $result
+ }
+
+ if ($Module.Verbosity -gt 1) {
+ $Module.Result.stdout = $result.stdout
+ }
+
+ if ($result.stdout -match ' upgraded (\d+)/\d+ package') {
+ if ($matches[1] -gt 0) {
+ Set-TaskResultChanged
+ }
+ }
+
+ # Need to set to false in case the rc is not 0 and a failure didn't actually occur
+ $Module.Result.failed = $false
+}
+
+function Install-ChocolateyPackage {
+ <#
+ .SYNOPSIS
+ Installs one or more Chocolatey packages.
+ #>
+ [CmdletBinding()]
+ param(
+ # A CommandInfo object containing the path to choco.exe.
+ [Parameter(Mandatory = $true)]
+ [System.Management.Automation.CommandInfo]
+ $ChocoCommand,
+
+ # The package or packages to install.
+ [Parameter(Mandatory = $true)]
+ [string[]]
+ $Package,
+
+ # The current module, will be used to set the response codes and
+ # any other information needing to be returned.
+ # Defaults to the currently active module.
+ [Parameter()]
+ [Ansible.Basic.AnsibleModule]
+ $Module = (Get-AnsibleModule),
+
+ # Whether to permit downgrading packages with `choco upgrade`.
+ [Parameter()]
+ [switch]
+ $AllowDowngrade,
+
+ # Whether to ignore missing checksums in packages' downloaded files.
+ [Parameter()]
+ [switch]
+ $AllowEmptyChecksums,
+
+ # Whether to permit multiple side by side installations of the same package.
+ [Parameter()]
+ [switch]
+ $AllowMultiple,
+
+ # Whether to consider pre-release packages as valid selections to install.
+ [Parameter()]
+ [switch]
+ $AllowPrerelease,
+
+ # Set to `x86` to force Chocolatey to install x86 binaries.
+ [Parameter()]
+ [string]
+ $Architecture,
+
+ # Any additional arguments to be passed directly to `choco.exe`
+ [Parameter()]
+ [string[]]
+ $ChocoArgs,
+
+ # Set to force choco to reinstall the package if the package (version)
+ # is already installed.
+ [Parameter()]
+ [switch]
+ $Force,
+
+ # Set to ignore mismatched checksums for files downloaded by packages.
+ [Parameter()]
+ [switch]
+ $IgnoreChecksums,
+
+ # Set to ignore any defined package dependencies.
+ [Parameter()]
+ [switch]
+ $IgnoreDependencies,
+
+ # Installation args to be provided to installers in a given package.
+ [Parameter()]
+ [string]
+ $InstallArgs,
+
+ # Set to have `-InstallArgs` completely overwrite rather than append to
+ # normal arguments provided by the package installation script.
+ [Parameter()]
+ [switch]
+ $OverrideArgs,
+
+ # Add specific package parameters to the package installation.
+ [Parameter()]
+ [string]
+ $PackageParams,
+
+ # Set a proxy URL to use when downloading packages.
+ [Parameter()]
+ [string]
+ $ProxyUrl,
+
+ # Set a username for the proxy used when downloading packages.
+ [Parameter()]
+ [string]
+ $ProxyUsername,
+
+ # Set the password for the proxy used for downloading packages.
+ [Parameter()]
+ [string]
+ $ProxyPassword,
+
+ # Skip any .ps1 scripts for the package and just manage the package files
+ # in the lib folder directly.
+ [Parameter()]
+ [bool]
+ $SkipScripts,
+
+ # Define a specific source or sources to search for the package.
+ [Parameter()]
+ [string]
+ $Source,
+
+ # Set a username to access authenticated sources.
+ [Parameter()]
+ [string]
+ $SourceUsername,
+
+ # Set the password to access authenticated sources.
+ [Parameter()]
+ [string]
+ $SourcePassword,
+
+ # Set a specific timout in seconds to apply to the operation.
+ [Parameter()]
+ [int]
+ $Timeout,
+
+ # The version for the package to install.
+ [Parameter()]
+ [string]
+ $Version
+ )
+
+ $commonParams = $PSBoundParameters -as [hashtable]
+ $commonParams.Remove('Package')
+ $commonParams.Remove('ChocoCommand')
+ if ($PSBoundParameters.ContainsKey('Module')) {
+ $commonParams.Remove('Module')
+ }
+
+ $arguments = @(
+ $ChocoCommand.Path
+ "install"
+ $Package
+ ConvertTo-ChocolateyArgument @commonParams
+ )
+
+ $command = Argv-ToString -Arguments $arguments
+ $result = Run-Command -Command $command
+ $Module.Result.rc = $result.rc
+
+ if ($result.rc -notin $script:successExitCodes) {
+ $message = "Error installing package(s) '$($Package -join ", ")'"
+ Assert-TaskFailed -Message $message -Command $command -CommandResult $result
+ }
+
+ if ($Module.Verbosity -gt 1) {
+ $Module.Result.stdout = $result.stdout
+ }
+
+ Set-TaskResultChanged
+
+ # need to set to false in case the rc is not 0 and a failure didn't actually occur
+ $Module.Result.failed = $false
+}
+
+function Uninstall-ChocolateyPackage {
+ <#
+ .SYNOPSIS
+ Uninstalls one or more Chocolatey packages.
+ #>
+ [CmdletBinding()]
+ param(
+ # A CommandInfo object containing the path to choco.exe.
+ [Parameter(Mandatory = $true)]
+ [System.Management.Automation.CommandInfo]
+ $ChocoCommand,
+
+ # The package or packages to uninstall.
+ [Parameter(Mandatory = $true)]
+ [string[]]
+ $Package,
+
+ # The current module, will be used to set the response codes and
+ # any other information needing to be returned.
+ # Defaults to the currently active module.
+ [Parameter()]
+ [Ansible.Basic.AnsibleModule]
+ $Module = (Get-AnsibleModule),
+
+ # Set to force choco to reinstall the package if the package (version)
+ # is already installed.
+ [Parameter()]
+ [switch]
+ $Force,
+
+ # Add specific package parameters to the package installation.
+ [Parameter()]
+ [string]
+ $PackageParams,
+
+ # Skip any .ps1 scripts for the package and just manage the package files
+ # in the lib folder directly.
+ [Parameter()]
+ [switch]
+ $SkipScripts,
+
+ # Uninstall all dependencies for this package as well.
+ [Parameter()]
+ [switch]
+ $RemoveDependencies,
+
+ # Whether to permit multiple side by side installations of the same package.
+ [Parameter()]
+ [switch]
+ $AllowMultiple,
+
+ # Set a specific timout in seconds to apply to the operation.
+ [Parameter()]
+ [int]
+ $Timeout,
+
+ # The version for the package to uninstall.
+ [Parameter()]
+ [string]
+ $Version
+ )
+
+ $arguments = @(
+ $ChocoCommand.Path
+ "uninstall"
+ $Package
+ Get-CommonChocolateyArgument
+
+ if ($Version) {
+ "--version", $Version
+
+ if ($AllowMultiple) {
+ "--allow-multiple"
+ }
+ }
+ else {
+ "--all-versions"
+ }
+
+ if ($RemoveDependencies) { "--remove-dependencies" }
+ if ($Force) { "--force" }
+ if ($PSBoundParameters.ContainsKey('Timeout')) { "--timeout", $timeout }
+ if ($SkipScripts) { "--skip-scripts" }
+ if ($PackageParams) { "--package-parameters", $package_params }
+ )
+
+ $command = Argv-ToString -Arguments $arguments
+ $result = Run-Command -Command $command
+ $Module.Result.rc = $result.rc
+
+ if ($result.rc -notin $script:successExitCodes) {
+ $message = "Error uninstalling package(s) '$($Package -join ", ")'"
+ Assert-TaskFailed -Message $message -Command $command -CommandResult $result
+ }
+
+ if ($Module.Verbosity -gt 1) {
+ $Module.Result.stdout = $result.stdout
+ }
+
+ Set-TaskResultChanged
+
+ # need to set to false in case the rc is not 0 and a failure didn't actually occur
+ $Module.Result.failed = $false
+}
+
+function Install-Chocolatey {
+ [CmdletBinding()]
+ param(
+ # The current module, will be used to set the response codes and
+ # any other information needing to be returned.
+ # Defaults to the currently active module.
+ [Parameter()]
+ [Ansible.Basic.AnsibleModule]
+ $Module = (Get-AnsibleModule),
+
+ # Set a proxy URL to use when downloading Chocolatey.
+ [Parameter()]
+ [string]
+ $ProxyUrl,
+
+ # Set a proxy username to use when downloading Chocolatey.
+ [Parameter()]
+ [string]
+ $ProxyUsername,
+
+ # Set a proxy password to use when downloading Chocolatey.
+ [Parameter()]
+ [string]
+ $ProxyPassword,
+
+ # Set the source URL to find the chocolatey install script in.
+ [Parameter()]
+ [string]
+ $Source,
+
+ # The username to authenticate to the source repository.
+ [Parameter()]
+ [string]
+ $SourceUsername,
+
+ # The password to authenticate to the source repository.
+ [Parameter()]
+ [string]
+ $SourcePassword,
+
+ # The version of Chocolatey to install.
+ [Parameter()]
+ [string]
+ $Version,
+
+ # Set to skip writing the warning message when Chocolatey is not yet present.
+ [Parameter()]
+ [switch]
+ $SkipWarning,
+
+ [Parameter()]
+ [string]
+ $BootstrapScript,
+
+ [Parameter()]
+ [string[]]
+ $BootstrapTlsVersion
+ )
+
+ $chocoCommand = Get-ChocolateyCommand -IgnoreMissing
+ if ($null -eq $chocoCommand) {
+ # We need to install chocolatey
+ # Enable necessary TLS versions if they're available but disabled.
+ # Default for win_chocolatey is to allow TLS 1.1, 1.2, and 1.3 (if available)
+ $protocols = [System.Net.ServicePointManager]::SecurityProtocol -bor [System.Net.SecurityProtocolType]::SystemDefault
+
+ foreach ($tlsVersion in $BootstrapTlsVersion) {
+ # If the TLS version isn't available on the system, this will evaluate to $null and be skipped
+ $value = $tlsVersion -as [System.Net.SecurityProtocolType]
+ if ($value) {
+ $protocols = $protocols -bor $value
+ }
+ }
+
+ [System.Net.ServicePointManager]::SecurityProtocol = $protocols
+
+ # These env values are used in the install.ps1 script when getting
+ # external dependencies
+ $environment = [Environment]::GetEnvironmentVariables()
+ $client = New-Object -TypeName System.Net.WebClient
+
+ if ($ProxyUrl) {
+ $environment.chocolateyProxyLocation = $ProxyUrl
+
+ $proxy = New-Object -TypeName System.Net.WebProxy -ArgumentList $ProxyUrl, $true
+ $client.Proxy = $proxy
+
+ if ($ProxyUsername -and $ProxyPassword) {
+ $environment.chocolateyProxyUser = $ProxyUsername
+ $environment.chocolateyProxyPassword = $ProxyPassword
+ $securePassword = ConvertTo-SecureString -String $ProxyPassword -AsPlainText -Force
+ $proxy.Credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList @(
+ $ProxyUsername
+ $securePassword
+ )
+ }
+ }
+
+ if ($Version) {
+ # Set the chocolateyVersion environment variable when bootstrapping Chocolatey to install that specific
+ # version.
+ $environment.chocolateyVersion = $Version
+ }
+
+ $scriptUrl = if ($BootstrapScript) {
+ $BootstrapScript
+ }
+ elseif ($Source) {
+ $uriInfo = [System.Uri]$Source
+
+ # check if the URL already contains the path to PS script
+ if ($Source -like "*.ps1") {
+ $Source
+ }
+ elseif ($uriInfo.AbsolutePath -like '/repository/*') {
+ # Best-effort guess at finding an install.ps1 for Chocolatey in the given repository
+ "$($uriInfo.Scheme)://$($uriInfo.Authority)/$($uriInfo.AbsolutePath)/install.ps1" -replace '(?<!:)//', '/'
+ }
+ else {
+ # chocolatey server automatically serves a script at http://host/install.ps1, we rely on this
+ # behaviour when a user specifies the choco source URL and it doesn't look like a repository
+ # style url.
+ # If a custom URL or file path is desired, they should use win_get_url/win_shell manually.
+ # We need to strip the path off the URL and append `install.ps1`
+ "$($uriInfo.Scheme)://$($uriInfo.Authority)/install.ps1"
+ }
+
+ if ($SourceUsername) {
+ # While the choco-server does not require creds on install.ps1, Net.WebClient will only send the
+ # credentials if the initial request fails; we add the creds here in case the source URL is not
+ # choco-server and requires authentication.
+ $securePassword = ConvertTo-SecureString -String $SourcePassword -AsPlainText -Force
+ $client.Credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList @(
+ $SourceUsername
+ $securePassword
+ )
+ }
+ }
+ else {
+ "https://community.chocolatey.org/install.ps1"
+ }
+
+ try {
+ $installScript = $client.DownloadString($scriptUrl)
+ }
+ catch {
+ $message = "Failed to download Chocolatey script from '$scriptUrl'; $($_.Exception.Message)"
+ Assert-TaskFailed -Message $message -Exception $_.Exception
+ }
+
+ if (-not $Module.CheckMode) {
+ $scriptFile = New-Item -Path (Join-Path $Module.TmpDir -ChildPath 'chocolateyInstall.ps1') -ItemType File
+ $installScript | Set-Content -Path $scriptFile
+
+ # These commands will be sent over stdin for the PowerShell process, and will be read line by line,
+ # so we must join them on \r\n line-feeds to have them read as separate commands.
+ $commands = @(
+ '$ProgressPreference = "SilentlyContinue"'
+ '& "{0}"' -f $scriptFile
+ ) -join "`r`n"
+
+ $result = Run-Command -Command "powershell.exe -" -Stdin $commands -Environment $environment
+ if ($result.rc -ne 0) {
+ $message = "Chocolatey bootstrap installation failed."
+ Assert-TaskFailed -Message $message -CommandResult $result
+ }
+
+ if (-not $SkipWarning) {
+ $Module.Warn("Chocolatey was missing from this system, so it was installed during this task run.")
+ }
+ }
+
+ Set-TaskResultChanged
+
+ # locate the newly installed choco.exe
+ $chocoCommand = Get-ChocolateyCommand -IgnoreMissing
+ }
+
+ if ($null -eq $chocoCommand -or -not (Test-Path -LiteralPath $chocoCommand.Path)) {
+ if ($Module.CheckMode) {
+ $Module.Result.skipped = $true
+ $Module.Result.msg = "Skipped check mode run on win_chocolatey as choco.exe cannot be found on the system"
+ $Module.ExitJson()
+ }
+ else {
+ $message = "Failed to find choco.exe, make sure it is added to the PATH or the env var 'ChocolateyInstall' is set"
+ Assert-TaskFailed -Message $message
+ }
+ }
+
+ $chocolateyPackageVersion = (Get-ChocolateyPackageVersion -ChocoCommand $chocoCommand -Name 'chocolatey').chocolatey |
+ Select-Object -First 1
+
+ if ($chocolateyPackageVersion) {
+ try {
+ # The Chocolatey version may not be in the strict form of major.minor.build and will fail to cast to
+ # System.Version. We want to warn if this is the case saying module behaviour may be incorrect.
+ $actualVersion = [Version]$chocolateyPackageVersion
+ }
+ catch {
+ $warning = @(
+ "Failed to parse Chocolatey version '$actualVersion' for checking module requirements."
+ "Module may not work correctly: $($_.Exception.Message)"
+ ) -join ' '
+ $Module.Warn($warning)
+ $actualVersion = $null
+ }
+ }
+ else {
+ # Couldn't find the Chocolatey package information
+ $warning = @(
+ "Did not find version information for package ID 'chocolatey'."
+ "Unable to determine the client's installed Chocolatey version."
+ "Module may not work correctly."
+ "You may be able to rectify this by upgrading / reinstalling 'chocolatey'."
+ ) -join ' '
+ $Module.Warn($warning)
+ $actualVersion = $null
+ }
+
+ if ($null -ne $actualVersion -and $actualVersion -lt [Version]"0.10.5") {
+ if ($Module.CheckMode) {
+ $Module.Result.skipped = $true
+ $Module.Result.msg = @(
+ "Skipped check mode run on win_chocolatey as choco.exe is too old, a real run would have upgraded the executable."
+ "Actual: '$actualVersion', Minimum Version: '0.10.5'"
+ ) -join ' '
+ $Module.ExitJson()
+ }
+
+ $Module.Warn("Chocolatey was older than v0.10.5 so it will be upgraded during this task run.")
+ $params = @{
+ ChocoCommand = $chocoCommand
+ Packages = @("chocolatey")
+ ProxyUrl = $ProxyUrl
+ ProxyUsername = $ProxyUsername
+ ProxyPassword = $ProxyPassword
+ Source = $Source
+ SourceUsername = $SourceUsername
+ SourcePassword = $SourcePassword
+ }
+ Update-ChocolateyPackage @params
+ }
+
+ $chocoCommand
+}
+
+Export-ModuleMember -Function @(
+ 'ConvertTo-ChocolateyArgument'
+ 'Get-ChocolateyOutdated'
+ 'Get-ChocolateyPackage'
+ 'Get-ChocolateyPackageVersion'
+ 'Get-ChocolateyPin'
+ 'Get-CommonChocolateyArgument'
+ 'Set-ChocolateyPin'
+ 'Install-Chocolatey'
+ 'Install-ChocolateyPackage'
+ 'Uninstall-ChocolateyPackage'
+ 'Update-ChocolateyPackage'
+)
diff --git a/ansible_collections/chocolatey/chocolatey/plugins/module_utils/Sources.psm1 b/ansible_collections/chocolatey/chocolatey/plugins/module_utils/Sources.psm1
new file mode 100644
index 00000000..0e450def
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/plugins/module_utils/Sources.psm1
@@ -0,0 +1,271 @@
+#Requires -Module Ansible.ModuleUtils.ArgvParser
+#Requires -Module Ansible.ModuleUtils.CommandUtil
+
+#AnsibleRequires -PowerShell ansible_collections.chocolatey.chocolatey.plugins.module_utils.Common
+
+function Get-ChocolateySource {
+ <#
+ .SYNOPSIS
+ Gets a list of all Chocolatey sources.
+
+ .DESCRIPTION
+ Outputs a list of hashtables, each containing the properties of a configured
+ Chocolatey source.
+ #>
+ [CmdletBinding()]
+ param(
+ # A CommandInfo object containing the path to choco.exe.
+ [Parameter(Mandatory = $true)]
+ [System.Management.Automation.CommandInfo]
+ $ChocoCommand
+ )
+
+ $configFolder = Split-Path -LiteralPath (Split-Path -LiteralPath $ChocoCommand.Path)
+ $configPath = "$configFolder\config\chocolatey.config"
+
+ if (-not (Test-Path -LiteralPath $configPath)) {
+ $message = "Expecting Chocolatey config file to exist at '$configPath'"
+ Assert-TaskFailed -Message $message
+ }
+
+ # would prefer to enumerate the existing sources with an actual API but the
+ # only stable interface is choco.exe source list and that does not output
+ # the sources in an easily parsable list. Using -r will split each entry by
+ # | like a psv but does not quote values that have a | already in it making
+ # it inadequete for our tasks. Instead we will parse the chocolatey.config
+ # file and get the values from there
+ try {
+ [xml]$configXml = Get-Content -LiteralPath $configPath
+ }
+ catch {
+ $message = "Failed to parse Chocolatey config file at '$configPath': $($_.Exception.Message)"
+ Assert-TaskFailed -Message $message -Exception $_
+ }
+
+ foreach ($sourceNode in $configXml.chocolatey.sources.GetEnumerator()) {
+ $sourceInfo = @{
+ name = $sourceNode.id
+ source = $sourceNode.value
+ disabled = [System.Convert]::ToBoolean($sourceNode.disabled)
+ }
+
+ $attributeList = @(
+ @{ attribute = 'user'; type = [string]; name = 'source_username' }
+ @{ attribute = 'priority'; type = [int] }
+ @{ attribute = 'certificate'; type = [string] }
+ @{ attribute = 'bypassProxy'; type = [bool]; name = 'bypass_proxy' }
+ @{ attribute = 'selfService'; type = [bool]; name = 'allow_self_service' }
+ @{ attribute = 'adminOnly'; type = [bool]; name = 'admin_only' }
+ )
+
+ foreach ($item in $attributeList) {
+ $attr = $sourceNode.Attributes.GetNamedItem($item.attribute)
+ $property = if ($item.ContainsKey('name')) { $item.name } else { $item.attribute }
+
+ $sourceInfo.$property = if ($null -ne $attr) {
+ if ($item.type -eq [bool]) {
+ [bool]::Parse($attr.Value)
+ }
+ elseif ($item.type -eq [int]) {
+ [int]::Parse($attr.Value)
+ }
+ else {
+ $attr.Value
+ }
+ }
+ else {
+ $null
+ }
+ }
+
+ $sourceInfo
+ }
+}
+
+function New-ChocolateySource {
+ <#
+ .SYNOPSIS
+ Adds a new Chocolatey source configuration.
+
+ .DESCRIPTION
+ Inserts a new Chocolatey source configuration with the requested
+ parameters set for the source.
+ #>
+ [CmdletBinding()]
+ param(
+ # A CommandInfo object containing the path to choco.exe.
+ [Parameter(Mandatory = $true)]
+ [System.Management.Automation.CommandInfo]
+ $ChocoCommand,
+
+ # The "friendly" name of the source.
+ [Parameter(Mandatory = $true)]
+ [string]
+ $Name,
+
+ # The URL to the source repository.
+ [Parameter(Mandatory = $true)]
+ [string]
+ $Source,
+
+ # The username required to authenticate to the source, if any.
+ [Parameter()]
+ [string]
+ $Username,
+
+ # The password required to authenticate to the source, if any.
+ [Parameter()]
+ [string]
+ $Password,
+
+ # The certificate required to authenticate to the source, if any.
+ [Parameter()]
+ [string]
+ $Certificate,
+
+ # The password for the certificate required to authenticate to the source, if applicable.
+ [Parameter()]
+ [string]
+ $CertificatePassword,
+
+ # The priority level of the source.
+ [Parameter()]
+ [int]
+ $Priority,
+
+ # Set to bypass the proxy configuration when retrieving packages from this source.
+ [Parameter()]
+ [switch]
+ $BypassProxy,
+
+ # Set to allow non-admin users to use the source when self-service is enabled.
+ [Parameter()]
+ [switch]
+ $AllowSelfService,
+
+ # Set to restrict usage of the source to administrator users only.
+ [Parameter()]
+ [switch]
+ $AdminOnly,
+
+ # The Ansible module object to check for verbosity levels and check mode.
+ # Defaults to the currently active module.
+ [Parameter()]
+ [Ansible.Basic.AnsibleModule]
+ $Module = (Get-AnsibleModule)
+ )
+
+ $arguments = @(
+ # Add the base arguments
+ $ChocoCommand.Path
+ "source", "add"
+ "--name", $Name
+ "--source", $Source
+
+ # Add optional arguments from user input
+ if ($PSBoundParameters.ContainsKey('Username')) {
+ "--user", $Username
+ "--password", $Password
+ }
+
+ if ($PSBoundParameters.ContainsKey('Certificate')) {
+ "--cert", $Certificate
+
+ if ($PSBoundParameters.ContainsKey('CertificatePassword')) {
+ "--certpassword", $CertificatePassword
+ }
+ }
+
+ if ($PSBoundParameters.ContainsKey('Priority')) {
+ "--priority", $Priority
+ }
+ else {
+ $Priority = 0
+ }
+
+ if ($BypassProxy) {
+ "--bypass-proxy"
+ }
+
+ if ($AllowSelfService) {
+ "--allow-self-service"
+ }
+
+ if ($AdminOnly) {
+ "--admin-only"
+ }
+
+ if ($Module.CheckMode) {
+ "--what-if"
+ }
+ )
+
+
+ $command = Argv-ToString -Arguments $arguments
+ $result = Run-Command -Command $command
+
+ if ($result.rc -ne 0) {
+ $message = "Failed to add Chocolatey source '$Name': $($result.stderr)"
+ Assert-TaskFailed -Message $message -CommandResult $result
+ }
+
+ @{
+ name = $Name
+ source = $Source
+ disabled = $false
+ source_username = $Username
+ priority = $Priority
+ certificate = $Certificate
+ bypass_proxy = $BypassProxy.IsPresent
+ allow_self_service = $AllowSelfService.IsPresent
+ admin_only = $AdminOnly.IsPresent
+ }
+}
+
+function Remove-ChocolateySource {
+ <#
+ .SYNOPSIS
+ Removes the target Chocolatey source configuration.
+ #>
+ [CmdletBinding()]
+ param(
+ # A CommandInfo object containing the path to choco.exe.
+ [Parameter(Mandatory = $true)]
+ [System.Management.Automation.CommandInfo]
+ $ChocoCommand,
+
+ # The "friendly" name of the source to remove.
+ [Parameter(Mandatory = $true)]
+ [string]
+ $Name,
+
+ # The Ansible module object to check for verbosity levels and check mode.
+ # Defaults to the currently active module.
+ [Parameter()]
+ [Ansible.Basic.AnsibleModule]
+ $Module = (Get-AnsibleModule)
+ )
+
+ $arguments = @(
+ $ChocoCommand.Path
+ "source", "remove"
+ "--name", $Name
+
+ if ($Module.CheckMode) {
+ "--what-if"
+ }
+ )
+ $command = Argv-ToString -Arguments $arguments
+ $result = Run-Command -Command $command
+
+ if ($result.rc -ne 0) {
+ $message = "Failed to remove Chocolatey source '$Name': $($result.stderr)"
+ Assert-TaskFailed -Message $message -CommandResult $result
+ }
+}
+
+Export-ModuleMember -Function @(
+ 'Get-ChocolateySource'
+ 'New-ChocolateySource'
+ 'Remove-ChocolateySource'
+)
diff --git a/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey.ps1 b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey.ps1
new file mode 100644
index 00000000..a6a4b92c
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey.ps1
@@ -0,0 +1,290 @@
+#!powershell
+
+# Copyright: (c) 2014, Trond Hindenes <trond@hindenes.com>
+# Copyright: (c) 2017, Dag Wieers <dag@wieers.com>
+# Copyright: (c) 2018, Ansible Project
+# Copyright: (c) 2020, Chocolatey Software
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#Requires -Module Ansible.ModuleUtils.ArgvParser
+#Requires -Module Ansible.ModuleUtils.CommandUtil
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.chocolatey.chocolatey.plugins.module_utils.Common
+#AnsibleRequires -PowerShell ansible_collections.chocolatey.chocolatey.plugins.module_utils.Packages
+
+[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
+ 'PSUseConsistentWhitespace',
+ '',
+ Justification = 'Relax whitespace rule for better readability in module spec',
+ Scope = 'function',
+ # Apply suppression specifically to module spec
+ Target = 'Get-ModuleSpec')]
+param()
+
+# As of chocolatey 0.9.10, non-zero success exit codes can be returned
+# See https://github.com/chocolatey/choco/issues/512#issuecomment-214284461
+$script:successExitCodes = (0, 1605, 1614, 1641, 3010)
+
+function Get-ModuleSpec {
+ @{
+ options = @{
+ allow_empty_checksums = @{ type = "bool"; default = $false }
+ allow_multiple = @{ type = "bool"; default = $false; removed_in_version = '2.0.0'; removed_from_collection = 'chocolatey.chocolatey' }
+ allow_prerelease = @{ type = "bool"; default = $false }
+ bootstrap_script = @{ type = "str"; aliases = "install_ps1", "bootstrap_ps1" }
+ bootstrap_tls_version = @{
+ type = "list"
+ elements = "str"
+ choices = "tls11", "tls12", "tls13"
+ default = "tls12", "tls13"
+ aliases = "tls_version", "tls_versions", "bootstrap_tls_versions"
+ }
+ architecture = @{ type = "str"; default = "default"; choices = "default", "x86" }
+ choco_args = @{ type = "list"; elements = "str"; aliases = "licensed_args" }
+ force = @{ type = "bool"; default = $false }
+ ignore_checksums = @{ type = "bool"; default = $false }
+ ignore_dependencies = @{ type = "bool"; default = $false }
+ install_args = @{ type = "str" }
+ name = @{ type = "list"; elements = "str"; required = $true }
+ override_args = @{ type = "bool"; default = $false }
+ package_params = @{ type = "str"; aliases = @("params") }
+ pinned = @{ type = "bool" }
+ proxy_url = @{ type = "str" }
+ proxy_username = @{ type = "str" }
+ proxy_password = @{ type = "str"; no_log = $true }
+ remove_dependencies = @{ type = "bool"; default = $false }
+ skip_scripts = @{ type = "bool"; default = $false }
+ source = @{ type = "str" }
+ source_username = @{ type = "str" }
+ source_password = @{ type = "str"; no_log = $true }
+ state = @{ type = "str"; default = "present"; choices = "absent", "downgrade", "upgrade", "latest", "present", "reinstalled" }
+ timeout = @{ type = "int"; default = 2700; aliases = @("execution_timeout") }
+ validate_certs = @{ type = "bool"; default = $true }
+ version = @{ type = "str" }
+ }
+ supports_check_mode = $true
+ }
+}
+
+$spec = Get-ModuleSpec
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec)
+Set-ActiveModule $module
+
+$allow_empty_checksums = $module.Params.allow_empty_checksums
+$allow_multiple = $module.Params.allow_multiple
+$allow_prerelease = $module.Params.allow_prerelease
+$architecture = $module.Params.architecture
+$bootstrap_script = $module.Params.bootstrap_script
+$choco_args = $module.Params.choco_args
+$force = $module.Params.force
+$ignore_checksums = $module.Params.ignore_checksums
+$ignore_dependencies = $module.Params.ignore_dependencies
+$install_args = $module.Params.install_args
+$name = $module.Params.name
+$override_args = $module.Params.override_args
+$package_params = $module.Params.package_params
+$pinned = $module.Params.pinned
+$proxy_url = $module.Params.proxy_url
+$proxy_username = $module.Params.proxy_username
+$proxy_password = $module.Params.proxy_password
+$remove_dependencies = $module.Params.remove_dependencies
+$skip_scripts = $module.Params.skip_scripts
+$source = $module.Params.source
+$source_username = $module.Params.source_username
+$source_password = $module.Params.source_password
+$state = $module.Params.state
+$timeout = $module.Params.timeout
+$bootstrap_tls_version = $module.Params.bootstrap_tls_version
+$validate_certs = $module.Params.validate_certs
+$version = $module.Params.version
+
+$module.Result.rc = 0
+
+if (-not $validate_certs) {
+ [System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
+}
+
+# get the full path to choco.exe, otherwise install/upgrade to at least 0.10.5
+$installParams = @{
+ BootstrapTlsVersion = $bootstrap_tls_version
+ ProxyUrl = $proxy_url
+ ProxyUsername = $proxy_username
+ ProxyPassword = $proxy_password
+ Source = $source
+ SourceUsername = $source_username
+ SourcePassword = $source_password
+}
+
+if ($version -and "chocolatey" -in $name) {
+ # If a version is set and chocolatey is in the package list, pass the chocolatey version to the bootstrapping
+ # process.
+ $installParams.Version = $version
+ $installParams.SkipWarning = $true
+}
+
+if ($bootstrap_script) {
+ $installParams.BootstrapScript = $bootstrap_script
+}
+
+$chocoCommand = Install-Chocolatey @installParams
+
+if ('all' -in $name -and $state -in @('present', 'reinstalled')) {
+ $message = "Cannot specify the package name as 'all' when state=$state"
+ Assert-TaskFailed -Message $message
+}
+
+# Get the installed versions of all specified packages
+$packageInfo = $name | Get-ChocolateyPackageVersion -ChocoCommand $chocoCommand
+
+if ($state -in "absent", "reinstalled") {
+ $installedPackages = $packageInfo.Keys | Where-Object { $null -ne $packageInfo.$_ }
+
+ if ($null -ne $installedPackages) {
+ foreach ($package in $installedPackages) {
+ # If a version has been supplied, check that that version of the package is actually installed.
+ # If that version of the package is not present, don't uninstall other versions by accident.
+ if ($version) {
+ $packageVersionedInfo = $package | Get-ChocolateyPackageVersion -ChocoCommand $chocoCommand -Version $version
+ $currentlyInstalledVersions = $packageVersionedInfo.Keys | Where-Object { $null -ne $packageVersionedInfo.$_ }
+ if (@($currentlyInstalledVersions).Count -eq 0) {
+ continue
+ }
+ }
+
+ # --allow-multiple is buggy for `choco uninstall`.
+ # To get the correct behaviour, we have to use it only when multiple side by side package versions
+ # are actually installed, or we'll either just get errors, or end up uninstalling all installed versions
+ # even if a specific version is targeted.
+ $useAllowMultiple = $packageInfo.$package.Count -gt 1
+ $uninstallParams = @{
+ ChocoCommand = $chocoCommand
+ Package = $package
+ Force = $force
+ PackageParams = $package_params
+ SkipScripts = $skip_scripts
+ RemoveDependencies = $remove_dependencies
+ Timeout = $timeout
+ Version = $version
+ AllowMultiple = $useAllowMultiple
+ }
+ Uninstall-ChocolateyPackage @uninstallParams
+ }
+ }
+
+ # Ensure the package info for the uninstalled versions has been removed,
+ # so state=reinstall will install them in the next step
+ foreach ($package in $installedPackages) {
+ $packageInfo.$package = $null
+ }
+}
+
+if ($state -in @("downgrade", "latest", "upgrade", "present", "reinstalled")) {
+ # When state=present and force=true, we just run the install step with the packages specified,
+ # otherwise only install the packages that are not installed
+ $missingPackages = [System.Collections.Generic.List[string]]@()
+
+ if ($state -eq "present" -and $force) {
+ $missingPackages.Add($name)
+ }
+ else {
+ foreach ($package in $packageInfo.GetEnumerator()) {
+ if ($null -eq $package.Value) {
+ $missingPackages.Add($package.Key)
+ }
+ }
+ }
+
+ # If version is specified and installed version does not match or not
+ # allow_multiple, throw error. Ignore this if force is set.
+ if ($state -eq "present" -and $null -ne $version -and -not $force) {
+ foreach ($package in $name) {
+ $packageVersions = @($packageInfo.$package | Where-Object { $_ })
+
+ if ($packageVersions.Count -gt 0) {
+ if (-not $packageVersions.Contains($version) -and -not $allow_multiple) {
+ $message = @(
+ "Chocolatey package '$package' is already installed with version(s) '$($packageVersions -join "', '")'"
+ "but was expecting '$version'. Either change the expected version, set state=latest or state=upgrade,"
+ "set allow_multiple=yes, or set force=yes to continue"
+ ) -join ' '
+ Assert-TaskFailed -Message $message
+ }
+ elseif ($version -notin $packageVersions -and $allow_multiple) {
+ # add the package back into the list of missing packages if installing multiple
+ $missingPackages.Add($package)
+ }
+ }
+ }
+ }
+
+ $commonParams = @{
+ ChocoCommand = $chocoCommand
+ AllowDowngrade = ($state -eq "downgrade")
+ AllowEmptyChecksums = $allow_empty_checksums
+ AllowMultiple = $allow_multiple
+ AllowPrerelease = $allow_prerelease
+ Architecture = $architecture
+ ChocoArgs = $choco_args
+ Force = $force
+ IgnoreChecksums = $ignore_checksums
+ IgnoreDependencies = $ignore_dependencies
+ InstallArgs = $install_args
+ OverrideArgs = $override_args
+ PackageParams = $package_params
+ ProxyUrl = $proxy_url
+ ProxyUsername = $proxy_username
+ ProxyPassword = $proxy_password
+ SkipScripts = $skip_scripts
+ Source = $source
+ SourceUsername = $source_username
+ SourcePassword = $source_password
+ Timeout = $timeout
+ Version = $version
+ }
+
+ if ($missingPackages.Count -gt 0) {
+ Install-ChocolateyPackage -Package $missingPackages @commonParams
+ }
+
+ if ($state -in @("latest", "upgrade") -or ($state -eq "downgrade" -and $null -ne $version)) {
+ # when in a downgrade/latest situation, we want to run choco upgrade on
+ # the remaining packages that were already installed, don't run this if
+ # state=downgrade and a version isn't specified (this will actually
+ # upgrade a package)
+ $installedPackages = ($packageInfo.GetEnumerator() | Where-Object { $null -ne $_.Value }).Key
+
+ if ($null -ne $installedPackages) {
+ Update-ChocolateyPackage -Package $installedPackages @commonParams
+ }
+ }
+
+ # Now we want to pin/unpin any packages now that it has been installed/upgraded
+ if ($null -ne $pinned) {
+ $pins = Get-ChocolateyPin -ChocoCommand $chocoCommand
+
+ foreach ($package in $name) {
+ if ($pins.ContainsKey($package)) {
+ if (-not $pinned -and $null -eq $version) {
+ # No version is set and pinned=no, we want to remove all pins on the package. There is a bug in
+ # 'choco pin remove' with multiple versions where an older version might be pinned but
+ # 'choco pin remove' will still fail without an explicit version. Instead we take the literal
+ # interpretation that pinned=no and no version means the package has no pins at all
+ foreach ($v in $pins.$package) {
+ Set-ChocolateyPin -ChocoCommand $chocoCommand -Name $package -Version $v
+ }
+ }
+ elseif ($null -ne $version -and $pins.$package.Contains($version) -ne $pinned) {
+ Set-ChocolateyPin -ChocoCommand $chocoCommand -Name $package -Pin:$pinned -Version $version
+ }
+ }
+ elseif ($pinned) {
+ # Package had no pins but pinned=yes is set.
+ Set-ChocolateyPin -ChocoCommand $chocoCommand -Name $package -Pin -Version $version
+ }
+ }
+ }
+}
+
+$module.ExitJson()
diff --git a/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey.py b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey.py
new file mode 100644
index 00000000..a660da9f
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey.py
@@ -0,0 +1,495 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2014, Trond Hindenes <trond@hindenes.com>
+# Copyright: (c) 2018, Ansible Project
+# Copyright: (c) 2020, Chocolatey Software
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+# this is a windows documentation stub. actual code lives in the .ps1
+# file of the same name
+
+ANSIBLE_METADATA = {'metadata_version': '1.1',
+ 'status': ['preview'],
+ 'supported_by': 'community'}
+
+DOCUMENTATION = r'''
+---
+module: win_chocolatey
+version_added: '0.1.9'
+short_description: Manage packages using chocolatey
+description:
+- Manage packages using Chocolatey.
+- If Chocolatey is missing from the system, the module will install it.
+requirements:
+- chocolatey >= 0.10.5 (will be upgraded if older)
+options:
+ allow_empty_checksums:
+ description:
+ - Allow empty checksums to be used for downloaded resource from non-secure
+ locations.
+ - Use M(chocolatey.chocolatey.win_chocolatey_feature) with the name C(allowEmptyChecksums) to
+ control this option globally.
+ type: bool
+ default: no
+ version_added: '0.2.2'
+ allow_multiple:
+ description:
+ - This option is deprecated and will be removed in v2.0.0 of this collection.
+ Chocolatey CLI has L(deprecated side-by-side installations, https://github.com/chocolatey/choco/issues/2787)
+ as of its v1.2.0 release and plans to remove them in its v2.0.0 release.
+ - Allow the installation of multiple packages when I(version) is specified.
+ - Having multiple packages at different versions can cause issues if the
+ package doesn't support this. Use at your own risk.
+ - The value of this parameter is ignored if I(state) is C(absent). Instead,
+ this parameter is automatically configured to remove all versions if
+ I(version) is not specified, and the specific version only if I(version)
+ is specified.
+ type: bool
+ default: no
+ version_added: '0.2.8'
+ allow_prerelease:
+ description:
+ - Allow the installation of pre-release packages.
+ - If I(state) is C(latest), the latest pre-release package will be
+ installed.
+ type: bool
+ default: no
+ version_added: '0.2.6'
+ architecture:
+ description:
+ - Force Chocolatey to install the package of a specific process
+ architecture.
+ - When setting C(x86), will ensure Chocolatey installs the x86 package
+ even when on an x64 bit OS.
+ type: str
+ choices: [ default, x86 ]
+ default: default
+ version_added: '0.2.7'
+ bootstrap_script:
+ description:
+ - Specify the bootstrap script URL that can be used to install Chocolatey
+ if it is not already present on the system.
+ - Use this parameter when I(name) is C(chocolatey) to ensure that a
+ custom bootstrap script is used.
+ - If neither this parameter nor I(source) is set, the bootstrap script
+ url will be C(https://community.chocolatey.org/install.ps1)
+ - If this parameter is not set, and I(source) is set to a url, the
+ bootstrap script url will be determined from that url instead.
+ - This parameter only defines which bootstrap script is used to download
+ and install Chocolatey. To define the URL to a specific Chocolatey
+ nupkg to install, note that many bootstrap scripts respect the value
+ of the C(chocolateyDownloadUrl) environment variable, which can be set
+ for the task as well.
+ type: str
+ version_added: '1.3.0'
+ aliases: [ install_ps1, bootstrap_ps1 ]
+ bootstrap_tls_version:
+ description:
+ - Specify the TLS versions used when retrieving and invoking the I(bootstrap_script) to install
+ Chocolatey if it is not already installed on the system.
+ - Does not change the TLS versions used by Chocolatey itself after it has already been installed.
+ - Specified TLS versions may be ignored or unused if the target TLS version is not available on
+ the client.
+ type: list
+ elements: str
+ choices: [ tls11, tls12, tls13 ]
+ default: [ tls12, tls13 ]
+ version_added: '1.4.0'
+ aliases: [ bootstrap_tls_versions, tls_version, tls_versions ]
+ force:
+ description:
+ - Forces the install of a package, even if it already is installed.
+ - Using I(force) will cause Ansible to always report that a change was
+ made.
+ type: bool
+ default: no
+ ignore_checksums:
+ description:
+ - Ignore the checksums provided by the package.
+ - Use M(chocolatey.chocolatey.win_chocolatey_feature) with the name C(checksumFiles) to control
+ this option globally.
+ type: bool
+ default: no
+ version_added: '0.2.2'
+ ignore_dependencies:
+ description:
+ - Ignore dependencies, only install/upgrade the package itself.
+ type: bool
+ default: no
+ version_added: '0.2.1'
+ remove_dependencies:
+ description:
+ - Remove a package's dependencies on uninstall.
+ type: bool
+ default: no
+ version_added: '1.1.0'
+ install_args:
+ description:
+ - Arguments to pass to the native installer.
+ - These are arguments that are passed directly to the installer the
+ Chocolatey package runs, this is generally an advanced option.
+ type: str
+ version_added: '0.2.1'
+ name:
+ description:
+ - Name of the package(s) to be installed.
+ - Set to C(all) to run the action on all the installed packages.
+ type: list
+ elements: str
+ required: yes
+ override_args:
+ description:
+ - Override arguments of native installer with arguments provided by user.
+ - Should install arguments be used exclusively without appending
+ to current package passed arguments.
+ type: bool
+ default: no
+ version_added: '0.2.10'
+ package_params:
+ description:
+ - Parameters to pass to the package.
+ - These are parameters specific to the Chocolatey package and are generally
+ documented by the package itself.
+ - Before Ansible 2.7, this option was just I(params).
+ type: str
+ version_added: '0.2.1'
+ aliases: [ params ]
+ choco_args:
+ description:
+ - Additional parameters to pass to choco.exe
+ - These may be any additional parameters to pass through directly to
+ Chocolatey, in addition to the arguments already specified via other
+ parameters.
+ - This may be used to pass licensed options to Chocolatey, for example
+ C(--package-parameters-sensitive) or C(--install-directory).
+ - Passing licensed options may result in them being ignored or causing
+ errors if the targeted node is unlicensed or missing the
+ chocolatey.extension package.
+ type: list
+ elements: str
+ version_added: '1.2.0'
+ aliases: [ licensed_args ]
+ pinned:
+ description:
+ - Whether to pin the Chocolatey package or not.
+ - If omitted then no checks on package pins are done.
+ - Will pin/unpin the specific version if I(version) is set.
+ - Will pin the latest version of a package if C(yes), I(version) is not set
+ and and no pin already exists.
+ - Will unpin all versions of a package if C(no) and I(version) is not set.
+ - This is ignored when C(state=absent).
+ type: bool
+ version_added: '0.2.8'
+ proxy_url:
+ description:
+ - Proxy URL used to install chocolatey and the package.
+ - Use M(chocolatey.chocolatey.win_chocolatey_config) with the name C(proxy) to control this
+ option globally.
+ type: str
+ version_added: '0.2.4'
+ proxy_username:
+ description:
+ - Proxy username used to install Chocolatey and the package.
+ - Before Ansible 2.7, users with double quote characters C(") would need to
+ be escaped with C(\) beforehand. This is no longer necessary.
+ - Use M(chocolatey.chocolatey.win_chocolatey_config) with the name C(proxyUser) to control this
+ option globally.
+ type: str
+ version_added: '0.2.4'
+ proxy_password:
+ description:
+ - Proxy password used to install Chocolatey and the package.
+ - This value is exposed as a command argument and any privileged account
+ can see this value when the module is running Chocolatey, define the
+ password on the global config level with M(chocolatey.chocolatey.win_chocolatey_config) with
+ name C(proxyPassword) to avoid this.
+ type: str
+ version_added: '0.2.4'
+ skip_scripts:
+ description:
+ - Do not run I(chocolateyInstall.ps1) or I(chocolateyUninstall.ps1) scripts
+ when installing a package.
+ type: bool
+ default: no
+ version_added: '0.2.4'
+ source:
+ description:
+ - Specify the source to retrieve the package from.
+ - Use M(chocolatey.chocolatey.win_chocolatey_source) to manage global sources.
+ - This value can either be the URL to a Chocolatey feed, a path to a folder
+ containing C(.nupkg) packages or the name of a source defined by
+ M(chocolatey.chocolatey.win_chocolatey_source).
+ - When Chocolatey is not yet installed, prefer using I(bootstrap_script)
+ instead to determine where to pull the bootstrap script from.
+ - This value may also be used when Chocolatey is not installed as the
+ location of the install.ps1 script if I(bootstrap_script) is not set, and
+ only supports URLs for this case.
+ In this case, if the URL ends in ".ps1", it is used as-is. Otherwise,
+ if the URL appears to contain a "/repository/" fragment, the module
+ will attempt to append "/install.ps1" to find an install script. If
+ neither of these checks pass, the module will strip off the URL path and
+ try to find an "/install.ps1" from the root of the server.
+ type: str
+ source_username:
+ description:
+ - A username to use with I(source) when accessing a feed that requires
+ authentication.
+ - It is recommended you define the credentials on a source with
+ M(chocolatey.chocolatey.win_chocolatey_source) instead of passing it per task.
+ type: str
+ version_added: '0.2.7'
+ source_password:
+ description:
+ - The password for I(source_username).
+ - This value is exposed as a command argument and any privileged account
+ can see this value when the module is running Chocolatey, define the
+ credentials with a source with M(chocolatey.chocolatey.win_chocolatey_source) to avoid this.
+ type: str
+ version_added: '0.2.7'
+ state:
+ description:
+ - State of the package on the system.
+ - When C(absent), will ensure the package is not installed.
+ - When C(present), will ensure the package is installed.
+ - When C(downgrade), will allow Chocolatey to downgrade a package if
+ I(version) is older than the installed version.
+ - When C(latest) or C(upgrade), will ensure the package is installed to the latest
+ available version.
+ - When C(reinstalled), will uninstall and reinstall the package.
+ type: str
+ choices: [ absent, downgrade, upgrade, latest, present, reinstalled ]
+ default: present
+ timeout:
+ description:
+ - The time to allow chocolatey to finish before timing out.
+ type: int
+ default: 2700
+ version_added: '0.2.3'
+ aliases: [ execution_timeout ]
+ validate_certs:
+ description:
+ - Used when downloading the Chocolatey install script if Chocolatey is not
+ already installed, this does not affect the Chocolatey package install
+ process.
+ - When C(no), no SSL certificates will be validated.
+ - This should only be used on personally controlled sites using self-signed
+ certificate.
+ type: bool
+ default: yes
+ version_added: '0.2.7'
+ version:
+ description:
+ - Specific version of the package to be installed.
+ - When I(state) is set to C(absent), will uninstall the specific version
+ otherwise all versions of that package will be removed.
+ - When I(state) is set to C(present) and the package is already installed
+ at a version that does not match, this task fails.
+ - If a different version of package is already installed, I(state) must be
+ C(latest), C(upgrade), or C(downgrade), or I(force) must be set to C(yes) to install
+ the desired version.
+ - Provide as a string (e.g. C('6.1')), otherwise it is considered to be
+ a floating-point number and depending on the locale could become C(6,1),
+ which will cause a failure.
+ - If I(name) is set to C(chocolatey) and Chocolatey is not installed on the
+ host, this will be the version of Chocolatey that is installed. You can
+ also set the C(chocolateyVersion) environment var.
+ type: str
+notes:
+- This module will install or upgrade Chocolatey when needed.
+- When using verbosity 2 or less (C(-vv)) the C(stdout) output will be restricted.
+ When using verbosity 4 (C(-vvvv)) the C(stdout) output will be more verbose.
+ When using verbosity 5 (C(-vvvvv)) the C(stdout) output will include debug output.
+- Some packages, like hotfixes or updates need an interactive user logon in
+ order to install. You can use C(become) to achieve this, see
+ :ref:`become_windows`.
+ Even if you are connecting as local Administrator, using C(become) to
+ become Administrator will give you an interactive user logon, see examples
+ below.
+- If C(become) is unavailable, use M(community.windows.win_hotfix) to install hotfixes instead
+ of M(chocolatey.chocolatey.win_chocolatey) as M(community.windows.win_hotfix) avoids using C(wusa.exe) which cannot
+ be run without C(become).
+seealso:
+- module: chocolatey.chocolatey.win_chocolatey_config
+- module: chocolatey.chocolatey.win_chocolatey_facts
+- module: chocolatey.chocolatey.win_chocolatey_feature
+- module: chocolatey.chocolatey.win_chocolatey_source
+- module: community.windows.win_feature
+- module: community.windows.win_hotfix
+ description: Use when C(become) is unavailable, to avoid using C(wusa.exe).
+- module: community.windows.win_package
+- module: community.windows.win_updates
+- name: Chocolatey website
+ description: More information about the Chocolatey tool.
+ link: http://chocolatey.org/
+- name: Chocolatey packages
+ description: An overview of the available Chocolatey packages.
+ link: http://chocolatey.org/packages
+- ref: become_windows
+ description: Some packages, like hotfixes or updates need an interactive user logon
+ in order to install. You can use C(become) to achieve this.
+author:
+- Trond Hindenes (@trondhindenes)
+- Peter Mounce (@petemounce)
+- Pepe Barbe (@elventear)
+- Adam Keech (@smadam813)
+- Pierre Templier (@ptemplier)
+- Jordan Borean (@jborean93)
+'''
+
+# TODO:
+# * Better parsing when a package has dependencies - currently fails
+# * Time each item that is run
+# * Support 'changed' with gems - would require shelling out to `gem list` first and parsing, kinda defeating the point of using chocolatey.
+# * Version provided not as string might be translated to 6,6 depending on Locale (results in errors)
+
+EXAMPLES = r'''
+- 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
+ version: '6.6'
+
+- name: Install notepadplusplus 32 bit version
+ win_chocolatey:
+ name: notepadplusplus
+ architecture: x86
+
+- name: Install git from specified repository
+ win_chocolatey:
+ name: git
+ source: https://someserver/api/v2/
+
+- name: Install git from a pre configured source (win_chocolatey_source)
+ win_chocolatey:
+ name: git
+ source: internal_repo
+
+- name: Ensure Chocolatey itself is installed, using community repo for the bootstrap
+ win_chocolatey:
+ name: chocolatey
+
+- name: Ensure Chocolatey itself is installed, bootstrapping with a specific nupkg url
+ win_chocolatey:
+ name: chocolatey
+ environment:
+ - chocolateyDownloadUrl: "https://internal-web-server/files/chocolatey.1.1.0.nupkg"
+
+- name: Ensure Chocolatey itself is installed and use internal repo as source for bootstrap script
+ win_chocolatey:
+ name: chocolatey
+ source: http://someserver/chocolatey
+
+- name: Ensure Chocolatey itself is installed, using a specific bootstrap script
+ win_chocolatey:
+ name: chocolatey
+ bootstrap_script: https://internal-web-server/files/custom-chocolatey-install.ps1
+
+- name: Ensure Chocolatey itself is installed, using a specific bootstrap script and target nupkg
+ win_chocolatey:
+ name: chocolatey
+ bootstrap_script: https://internal-web-server/files/custom-chocolatey-install.ps1
+ environment:
+ - chocolateyDownloadUrl: "https://internal-web-server/files/chocolatey.1.1.0.nupkg"
+
+- name: Uninstall git
+ win_chocolatey:
+ name: git
+ state: absent
+
+- name: Install multiple packages
+ win_chocolatey:
+ name:
+ - procexp
+ - putty
+ - windirstat
+ state: present
+
+- name: Install multiple packages sequentially
+ win_chocolatey:
+ name: '{{ item }}'
+ state: present
+ loop:
+ - procexp
+ - putty
+ - windirstat
+
+- name: Uninstall multiple packages
+ win_chocolatey:
+ name:
+ - procexp
+ - putty
+ - windirstat
+ state: absent
+
+- name: Uninstall a package and dependencies
+ win_chocolatey:
+ name: audacity-lame
+ remove_dependencies: yes
+ state: absent
+
+- name: Install curl using proxy
+ win_chocolatey:
+ name: curl
+ proxy_url: http://proxy-server:8080/
+ proxy_username: joe
+ proxy_password: p@ssw0rd
+
+- name: Install a package that requires 'become'
+ win_chocolatey:
+ name: officepro2013
+ become: yes
+ become_user: Administrator
+ become_method: runas
+
+- name: install and pin Notepad++ at 7.6.3
+ win_chocolatey:
+ name: notepadplusplus
+ version: 7.6.3
+ pinned: yes
+ state: present
+
+- name: remove all pins for Notepad++ on all versions
+ win_chocolatey:
+ name: notepadplusplus
+ pinned: no
+ state: present
+
+- name: install a package with options that require licensed edition
+ win_chocolatey:
+ name: foo
+ state: present
+ choco_args:
+ - --skip-download-cache
+ - --package-parameters-sensitive
+ - '/Password=SecretPassword'
+'''
+
+RETURN = r'''
+command:
+ description: The full command used in the chocolatey task.
+ returned: changed
+ type: str
+ sample: choco.exe install -r --no-progress -y sysinternals --timeout 2700 --failonunfound
+rc:
+ description: The return code from the chocolatey task.
+ returned: always
+ type: int
+ sample: 0
+stdout:
+ description: The stdout from the chocolatey task. The verbosity level of the
+ messages are affected by Ansible verbosity setting, see notes for more
+ details.
+ returned: changed
+ type: str
+ sample: Chocolatey upgraded 1/1 packages.
+'''
diff --git a/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_config.ps1 b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_config.ps1
new file mode 100644
index 00000000..d88fefc3
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_config.ps1
@@ -0,0 +1,108 @@
+#!powershell
+
+# Copyright: (c) 2018, Ansible Project
+# Copyright: (c) 2020, Chocolatey Software
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#Requires -Module Ansible.ModuleUtils.ArgvParser
+#Requires -Module Ansible.ModuleUtils.CommandUtil
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+
+#AnsibleRequires -PowerShell ansible_collections.chocolatey.chocolatey.plugins.module_utils.Common
+#AnsibleRequires -PowerShell ansible_collections.chocolatey.chocolatey.plugins.module_utils.Config
+
+[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
+ 'PSUseConsistentWhitespace',
+ '',
+ Justification = 'Relax whitespace rule for better readability in module spec',
+ Scope = 'function',
+ # Apply suppression specifically to module spec
+ Target = 'Get-ModuleSpec')]
+param()
+
+$ErrorActionPreference = "Stop"
+
+# Documentation: https://docs.ansible.com/ansible/2.10/dev_guide/developing_modules_general_windows.html#windows-new-module-development
+function Get-ModuleSpec {
+ @{
+ options = @{
+ name = @{ type = "str"; required = $true }
+ state = @{ type = "str"; default = "present"; choices = "absent", "present" }
+ value = @{ type = "str" }
+ }
+ required_if = @(
+ # Explicit prefix `,` required, Ansible wants a list of lists for `required_if`
+ # Read as:
+ # ,@( [if] property, [is] value, [require] other_properties, $true_if_only_one_other_is_required ) -- last option is not mandatory
+ , @( 'state', 'present', @( 'value' ) )
+ )
+ supports_check_mode = $true
+ }
+}
+
+$spec = Get-ModuleSpec
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec)
+Set-ActiveModule $module
+
+$name = $module.Params.name
+$state = $module.Params.state
+$value = $module.Params.value
+
+if ($module.DiffMode) {
+ $module.Diff.before = $null
+ $module.Diff.after = $null
+}
+
+if ($state -eq "present") {
+ if ([string]::IsNullOrEmpty($value)) {
+ $message = "Cannot set Chocolatey config as an empty string when state=present, use state=absent instead"
+ Assert-TaskFailed -Message $message
+ }
+
+ # make sure bool values are lower case
+ if ($value -ceq "True" -or $value -ceq "False") {
+ $value = $value.ToLower()
+ }
+}
+
+$chocoCommand = Get-ChocolateyCommand
+$config = Get-ChocolateyConfig -ChocoCommand $chocoCommand
+
+if ($name -notin $config.Keys) {
+ $message = "The Chocolatey config '{0}' is not an existing config value, check the spelling. Valid config names: {1}" -f @(
+ $name
+ $config.Keys -join ', '
+ )
+
+ Assert-TaskFailed -Message $message
+}
+
+if ($module.DiffMode) {
+ $module.Diff.before = $config.$name
+}
+
+if ($state -eq "absent" -and -not [string]::IsNullOrEmpty($config.$name)) {
+ if (-not $module.CheckMode) {
+ Remove-ChocolateyConfig -ChocoCommand $chocoCommand -Name $name
+ }
+
+ $module.Result.changed = $true
+}
+elseif ($state -eq "present" -and $value -ne $config.$name) {
+ # choco.exe config set is not case sensitive, it won't make a change if the
+ # value is the same but doesn't match, so we skip setting it as well in that
+ # case.
+
+ if (-not $module.CheckMode) {
+ Set-ChocolateyConfig -ChocoCommand $chocoCommand -Name $name -Value $value
+ }
+
+ $module.Result.changed = $true
+ if ($module.DiffMode) {
+ $module.Diff.after = $value
+ }
+}
+
+$module.ExitJson()
diff --git a/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_config.py b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_config.py
new file mode 100644
index 00000000..06bbb998
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_config.py
@@ -0,0 +1,67 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2018, Ansible Project
+# Copyright: (c) 2020, Chocolatey Software
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+ANSIBLE_METADATA = {'metadata_version': '1.1',
+ 'status': ['preview'],
+ 'supported_by': 'community'}
+
+DOCUMENTATION = r'''
+---
+module: win_chocolatey_config
+version_added: '0.2.7'
+short_description: Manages Chocolatey config settings
+description:
+- Used to manage Chocolatey config settings as well as unset the values.
+options:
+ name:
+ description:
+ - The name of the config setting to manage.
+ - See U(https://chocolatey.org/docs/chocolatey-configuration) for a list of
+ valid configuration settings that can be changed.
+ - Any config values that contain encrypted values like a password are not
+ idempotent as the plaintext value cannot be read.
+ type: str
+ required: yes
+ state:
+ description:
+ - When C(absent), it will ensure the setting is unset or blank.
+ - When C(present), it will ensure the setting is set to the value of
+ I(value).
+ type: str
+ choices: [ absent, present ]
+ default: present
+ value:
+ description:
+ - Used when C(state=present) that contains the value to set for the config
+ setting.
+ - Cannot be null or an empty string, use C(state=absent) to unset a config
+ value instead.
+ type: str
+seealso:
+- module: win_chocolatey
+- module: win_chocolatey_facts
+- module: win_chocolatey_feature
+- module: win_chocolatey_source
+author:
+- Jordan Borean (@jborean93)
+'''
+
+EXAMPLES = r'''
+- name: Set the cache location
+ win_chocolatey_config:
+ name: cacheLocation
+ state: present
+ value: D:\chocolatey_temp
+
+- name: Unset the cache location
+ win_chocolatey_config:
+ name: cacheLocation
+ state: absent
+'''
+
+RETURN = r'''
+'''
diff --git a/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_facts.ps1 b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_facts.ps1
new file mode 100644
index 00000000..edbd425e
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_facts.ps1
@@ -0,0 +1,65 @@
+#!powershell
+
+# Copyright: (c) 2018, Ansible Project
+# Copyright: (c) 2018, Simon Baerlocher <s.baerlocher@sbaerlocher.ch>
+# Copyright: (c) 2018, ITIGO AG <opensource@itigo.ch>
+# Copyright: (c) 2020, Chocolatey Software
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#Requires -Module Ansible.ModuleUtils.ArgvParser
+#Requires -Module Ansible.ModuleUtils.CommandUtil
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+
+#AnsibleRequires -PowerShell ansible_collections.chocolatey.chocolatey.plugins.module_utils.Common
+#AnsibleRequires -PowerShell ansible_collections.chocolatey.chocolatey.plugins.module_utils.Config
+#AnsibleRequires -PowerShell ansible_collections.chocolatey.chocolatey.plugins.module_utils.Sources
+#AnsibleRequires -PowerShell ansible_collections.chocolatey.chocolatey.plugins.module_utils.Features
+#AnsibleRequires -PowerShell ansible_collections.chocolatey.chocolatey.plugins.module_utils.Packages
+
+[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
+ 'PSUseConsistentWhitespace',
+ '',
+ Justification = 'Relax whitespace rule for better readability in module spec',
+ Scope = 'function',
+ # Apply suppression specifically to module spec
+ Target = 'Get-ModuleSpec')]
+param()
+
+$ErrorActionPreference = "Stop"
+Set-StrictMode -Version 2.0
+
+# Documentation: https://docs.ansible.com/ansible/2.10/dev_guide/developing_modules_general_windows.html#windows-new-module-development
+function Get-ModuleSpec {
+ @{
+ options = @{}
+ supports_check_mode = $true
+ }
+}
+
+$spec = Get-ModuleSpec
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec)
+Set-ActiveModule $module
+
+$chocoCommand = Get-ChocolateyCommand
+
+$module.Result.ansible_facts = @{
+ ansible_chocolatey = @{
+ config = @{}
+ feature = @{}
+ sources = @()
+ packages = @()
+ outdated = @()
+ }
+}
+
+$chocolateyFacts = $module.Result.ansible_facts.ansible_chocolatey
+$chocolateyFacts.config = Get-ChocolateyConfig -ChocoCommand $chocoCommand
+$chocolateyFacts.feature = Get-ChocolateyFeature -ChocoCommand $chocoCommand
+$chocolateyFacts.sources = @(Get-ChocolateySource -ChocoCommand $chocoCommand)
+$chocolateyFacts.packages = @(Get-ChocolateyPackage -ChocoCommand $chocoCommand)
+$chocolateyFacts.outdated = @(Get-ChocolateyOutdated -ChocoCommand $chocoCommand)
+
+# Return result
+$module.ExitJson()
diff --git a/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_facts.py b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_facts.py
new file mode 100644
index 00000000..ea75a67c
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_facts.py
@@ -0,0 +1,175 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2018, Ansible Project
+# Copyright: (c) 2018, Simon Baerlocher <s.baerlocher@sbaerlocher.ch>
+# Copyright: (c) 2018, ITIGO AG <opensource@itigo.ch>
+# Copyright: (c) 2020, Chocolatey Software
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+ANSIBLE_METADATA = {'metadata_version': '1.1',
+ 'status': ['preview'],
+ 'supported_by': 'community'}
+
+DOCUMENTATION = r'''
+---
+module: win_chocolatey_facts
+version_added: '0.2.8'
+short_description: Create a facts collection for Chocolatey
+description:
+- This module shows information from Chocolatey, such as installed packages, outdated packages, configuration, feature and sources.
+notes:
+- Chocolatey must be installed beforehand, use M(chocolatey.chocolatey.win_chocolatey) to do this.
+seealso:
+- module: chocolatey.chocolatey.win_chocolatey
+- module: chocolatey.chocolatey.win_chocolatey_config
+- module: chocolatey.chocolatey.win_chocolatey_feature
+- module: chocolatey.chocolatey.win_chocolatey_source
+author:
+- Simon Bärlocher (@sbaerlocher)
+- ITIGO AG (@itigoag)
+'''
+
+EXAMPLES = r'''
+- name: Gather facts from chocolatey
+ win_chocolatey_facts:
+
+- name: Displays the Configuration
+ debug:
+ var: ansible_chocolatey.config
+
+- name: Displays the Feature
+ debug:
+ var: ansible_chocolatey.feature
+
+- name: Displays the Sources
+ debug:
+ var: ansible_chocolatey.sources
+
+- name: Displays the Packages
+ debug:
+ var: ansible_chocolatey.packages
+
+- name: Displays the Outdated packages
+ debug:
+ var: ansible_chocolatey.outdated
+'''
+
+RETURN = r'''
+ansible_facts:
+ description: Detailed information about the Chocolatey installation
+ returned: always
+ type: complex
+ contains:
+ ansible_chocolatey:
+ description: Detailed information about the Chocolatey installation
+ returned: always
+ type: complex
+ contains:
+ config:
+ description: Detailed information about stored the configurations
+ returned: always
+ type: dict
+ sample:
+ commandExecutionTimeoutSeconds: 2700
+ containsLegacyPackageInstalls: true
+ feature:
+ description: Detailed information about enabled and disabled features
+ returned: always
+ type: dict
+ sample:
+ allowEmptyCheckums: false
+ autoUninstaller: true
+ failOnAutoUninstaller: false
+ sources:
+ description: List of Chocolatey sources
+ returned: always
+ type: complex
+ contains:
+ admin_only:
+ description: Is the source visible to Administrators only
+ returned: always
+ type: bool
+ sample: false
+ allow_self_service:
+ description: Is the source allowed to be used with self-service
+ returned: always
+ type: bool
+ sample: false
+ bypass_proxy:
+ description: Can the source explicitly bypass configured proxies
+ returned: always
+ type: bool
+ sample: true
+ certificate:
+ description: Pth to a PFX certificate for X509 authenticated feeds
+ returned: always
+ type: str
+ sample: C:\chocolatey\cert.pfx
+ disabled:
+ description: Is the source disabled
+ returned: always
+ type: bool
+ sample: false
+ name:
+ description: Name of the source
+ returned: always
+ type: str
+ sample: chocolatey
+ priority:
+ description: The priority order of this source, lower is better, 0 is no priority
+ returned: always
+ type: int
+ sample: 0
+ source:
+ description: The source, can be a folder/file or an url
+ returned: always
+ type: str
+ sample: https://community.chocolatey.org/api/v2/
+ source_username:
+ description: Username used to access authenticated feeds
+ returned: always
+ type: str
+ sample: username
+ packages:
+ description: List of installed Packages
+ returned: always
+ type: complex
+ contains:
+ package:
+ description: Name of the package
+ returned: always
+ type: str
+ sample: vscode
+ version:
+ description: Version of the package
+ returned: always
+ type: str
+ sample: '1.27.2'
+ outdated:
+ description: List of packages for which an update is available
+ returned: always
+ type: complex
+ version_added: '1.3.0'
+ contains:
+ available_version:
+ description: Available version of the package
+ returned: always
+ type: str
+ sample: 7.2.4
+ current_version:
+ description: Current version of the package
+ returned: always
+ type: str
+ sample: 7.2.3
+ package:
+ description: Name of the package
+ returned: always
+ type: str
+ sample: vscodepowershell-core",
+ pinned:
+ description: Is the version of the package pinned to suppress upgrades
+ returned: always
+ type: bool
+ sample: false
+'''
diff --git a/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_feature.ps1 b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_feature.ps1
new file mode 100644
index 00000000..b73ce91c
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_feature.ps1
@@ -0,0 +1,64 @@
+#!powershell
+
+# Copyright: (c), 2018 Ansible Project
+# Copyright: (c) 2020, Chocolatey Software
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#Requires -Module Ansible.ModuleUtils.ArgvParser
+#Requires -Module Ansible.ModuleUtils.CommandUtil
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+
+#AnsibleRequires -PowerShell ansible_collections.chocolatey.chocolatey.plugins.module_utils.Common
+#AnsibleRequires -PowerShell ansible_collections.chocolatey.chocolatey.plugins.module_utils.Features
+
+[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
+ 'PSUseConsistentWhitespace',
+ '',
+ Justification = 'Relax whitespace rule for better readability in module spec',
+ Scope = 'function',
+ # Apply suppression specifically to module spec
+ Target = 'Get-ModuleSpec')]
+param()
+
+$ErrorActionPreference = "Stop"
+
+# Documentation: https://docs.ansible.com/ansible/2.10/dev_guide/developing_modules_general_windows.html#windows-new-module-development
+function Get-ModuleSpec {
+ @{
+ options = @{
+ name = @{ type = "str"; required = $true }
+ state = @{ type = "str"; default = "enabled"; choices = "disabled", "enabled" }
+ }
+ supports_check_mode = $true
+ }
+}
+
+$spec = Get-ModuleSpec
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec)
+Set-ActiveModule $module
+
+$name = $module.Params.name
+$state = $module.Params.state
+
+$chocoCommand = Get-ChocolateyCommand
+$featureStates = Get-ChocolateyFeature -ChocoCommand $chocoCommand
+
+if ($name -notin $featureStates.Keys) {
+ $message = "Invalid feature name '$name' specified, valid features are: $($featureStates.Keys -join ', ')"
+ Assert-TaskFailed -Message $message
+}
+
+$shouldBeEnabled = $state -eq "enabled"
+$isEnabled = $featureStates.$name
+
+if ($isEnabled -ne $shouldBeEnabled) {
+ if (-not $module.CheckMode) {
+ Set-ChocolateyFeature -ChocoCommand $chocoCommand -Name $name -Enabled:$shouldBeEnabled
+ }
+
+ $module.Result.changed = $true
+}
+
+$module.ExitJson()
diff --git a/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_feature.py b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_feature.py
new file mode 100644
index 00000000..c6750443
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_feature.py
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2018, Ansible Project
+# Copyright: (c) 2020, Chocolatey Software
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+ANSIBLE_METADATA = {'metadata_version': '1.1',
+ 'status': ['preview'],
+ 'supported_by': 'community'}
+
+DOCUMENTATION = r'''
+---
+module: win_chocolatey_feature
+version_added: '0.2.7'
+short_description: Manages Chocolatey features
+description:
+- Used to enable or disable features in Chocolatey.
+options:
+ name:
+ description:
+ - The name of the feature to manage.
+ - Run C(choco.exe feature list) to get a list of features that can be
+ managed.
+ - For a list of options see L(Chocolatey feature docs,https://chocolatey.org/docs/chocolatey-configuration#features)
+ type: str
+ required: yes
+ state:
+ description:
+ - When C(disabled) then the feature will be disabled.
+ - When C(enabled) then the feature will be enabled.
+ type: str
+ choices: [ disabled, enabled ]
+ default: enabled
+seealso:
+- module: win_chocolatey
+- module: win_chocolatey_config
+- module: win_chocolatey_facts
+- module: win_chocolatey_source
+author:
+- Jordan Borean (@jborean93)
+'''
+
+EXAMPLES = r'''
+- name: Disable file checksum matching
+ win_chocolatey_feature:
+ name: checksumFiles
+ state: disabled
+
+- name: Stop Chocolatey on the first package failure
+ win_chocolatey_feature:
+ name: stopOnFirstPackageFailure
+ state: enabled
+'''
+
+RETURN = r'''
+'''
diff --git a/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_source.ps1 b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_source.ps1
new file mode 100644
index 00000000..5a3b75fd
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_source.ps1
@@ -0,0 +1,200 @@
+#!powershell
+
+# Copyright: (c) 2018, Ansible Project
+# Copyright: (c) 2020, Chocolatey Software
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#Requires -Module Ansible.ModuleUtils.ArgvParser
+#Requires -Module Ansible.ModuleUtils.CommandUtil
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+
+#AnsibleRequires -PowerShell ansible_collections.chocolatey.chocolatey.plugins.module_utils.Common
+#AnsibleRequires -PowerShell ansible_collections.chocolatey.chocolatey.plugins.module_utils.Sources
+
+[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
+ 'PSUseConsistentWhitespace',
+ '',
+ Justification = 'Relax whitespace rule for better readability in module spec',
+ Scope = 'function',
+ # Apply suppression specifically to module spec
+ Target = 'Get-ModuleSpec')]
+param()
+
+# Documentation: https://docs.ansible.com/ansible/2.10/dev_guide/developing_modules_general_windows.html#windows-new-module-development
+function Get-ModuleSpec {
+ @{
+ options = @{
+ name = @{ type = "str"; required = $true }
+ state = @{ type = "str"; default = "present"; choices = "absent", "disabled", "present" }
+
+ admin_only = @{ type = "bool" }
+ allow_self_service = @{ type = "bool" }
+ bypass_proxy = @{ type = "bool" }
+ certificate = @{ type = "str" }
+ certificate_password = @{ type = "str"; no_log = $true }
+ priority = @{ type = "int" }
+ source = @{ type = "str" }
+ source_username = @{ type = "str" }
+ source_password = @{ type = "str"; no_log = $true }
+ update_password = @{ type = "str"; default = "always"; choices = "always", "on_create" }
+ }
+ supports_check_mode = $true
+ required_together = @(
+ # Explicit `,` prefix required to prevent the array unrolling, Ansible requires nested arrays here.
+ , @( 'source_username', 'source_password' )
+ )
+ required_by = @{
+ 'certificate_password' = 'certificate'
+ }
+ }
+}
+
+$spec = Get-ModuleSpec
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec)
+Set-ActiveModule $module
+
+$name = $module.Params.name
+$state = $module.Params.state
+
+$admin_only = $module.Params.admin_only
+$allow_self_service = $module.Params.allow_self_service
+$bypass_proxy = $module.Params.bypass_proxy
+$certificate = $module.Params.certificate
+$certificate_password = $module.Params.certificate_password
+$priority = $module.Params.priority
+$source = $module.Params.source
+$source_username = $module.Params.source_username
+$source_password = $module.Params.source_password
+$update_password = $module.Params.update_password
+
+if ($module.DiffMode) {
+ $module.Diff.before = @{}
+ $module.Diff.after = @{}
+}
+
+$chocoCommand = Get-ChocolateyCommand
+
+$targetSource = Get-ChocolateySource -ChocoCommand $chocoCommand | Where-Object { $_.name -eq $name }
+
+if ($module.DiffMode) {
+ if ($null -ne $targetSource) {
+ $before = $targetSource.Clone()
+ }
+ else {
+ $before = @{}
+ }
+
+ $module.Diff.before = $before
+}
+
+if ($state -eq "absent" -and $null -ne $targetSource) {
+ Remove-ChocolateySource -ChocoCommand $chocoCommand -Name $name
+ $module.Result.changed = $true
+}
+elseif ($state -in ("disabled", "present")) {
+ $change = $false
+
+ if ($null -eq $targetSource) {
+ if ($null -eq $source) {
+ $message = "The source option must be set when creating a new source"
+ Assert-TaskFailed -Message $message
+ }
+
+ $change = $true
+ }
+ else {
+ $change = ($null -ne $source -and $source -ne $targetSource.source) -or
+ ($null -ne $source_username -and $source_username -ne $targetSource.source_username) -or
+ ($null -ne $source_password -and $update_password -eq "always") -or
+ ($null -ne $certificate -and $certificate -ne $targetSource.certificate) -or
+ ($null -ne $certificate_password -and $update_password -eq "always") -or
+ ($null -ne $priority -and $priority -ne $targetSource.priority) -or
+ ($null -ne $bypass_proxy -and $bypass_proxy -ne $targetSource.bypass_proxy) -or
+ ($null -ne $allow_self_service -and $allow_self_service -ne $targetSource.allow_self_service) -or
+ ($null -ne $admin_only -and $admin_only -ne $targetSource.admin_only)
+
+ if ($change) {
+ Remove-ChocolateySource -ChocoCommand $chocoCommand -Name $Name
+ $module.Result.changed = $true
+ }
+ }
+
+ if ($change) {
+ $sourceParams = @{
+ ChocoCommand = $chocoCommand
+ Name = $name
+ Source = $source
+ BypassProxy = $bypass_proxy
+ AllowSelfService = $allow_self_service
+ AdminOnly = $admin_only
+ }
+
+ if ($null -ne $priority) {
+ $sourceParams.Priority = $priority
+ }
+
+ if ($null -ne $source_username) {
+ $sourceParams.Username = $source_username
+ $sourceParams.Password = $source_password
+ }
+
+ if ($null -ne $certificate) {
+ $sourceParams.Certificate = $certificate
+
+ if ($null -ne $certificate_password) {
+ $sourceParams.CertificatePassword = $certificate_password
+ }
+ }
+
+ $targetSource = New-ChocolateySource @sourceParams
+ $module.Result.changed = $true
+ }
+
+ # enable/disable the source if necessary
+ $action = if ($state -ne "disabled" -and $targetSource.disabled) {
+ "enable"
+ }
+ elseif ($state -eq "disabled" -and (-not $targetSource.disabled)) {
+ "disable"
+ }
+ else {
+ $null
+ }
+
+ if ($null -ne $action) {
+ $arguments = @(
+ $chocoCommand.Path
+ "source", $action
+ "--name", $name
+
+ if ($module.CheckMode) {
+ "--what-if"
+ }
+ )
+
+ $command = Argv-ToString -Arguments $arguments
+ $result = Run-Command -Command $command
+
+ if ($result.rc -ne 0) {
+ $message = "Failed to $action Chocolatey source '$name': $($result.stderr)"
+ Assert-TaskFailed -Message $message -CommandResult $result
+ }
+
+ $targetSource.disabled = ($action -eq "disable")
+ $module.Result.changed = $true
+ }
+
+ if ($module.DiffMode) {
+ $module.Diff.after = $targetSource
+ }
+}
+
+# finally remove the diff if there was no change
+if ($module.DiffMode -and -not $module.Result.changed) {
+ $module.Diff.before = @{}
+ $module.Diff.after = @{}
+}
+
+$module.ExitJson()
diff --git a/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_source.py b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_source.py
new file mode 100644
index 00000000..420639d6
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/plugins/modules/win_chocolatey_source.py
@@ -0,0 +1,136 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2018, Ansible Project
+# Copyright: (c) 2020, Chocolatey Software
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+ANSIBLE_METADATA = {'metadata_version': '1.1',
+ 'status': ['preview'],
+ 'supported_by': 'community'}
+
+DOCUMENTATION = r'''
+---
+module: win_chocolatey_source
+version_added: '0.2.7'
+short_description: Manages Chocolatey sources
+description:
+- Used to managed Chocolatey sources configured on the client.
+- Requires Chocolatey to be already installed on the remote host.
+options:
+ admin_only:
+ description:
+ - Makes the source visible to Administrators only.
+ - Requires Chocolatey >= 0.10.8.
+ - When creating a new source, this defaults to C(no).
+ type: bool
+ allow_self_service:
+ description:
+ - Allow the source to be used with self-service
+ - Requires Chocolatey >= 0.10.4.
+ - When creating a new source, this defaults to C(no).
+ type: bool
+ bypass_proxy:
+ description:
+ - Bypass the proxy when using this source.
+ - Requires Chocolatey >= 0.10.4.
+ - When creating a new source, this defaults to C(no).
+ type: bool
+ certificate:
+ description:
+ - The path to a .pfx file to use for X509 authenticated feeds.
+ - Requires Chocolatey >= 0.9.10.
+ type: str
+ certificate_password:
+ description:
+ - The password for I(certificate) if required.
+ - Requires Chocolatey >= 0.9.10.
+ type: str
+ name:
+ description:
+ - The name of the source to configure.
+ required: yes
+ type: str
+ priority:
+ description:
+ - The priority order of this source compared to other sources, lower is
+ better.
+ - All priorities above C(0) will be evaluated first, then zero-based values
+ will be evaluated in config file order.
+ - Requires Chocolatey >= 0.9.9.9.
+ - When creating a new source, this defaults to C(0).
+ type: int
+ source:
+ description:
+ - The file/folder/url of the source.
+ - Required when I(state) is C(present) or C(disabled) and the source does
+ not already exist.
+ type: str
+ source_username:
+ description:
+ - The username used to access I(source).
+ type: str
+ source_password:
+ description:
+ - The password for I(source_username).
+ - Required if I(source_username) is set.
+ type: str
+ state:
+ description:
+ - When C(absent), will remove the source.
+ - When C(disabled), will ensure the source exists but is disabled.
+ - When C(present), will ensure the source exists and is enabled.
+ choices:
+ - absent
+ - disabled
+ - present
+ default: present
+ type: str
+ update_password:
+ description:
+ - When C(always), the module will always set the password and report a
+ change if I(certificate_password) or I(source_password) is set.
+ - When C(on_create), the module will only set the password if the source
+ is being created.
+ choices:
+ - always
+ - on_create
+ default: always
+ type: str
+seealso:
+- module: win_chocolatey
+- module: win_chocolatey_config
+- module: win_chocolatey_facts
+- module: win_chocolatey_feature
+author:
+- Jordan Borean (@jborean93)
+'''
+
+EXAMPLES = r'''
+- name: Remove the default public source
+ win_chocolatey_source:
+ name: chocolatey
+ state: absent
+
+- name: Add new internal source
+ win_chocolatey_source:
+ name: internal repo
+ state: present
+ source: http://chocolatey-server/chocolatey
+
+- name: Create HTTP source with credentials
+ win_chocolatey_source:
+ name: internal repo
+ state: present
+ source: https://chocolatey-server/chocolatey
+ source_username: username
+ source_password: password
+
+- name: Disable Chocolatey source
+ win_chocolatey_source:
+ name: chocolatey
+ state: disabled
+'''
+
+RETURN = r'''
+'''
diff --git a/ansible_collections/chocolatey/chocolatey/requirements.txt b/ansible_collections/chocolatey/chocolatey/requirements.txt
new file mode 100644
index 00000000..17a16ff2
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/requirements.txt
@@ -0,0 +1 @@
+pywinrm
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/defaults/main.yml b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/defaults/main.yml
new file mode 100644
index 00000000..eb5289d3
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/defaults/main.yml
@@ -0,0 +1,9 @@
+---
+test_choco_path: '{{ win_output_dir }}\win_chocolatey'
+test_choco_source: '{{ test_choco_path }}\packages'
+test_choco_source2: '{{ test_choco_path }}\packages2' # used to verify source works with the source name and not just the path
+test_choco_package1: ansible
+test_choco_package2: ansible-test
+test_choco_packages:
+- '{{ test_choco_package1 }}'
+- '{{ test_choco_package2 }}'
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/files/test-package/package.nuspec b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/files/test-package/package.nuspec
new file mode 100644
index 00000000..b5a3e409
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/files/test-package/package.nuspec
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
+ <metadata>
+ <id>--- NAME ---</id>
+ <version>--- VERSION ---</version>
+ <title>--- NAME ---</title>
+ <authors>Jordan Borean</authors>
+ <description>Test for win_chocolatey module</description>
+ </metadata>
+ <files>
+ <file src="tools\**" target="tools" />
+ </files>
+</package>
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/files/test-package/tools/chocolateyUninstall.ps1 b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/files/test-package/tools/chocolateyUninstall.ps1
new file mode 100644
index 00000000..921f6e4d
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/files/test-package/tools/chocolateyUninstall.ps1
@@ -0,0 +1,9 @@
+$ErrorActionPreference = 'Stop'
+
+$package_name = $env:ChocolateyPackageName
+$package_version = $env:ChocolateyPackageVersion
+$install_path = "--- PATH ---\$package_name-$package_version.txt"
+
+if (Test-Path -LiteralPath $install_path) {
+ Remove-Item -LiteralPath $install_path -Force > $null
+}
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/files/test-package/tools/chocolateyinstall.ps1 b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/files/test-package/tools/chocolateyinstall.ps1
new file mode 100644
index 00000000..47d3ee0d
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/files/test-package/tools/chocolateyinstall.ps1
@@ -0,0 +1,66 @@
+$ErrorActionPreference = 'Stop'
+
+$package_name = $env:ChocolateyPackageName
+$package_version = $env:ChocolateyPackageVersion
+$install_path = "--- PATH ---\$package_name-$package_version.txt"
+$source = "--- SOURCE ---" # used by the test to determine which source it was installed from
+
+if ($env:ChocolateyAllowEmptyChecksums) {
+ $allow_empty_checksums = $true
+}
+else {
+ $allow_empty_checksums = $false
+}
+
+if ($env:ChocolateyIgnoreChecksums) {
+ $ignore_checksums = $true
+}
+else {
+ $ignore_checksums = $false
+}
+
+if ($env:ChocolateyForce) {
+ $force = $true
+}
+else {
+ $force = $false
+}
+
+if ($env:ChocolateyForceX86) {
+ $force_x86 = $true
+}
+else {
+ $force_x86 = $false
+}
+
+if ($env:ChocolateyInstallOverride) {
+ $override_args = $true
+}
+else {
+ $override_args = $false
+}
+
+#$process_env = Get-EnvironmentVariableNames -Scope Process
+#$env_vars = @{}
+#foreach ($name in $process_env) {
+# $env_vars.$name = Get-EnvironmentVariable -Name $name -Scope Process
+#}
+
+$timeout = $env:chocolateyResponseTimeout
+
+$package_info = @{
+ allow_empty_checksums = $allow_empty_checksums
+ #env_vars = $env_vars
+ force = $force
+ force_x86 = $force_x86
+ ignore_checksums = $ignore_checksums
+ install_args = $env:ChocolateyInstallArguments
+ override_args = $override_args
+ package_params = Get-PackageParameters
+ proxy_url = $env:ChocolateyProxyLocation
+ source = $source
+ timeout = $timeout
+}
+$package_json = ConvertTo-Json -InputObject $package_info
+
+[System.IO.File]::WriteAllText($install_path, $package_json)
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/tasks/main.yml b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/tasks/main.yml
new file mode 100644
index 00000000..d9cc0304
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/setup_win_chocolatey/tasks/main.yml
@@ -0,0 +1,87 @@
+---
+- name: ensure test package is uninstalled
+ win_chocolatey:
+ name: '{{ test_choco_packages }}'
+ state: absent
+
+- name: ensure testing dir is cleaned
+ win_file:
+ path: '{{ test_choco_path }}'
+ state: '{{ item }}'
+ with_items:
+ - absent
+ - directory
+
+- name: copy template package files
+ win_copy:
+ src: files/test-package/
+ dest: '{{ test_choco_path }}'
+
+# run the setup in 1 shell script to save on test time
+- name: set up packages
+ win_shell: |
+ $ErrorActionPreference = "Stop"
+ $root_path = '{{ test_choco_path }}'
+ $packages_path = '{{ test_choco_source }}'
+ $packages_path_override = '{{ test_choco_source2 }}'
+ $packages = @(
+ @{ name = "ansible"; version = "0.0.1"; override = $false },
+ @{ name = "ansible"; version = "0.1.0"; override = $false },
+ @{ name = "ansible"; version = "0.1.0"; override = $true },
+ @{ name = "ansible-test"; version = "1.0.0"; override = $false },
+ @{ name = "ansible-test"; version = "1.0.1-beta1"; override = $false }
+ )
+ $nuspec_src = "$root_path\package.nuspec"
+ $install_src = "$root_path\tools\chocolateyinstall.ps1"
+ $uninstall_src = "$root_path\tools\chocolateyUninstall.ps1"
+
+ New-Item -Path $packages_path -ItemType Directory > $null
+ New-Item -Path $packages_path_override -ItemType Directory > $null
+
+ foreach ($package in $packages) {
+ $package_dir = "$root_path\$($package.name)-$($package.version)"
+ New-Item -Path $package_dir -ItemType Directory > $null
+ New-Item -Path "$package_dir\tools" -ItemType Directory > $null
+
+ if ($package.override) {
+ $out_path = $packages_path_override
+ $source_value = "override"
+ } else {
+ $out_path = $packages_path
+ $source_value = "normal"
+ }
+
+ $nuspec_text = ([System.IO.File]::ReadAllLines($nuspec_src) -join "`r`n")
+ $nuspec_text = $nuspec_text.Replace('--- NAME ---', $package.name).Replace('--- VERSION ---', $package.version)
+
+ $install_text = ([System.IO.File]::ReadAllLines($install_src) -join "`r`n")
+ $install_text = $install_text.Replace('--- PATH ---', $root_path).Replace('--- SOURCE ---', $source_value)
+
+ $uninstall_text = ([System.IO.File]::ReadAllLines($uninstall_src) -join "`r`n")
+ $uninstall_text = $uninstall_text.Replace('--- PATH ---', $root_path)
+
+ $utf8 = New-Object -TypeName System.Text.UTF8Encoding -ArgumentList $false
+ $utf8_bom = New-Object -TypeName System.Text.UTF8Encoding -ArgumentList $true
+ [System.IO.File]::WriteAllText("$package_dir\$($package.name).nuspec", $nuspec_text, $utf8)
+ [System.IO.File]::WriteAllText("$package_dir\tools\chocolateyinstall.ps1", $install_text, $utf8_bom)
+ [System.IO.File]::WriteAllText("$package_dir\tools\chocolateyUninstall.ps1", $uninstall_text, $utf8_bom)
+
+ &choco.exe pack --out $out_path --no-progress --limit-output "$package_dir\$($package.name).nuspec"
+ Remove-Item -Path $package_dir -Force -Recurse > $null
+ }
+ Remove-Item -Path "$root_path\tools" -Force -Recurse > $null
+ Remove-Item -Path $nuspec_src > $null
+
+- name: set up Chocolatey sources
+ win_chocolatey_source:
+ name: '{{ item.name }}'
+ priority: '{{ item.priority }}'
+ source: '{{ item.src }}'
+ state: present
+ with_items:
+ - name: ansible-test
+ priority: 1
+ src: '{{ test_choco_source }}'
+ - name: ansible-test-override
+ priority: 2
+ src: '{{ test_choco_source2 }}'
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/aliases b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/aliases
new file mode 100644
index 00000000..4f4664b6
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/aliases
@@ -0,0 +1 @@
+shippable/windows/group5
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/defaults/main.yml b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/defaults/main.yml
new file mode 100644
index 00000000..49114fc3
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/defaults/main.yml
@@ -0,0 +1,4 @@
+---
+test_choco_bootstrap_script: '{{ win_output_dir }}/test-bootstrap.ps1'
+test_choco_backup: '{{ win_output_dir }}/backup/'
+choco_install_dir: 'C:/ProgramData/chocolatey/'
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/files/bootstrap.ps1 b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/files/bootstrap.ps1
new file mode 100644
index 00000000..4248c52e
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/files/bootstrap.ps1
@@ -0,0 +1,25 @@
+# This is a minimal bootstrap script which simply pulls the default bootstrap
+# script from community.chocolatey.org and then uses that to install Chocolatey.
+# Afterwards, a file is created so we can confirm this bootstrap script was
+# indeed used to install Chocolatey.
+
+$protocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [System.Net.SecurityProtocolType]::Tls12
+[System.Net.ServicePointManager]::SecurityProtocol = $protocol
+
+$client = New-Object System.Net.WebClient
+$scriptContent = $client.DownloadString("https://community.chocolatey.org/install.ps1")
+$filePath = "$PSScriptRoot/install.ps1"
+
+$scriptContent | Set-Content -Path $filePath
+
+$ErrorActionPreference = 'Stop'
+
+# Parameters aren't needed; our Ansible installation process sets all the parameters
+# with environment variables before running the bootstrap script.
+& $filePath
+
+$temp = "C:\temp"
+if (-not (Test-Path -LiteralPath $temp)) {
+ New-Item -ItemType Directory -Path $temp -Force > $null
+}
+[pscustomobject]@{ bootstrap = $true } | ConvertTo-Json | Set-Content -Path "$temp\confirm-bootstrap.txt"
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/meta/main.yml b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/meta/main.yml
new file mode 100644
index 00000000..76ff5d34
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/meta/main.yml
@@ -0,0 +1,4 @@
+---
+
+dependencies:
+ - setup_win_chocolatey
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/tasks/bootstrap_tests.yml b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/tasks/bootstrap_tests.yml
new file mode 100644
index 00000000..f7095131
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/tasks/bootstrap_tests.yml
@@ -0,0 +1,54 @@
+---
+- name: copy test bootstrap script
+ win_copy:
+ src: files/bootstrap.ps1
+ dest: '{{ test_choco_bootstrap_script }}'
+
+- name: backup Chocolatey installation
+ win_copy:
+ src: '{{ choco_install_dir }}'
+ dest: '{{ test_choco_backup }}'
+ remote_src: yes
+
+- name: ensure Chocolatey is not installed
+ win_file:
+ path: '{{ choco_install_dir }}'
+ state: absent
+
+- name: install Chocolatey using the test bootstrap script
+ win_chocolatey:
+ name: chocolatey
+ state: present
+ bootstrap_script: "{{ test_choco_bootstrap_script }}"
+
+- name: checking if the bootstrap file has been created
+ win_shell: Get-Content -Path "C:/temp/confirm-bootstrap.txt" -Raw
+ register: bootstrap_file_check
+
+- name: assert bootstrap file has been created
+ assert:
+ that:
+ - (bootstrap_file_check.stdout|from_json).bootstrap
+
+- name: ensure Chocolatey is not installed
+ win_file:
+ path: '{{ choco_install_dir }}'
+ state: absent
+
+- name: installing Chocolatey from Community Repository with TLS 1.1 only should fail
+ win_chocolatey:
+ name: chocolatey
+ bootstrap_tls_version: [ tls11 ]
+ register: test_tls_version
+ failed_when: not test_tls_version.failed
+
+- name: ensure no leftover files from failed install
+ win_file:
+ path: '{{ choco_install_dir }}'
+ state: absent
+
+- name: restore Chocolatey installation from backup
+ win_copy:
+ src: '{{ test_choco_backup }}'
+ dest: '{{ choco_install_dir }}'
+ remote_src: yes
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/tasks/main.yml b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/tasks/main.yml
new file mode 100644
index 00000000..3b52a53f
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/tasks/main.yml
@@ -0,0 +1,27 @@
+---
+
+- block:
+ - name: run bootstrap tests
+ include_tasks: bootstrap_tests.yml
+
+ - name: run tests
+ include_tasks: tests.yml
+
+ always:
+ - name: ensure test package is uninstalled after tests
+ win_chocolatey:
+ name: '{{ test_choco_packages }}'
+ state: absent
+
+ - name: remove test sources
+ win_chocolatey_source:
+ name: '{{ item }}'
+ state: absent
+ with_items:
+ - ansible-test
+ - ansible-test-override
+
+ - name: remove testing dir
+ win_file:
+ path: '{{ test_choco_path }}'
+ state: absent
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/tasks/tests.yml b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/tasks/tests.yml
new file mode 100644
index 00000000..ed0eedcf
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey/tasks/tests.yml
@@ -0,0 +1,755 @@
+---
+- name: raise failure when state=present and name=all
+ win_chocolatey:
+ name: all
+ state: present
+ register: fail_all_present
+ failed_when: fail_all_present.msg != "Cannot specify the package name as 'all' when state=present"
+
+- name: raise failure when state=reinstalled and name=all
+ win_chocolatey:
+ name: all
+ state: reinstalled
+ register: fail_all_reinstalled
+ failed_when: fail_all_reinstalled.msg != "Cannot specify the package name as 'all' when state=reinstalled"
+
+- name: install package (check mode)
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: present
+ check_mode: yes
+ register: install_check
+
+- name: get result of install package (check mode)
+ win_command: choco.exe list --local-only --exact --limit-output {{ test_choco_package1|quote }}
+ register: install_actual_check
+ failed_when: not install_actual_check.rc in [0, 2] # v0.10.12+ returns 2 for no package
+
+- name: assert install package (check mode)
+ assert:
+ that:
+ - install_check is changed
+ - install_actual_check.stdout_lines == []
+
+- name: install package
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: present
+ register: install
+
+- name: get result of install package
+ win_command: choco.exe list --local-only --exact --limit-output {{ test_choco_package1|quote }}
+ register: install_actual
+
+- name: get package info of install package
+ win_shell: Get-Content -Path '{{ test_choco_path }}\{{ test_choco_package1 }}-0.1.0.txt' -Raw
+ register: install_actual_info
+
+- name: assert install package
+ assert:
+ that:
+ - install is changed
+ - install_actual.stdout_lines == [test_choco_package1 + "|0.1.0"]
+ - (install_actual_info.stdout|from_json).allow_empty_checksums == False
+ - (install_actual_info.stdout|from_json).force == False
+ - (install_actual_info.stdout|from_json).force_x86 == False
+ - (install_actual_info.stdout|from_json).ignore_checksums == False
+ - (install_actual_info.stdout|from_json).install_args == None
+ - (install_actual_info.stdout|from_json).override_args == False
+ - (install_actual_info.stdout|from_json).package_params == {}
+ - (install_actual_info.stdout|from_json).proxy_url == None
+ - (install_actual_info.stdout|from_json).source == "normal"
+ - (install_actual_info.stdout|from_json).timeout == "2700000"
+
+- name: install package (idempotent)
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: present
+ register: install_again
+
+- name: assert install package (idempotent)
+ assert:
+ that:
+ - not install_again is changed
+
+- name: remove package (check mode)
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: absent
+ check_mode: yes
+ register: remove_check
+
+- name: get result of remove package (check mode)
+ win_command: choco.exe list --local-only --exact --limit-output {{ test_choco_package1|quote }}
+ register: remove_actual_check
+
+- name: assert remove package (check mode)
+ assert:
+ that:
+ - remove_check is changed
+ - remove_actual_check.stdout_lines == [test_choco_package1 + "|0.1.0"]
+
+- name: remove package
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: absent
+ register: remove
+
+- name: get result of remove package
+ win_command: choco.exe list --local-only --exact --limit-output {{ test_choco_package1|quote }}
+ register: remove_actual
+ failed_when: not remove_actual.rc in [0, 2]
+
+- name: check if removed package file still exists
+ win_stat:
+ path: '{{ test_choco_path }}\{{ test_choco_package1 }}-0.1.0.txt'
+ register: remove_actual_info
+
+- name: assert remove package
+ assert:
+ that:
+ - remove is changed
+ - remove_actual.stdout_lines == []
+ - remove_actual_info.stat.exists == False
+
+- name: remove package (idempotent)
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: absent
+ register: remove_again
+
+- name: assert remove_package (idempotent)
+ assert:
+ that:
+ - not remove_again is changed
+
+- name: install multiple packages with timeout
+ win_chocolatey:
+ name: '{{ test_choco_packages }}'
+ state: present
+ timeout: 1000
+ register: install_multiple
+
+- name: get list of installed packages with timeout
+ win_command: choco.exe list --local-only --limit-output ansible
+ register: install_multiple_actual
+
+- name: get info on package 1
+ win_shell: Get-Content -Path '{{ test_choco_path }}\{{ test_choco_package1 }}-0.1.0.txt' -Raw
+ register: install_multiple_package1
+
+- name: get info on package 2
+ win_shell: Get-Content -Path '{{ test_choco_path }}\{{ test_choco_package2 }}-1.0.0.txt' -Raw
+ register: install_multiple_package2
+
+- name: assert install multiple packages with timeout
+ assert:
+ that:
+ - install_multiple is changed
+ - install_multiple_actual.stdout_lines == [test_choco_package1 + "|0.1.0", test_choco_package2 + "|1.0.0"]
+ - (install_multiple_package1.stdout|from_json).allow_empty_checksums == False
+ - (install_multiple_package1.stdout|from_json).force == False
+ - (install_multiple_package1.stdout|from_json).force_x86 == False
+ - (install_multiple_package1.stdout|from_json).ignore_checksums == False
+ - (install_multiple_package1.stdout|from_json).install_args == None
+ - (install_multiple_package1.stdout|from_json).override_args == False
+ - (install_multiple_package1.stdout|from_json).package_params == {}
+ - (install_multiple_package1.stdout|from_json).proxy_url == None
+ - (install_multiple_package1.stdout|from_json).source == "normal"
+ - (install_multiple_package1.stdout|from_json).timeout == "1000000"
+ - (install_multiple_package2.stdout|from_json).allow_empty_checksums == False
+ - (install_multiple_package2.stdout|from_json).force == False
+ - (install_multiple_package2.stdout|from_json).force_x86 == False
+ - (install_multiple_package2.stdout|from_json).ignore_checksums == False
+ - (install_multiple_package2.stdout|from_json).install_args == None
+ - (install_multiple_package2.stdout|from_json).override_args == False
+ - (install_multiple_package2.stdout|from_json).package_params == {}
+ - (install_multiple_package2.stdout|from_json).proxy_url == None
+ - (install_multiple_package2.stdout|from_json).source == "normal"
+ - (install_multiple_package2.stdout|from_json).timeout == "1000000"
+
+- name: install multiple packages (idempotent)
+ win_chocolatey:
+ name: '{{ test_choco_packages }}'
+ state: present
+ register: install_multiple_again
+
+- name: assert install multiple packages (idempotent)
+ assert:
+ that:
+ - not install_multiple_again is changed
+
+- name: remove multiple packages
+ win_chocolatey:
+ name: '{{ test_choco_packages }}'
+ state: absent
+ register: remove_multiple
+
+- name: get list of installed packages after removal
+ win_command: choco.exe list --local-only --limit-output ansible
+ register: remove_multiple_actual
+ failed_when: not remove_multiple_actual.rc in [0, 2]
+
+- name: get info on package 1
+ win_stat:
+ path: '{{ test_choco_path }}\{{ test_choco_package1 }}-0.1.0.txt'
+ register: remove_multiple_package1
+
+- name: get info on package 2
+ win_stat:
+ path: '{{ test_choco_path }}\{{ test_choco_package2 }}-1.0.0.txt'
+ register: remove_multiple_package2
+
+- name: assert remove multiple packages
+ assert:
+ that:
+ - remove_multiple is changed
+ - remove_multiple_actual.stdout_lines == []
+ - remove_multiple_package1.stat.exists == False
+ - remove_multiple_package2.stat.exists == False
+
+- name: remove multiple packages (idempotent)
+ win_chocolatey:
+ name: '{{ test_choco_packages }}'
+ state: absent
+ register: remove_multiple_again
+
+- name: assert remove multiple packages (idempotent)
+ assert:
+ that:
+ - not remove_multiple_again is changed
+
+- name: install package with explicit version and state=present
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: present
+ version: 0.1.0
+ register: install_with_version_and_state_present
+
+- name: get result of install package with explicit version and state=present
+ win_command: choco.exe list --local-only --exact --limit-output {{ test_choco_package1|quote }}
+ register: install_with_version_and_state_present_actual
+
+- name: get package info of install package with explicit version and state=present
+ win_shell: Get-Content -Path '{{ test_choco_path }}\{{ test_choco_package1 }}-0.1.0.txt' -Raw
+ register: install_with_version_and_state_present_actual_info
+
+- name: assert install package with explicit version and state=present
+ assert:
+ that:
+ - install_with_version_and_state_present is changed
+ - install_with_version_and_state_present_actual.stdout_lines == [test_choco_package1 + "|0.1.0"]
+ - (install_with_version_and_state_present_actual_info.stdout|from_json).allow_empty_checksums == False
+ - (install_with_version_and_state_present_actual_info.stdout|from_json).force == False
+ - (install_with_version_and_state_present_actual_info.stdout|from_json).force_x86 == False
+ - (install_with_version_and_state_present_actual_info.stdout|from_json).ignore_checksums == False
+ - (install_with_version_and_state_present_actual_info.stdout|from_json).install_args == None
+ - (install_with_version_and_state_present_actual_info.stdout|from_json).override_args == False
+ - (install_with_version_and_state_present_actual_info.stdout|from_json).package_params == {}
+ - (install_with_version_and_state_present_actual_info.stdout|from_json).proxy_url == None
+ - (install_with_version_and_state_present_actual_info.stdout|from_json).source == "normal"
+ - (install_with_version_and_state_present_actual_info.stdout|from_json).timeout == "2700000"
+
+- name: install package with params
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: present
+ install_args: /install_arg 1 /install_arg 2
+ override_args: yes
+ package_params: /param1 /param2:value
+ allow_empty_checksums: yes
+ architecture: x86
+ force: yes
+ ignore_checksums: yes
+ proxy_url: http://proxyhost
+ version: 0.0.1
+ register: install_params
+
+- name: get result of install package with params
+ win_command: choco.exe list --local-only --limit-output --exact {{ test_choco_package1|quote }}
+ register: install_params_actual
+
+- name: get info of install package with params
+ win_shell: Get-Content -Path '{{ test_choco_path }}\{{ test_choco_package1 }}-0.0.1.txt'
+ register: install_params_info
+
+- name: assert install package with params
+ assert:
+ that:
+ - install_params is changed
+ - install_params_actual.stdout_lines == [test_choco_package1 + "|0.0.1"]
+ - (install_params_info.stdout|from_json).allow_empty_checksums == True
+ - (install_params_info.stdout|from_json).force == True
+ - (install_params_info.stdout|from_json).force_x86 == True
+ - (install_params_info.stdout|from_json).ignore_checksums == True
+ - (install_params_info.stdout|from_json).install_args == "/install_arg 1 /install_arg 2"
+ - (install_params_info.stdout|from_json).override_args == True
+ - (install_params_info.stdout|from_json).package_params.keys()|count == 2
+ - (install_params_info.stdout|from_json).package_params.param1 == True
+ - (install_params_info.stdout|from_json).package_params.param2 == "value"
+ - (install_params_info.stdout|from_json).proxy_url == "http://proxyhost"
+ - (install_params_info.stdout|from_json).source == "normal"
+ - (install_params_info.stdout|from_json).timeout == "2700000"
+
+- name: reinstall package with manually specified params
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: reinstalled
+ choco_args:
+ - --install-args
+ - '/install_arg 1 /install_arg 2'
+ - --override-arguments
+ - --package-parameters
+ - '/param1 /param2:value'
+ - --allow-empty-checksums
+ - --x86
+ - --force
+ - --ignore-checksums
+ - --version
+ - '0.0.1'
+ - --proxy
+ - 'http://proxyhost'
+
+ register: install_manual_params
+
+- name: get result of install package with manually specified params
+ win_command: choco.exe list --local-only --limit-output --exact {{ test_choco_package1|quote }}
+ register: install_manual_params_actual
+
+- name: get info of install package with manually specified params
+ win_shell: Get-Content -Path '{{ test_choco_path }}\{{ test_choco_package1 }}-0.0.1.txt'
+ register: install_manual_params_info
+
+- name: assert install package with manually specified params
+ assert:
+ that:
+ - install_manual_params is changed
+ - install_manual_params_actual.stdout_lines == [test_choco_package1 + "|0.0.1"]
+ - (install_manual_params_info.stdout|from_json).allow_empty_checksums == True
+ - (install_manual_params_info.stdout|from_json).force == True
+ - (install_manual_params_info.stdout|from_json).force_x86 == True
+ - (install_manual_params_info.stdout|from_json).ignore_checksums == True
+ - (install_manual_params_info.stdout|from_json).install_args == "/install_arg 1 /install_arg 2"
+ - (install_manual_params_info.stdout|from_json).override_args == True
+ - (install_manual_params_info.stdout|from_json).package_params.keys()|count == 2
+ - (install_manual_params_info.stdout|from_json).package_params.param1 == True
+ - (install_manual_params_info.stdout|from_json).package_params.param2 == "value"
+ - (install_manual_params_info.stdout|from_json).proxy_url == "http://proxyhost"
+ - (install_manual_params_info.stdout|from_json).source == "normal"
+ - (install_manual_params_info.stdout|from_json).timeout == "2700000"
+
+- name: install package with version (idempotent)
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: present
+ version: 0.0.1
+ register: install_with_version
+
+- name: assert install package with version (idempotent)
+ assert:
+ that:
+ - not install_with_version is changed
+
+- name: fail to install side by side package
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: present
+ version: 0.1.0
+ register: fail_multiple_versions
+ failed_when: fail_multiple_versions.msg != "Chocolatey package '" + test_choco_package1 + "' is already installed with version(s) '0.0.1' but was expecting '0.1.0'. Either change the expected version, set state=latest or state=upgrade, set allow_multiple=yes, or set force=yes to continue"
+
+- name: force the upgrade of an existing version
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: present
+ version: 0.1.0
+ force: yes
+ register: force_different_version
+
+- name: get result of force the upgrade of an existing version
+ win_command: choco.exe list --local-only --limit-output --exact {{ test_choco_package1|quote }}
+ register: force_different_version_actual
+
+- name: get result of forced package install file
+ win_stat:
+ path: '{{ test_choco_path }}\{{ test_choco_package1 }}-0.1.0.txt'
+ register: force_different_version_info
+
+- name: assert force the upgrade of an existing version
+ assert:
+ that:
+ - force_different_version is changed
+ - force_different_version_actual.stdout_lines == [test_choco_package1 + "|0.1.0"]
+ - force_different_version_info.stat.exists
+
+- name: remove package after force clobbered everything
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: absent
+ ignore_errors: yes # the mock package created doesn't really handle force well
+
+- name: install package with reference to source name
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: present
+ source: ansible-test-override
+ register: install_source_name
+
+- name: get result of install package with reference to source name
+ win_command: choco.exe list --local-only --limit-output --exact {{ test_choco_package1|quote }}
+ register: install_source_name_actual
+
+- name: get result fo installed package with reference to source name info
+ win_shell: Get-Content -Path '{{ test_choco_path }}\{{ test_choco_package1 }}-0.1.0.txt' -Raw
+ register: install_source_name_info
+
+- name: assert install package with reference to source name
+ assert:
+ that:
+ - install_source_name is changed
+ - install_source_name_actual.stdout_lines == [test_choco_package1 + "|0.1.0"]
+ - (install_source_name_info.stdout|from_json).source == "override"
+
+- name: reinstall package without source override
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: reinstalled
+ register: reinstalled_package
+
+- name: get result of reinstalled package without source override
+ win_shell: Get-Content -Path '{{ test_choco_path }}\{{ test_choco_package1 }}-0.1.0.txt' -Raw
+ register: reinstalled_package_info
+
+- name: assert reinstall package without source override
+ assert:
+ that:
+ - reinstalled_package is changed
+ - (reinstalled_package_info.stdout|from_json).source == "normal"
+
+- name: downgrade package
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: downgrade
+ version: 0.0.1
+ register: downgraded_package
+
+- name: get result of downgrade package
+ win_command: choco.exe list --local-only --limit-output --exact {{ test_choco_package1|quote }}
+ register: downgraded_package_actual
+
+- name: assert downgrade package
+ assert:
+ that:
+ - downgraded_package is changed
+ - downgraded_package_actual.stdout_lines == [test_choco_package1 + "|0.0.1"]
+
+- name: downgrade package (idempotent)
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: downgrade
+ version: 0.0.1
+ register: downgraded_package_again
+
+- name: assert downgrade package (idempotent)
+ assert:
+ that:
+ - not downgraded_package_again is changed
+
+- name: downgrade package without version specified
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: downgrade
+ register: downgrade_without_version
+
+- name: get result of downgrade without version
+ win_command: choco.exe list --local-only --limit-output --exact {{ test_choco_package1|quote }}
+ register: downgrade_without_version_actual
+
+- name: assert downgrade package without version specified
+ assert:
+ that:
+ - not downgrade_without_version is changed
+ - downgrade_without_version_actual.stdout_lines == [test_choco_package1 + "|0.0.1"]
+
+- name: upgrade package
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: latest
+ register: upgrade_package
+
+- name: get result of upgrade package
+ win_command: choco.exe list --local-only --limit-output --exact {{ test_choco_package1|quote }}
+ register: upgrade_package_actual
+
+- name: assert upgrade package
+ assert:
+ that:
+ - upgrade_package is changed
+ - upgrade_package_actual.stdout_lines == [test_choco_package1 + "|0.1.0"]
+
+- name: downgrade package again
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: downgrade
+ version: '0.0.1'
+
+- name: upgrade package with state=upgrade
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: upgrade
+ register: upgrade_package_with_state_upgrade
+
+- name: get result of upgrade package with state=upgrade
+ win_command: choco.exe list --local-only --limit-output --exact {{ test_choco_package1|quote }}
+ register: actual_after_upgrade_with_state_upgrade
+
+- name: assert upgrade package with state=upgrade
+ assert:
+ that:
+ - upgrade_package_with_state_upgrade is changed
+ - actual_after_upgrade_with_state_upgrade.stdout_lines == [test_choco_package1 + "|0.1.0"]
+
+- name: upgrade package (idempotent)
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: latest
+ register: upgrade_package_again
+
+- name: assert upgrade package (idempotent)
+ assert:
+ that:
+ - not upgrade_package_again is changed
+
+- name: install prerelease package
+ win_chocolatey:
+ name: '{{ test_choco_package2 }}'
+ state: present
+ allow_prerelease: yes
+ register: install_prerelease
+
+- name: get result of install prerelease package
+ win_command: choco.exe list --local-only --limit-output --exact {{ test_choco_package2|quote }}
+ register: install_prerelease_actual
+
+- name: assert install prerelease package
+ assert:
+ that:
+ - install_prerelease is changed
+ - install_prerelease_actual.stdout_lines == [test_choco_package2 + "|1.0.1-beta1"]
+
+- name: downgrade package
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: downgrade
+ version: 0.0.1
+
+- name: upgrade all packages
+ win_chocolatey:
+ name: all
+ state: latest
+ register: all_latest
+
+- name: get result of upgrade all packages
+ win_command: choco.exe list --local-only --limit-output --exact {{ test_choco_package1|quote }}
+ register: all_latest_actual
+
+- name: assert upgrade all packages
+ assert:
+ that:
+ - all_latest is changed
+ - all_latest_actual.stdout_lines == [test_choco_package1 + "|0.1.0"]
+
+- name: install newer version of package
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: present
+
+- name: install older package with allow_multiple
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: present
+ allow_multiple: True
+ version: '0.0.1'
+ register: allow_multiple
+
+- name: get result of install older package with allow_multiple
+ win_command: choco.exe list --local-only --limit-output --all-versions
+ register: allow_multiple_actual
+
+- name: assert install older package with allow_multiple
+ assert:
+ that:
+ - allow_multiple is changed
+ - '"{{ test_choco_package1 }}|0.1.0" in allow_multiple_actual.stdout_lines'
+ - '"{{ test_choco_package1 }}|0.0.1" in allow_multiple_actual.stdout_lines'
+
+- name: pin 2 packages (check mode)
+ win_chocolatey:
+ name:
+ - '{{ test_choco_package1 }}'
+ - '{{ test_choco_package2 }}'
+ state: present
+ pinned: yes
+ register: pin_multiple_check
+ check_mode: True
+
+- name: get result of pin 2 packages (check mode)
+ win_command: choco.exe pin list --limit-output
+ register: pin_multiple_actual_check
+
+- name: assert pin 2 packages (check mode)
+ assert:
+ that:
+ - pin_multiple_check is changed
+ - pin_multiple_actual_check.stdout == ""
+
+- name: pin 2 packages
+ win_chocolatey:
+ name:
+ - '{{ test_choco_package1 }}'
+ - '{{ test_choco_package2 }}'
+ state: present
+ pinned: yes
+ register: pin_multiple
+
+- name: get result of pin 2 packages
+ win_command: choco.exe pin list --limit-output
+ register: pin_multiple_actual
+
+- name: assert pin 2 packages
+ assert:
+ that:
+ - pin_multiple is changed
+ - pin_multiple_actual.stdout_lines == ["ansible|0.1.0", "ansible-test|1.0.1-beta1"]
+
+- name: pin 2 packages (idempotent)
+ win_chocolatey:
+ name:
+ - '{{ test_choco_package1 }}'
+ - '{{ test_choco_package2 }}'
+ state: present
+ pinned: yes
+ register: pin_multiple_again
+
+- name: assert pin 2 packages (idempoent)
+ assert:
+ that:
+ - not pin_multiple_again is changed
+
+- name: pin specific older version
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: present
+ pinned: yes
+ version: '0.0.1'
+ register: pin_older
+
+- name: get result of pin specific older version
+ win_command: choco.exe pin list --limit-output
+ register: pin_older_actual
+
+- name: assert pin specific older version
+ assert:
+ that:
+ - pin_older is changed
+ - pin_older_actual.stdout_lines == ["ansible|0.1.0", "ansible|0.0.1", "ansible-test|1.0.1-beta1"]
+
+- name: unpin package at version
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: present
+ pinned: no
+ version: '0.1.0'
+ register: unpin_version
+
+- name: get result of unpin package at version
+ win_command: choco.exe pin list --limit-output
+ register: unpin_version_actual
+
+- name: assert unpin package at version
+ assert:
+ that:
+ - unpin_version is changed
+ - unpin_version_actual.stdout_lines == ["ansible|0.0.1", "ansible-test|1.0.1-beta1"]
+
+- name: unpin multiple packages without a version
+ win_chocolatey:
+ name:
+ - '{{ test_choco_package1 }}'
+ - '{{ test_choco_package2 }}'
+ state: present
+ pinned: no
+ register: unpin_multiple
+
+- name: get result of unpin multiple packages without a version
+ win_command: choco.exe pin list --limit-output
+ register: unpin_multiple_actual
+
+- name: assert unpin multiple packages without a version
+ assert:
+ that:
+ - unpin_multiple is changed
+ - unpin_multiple_actual.stdout == ""
+
+- name: uninstall specific version installed with allow_multiple
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: absent
+ version: '0.0.1'
+ register: remove_multiple
+
+- name: get result of uninstall specific version installed with allow_multiple
+ win_command: choco.exe list --local-only --limit-output --all-versions
+ register: remove_multiple_actual
+
+- name: assert uninstall specific version installed with allow_multiple
+ assert:
+ that:
+ - remove_multiple is changed
+ - '"{{ test_choco_package1 }}|0.0.1" not in remove_multiple_actual.stdout_lines'
+ - '"{{ test_choco_package1 }}|0.1.0" in remove_multiple_actual.stdout_lines'
+
+- name: attempt to uninstall a nonexistent version of an installed package
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: absent
+ version: '2.0.12'
+ register: remove_nonexistent_version
+
+- name: get result of uninstall a nonexistent version of an installed package
+ win_command: choco.exe list --local-only --limit-output --all-versions
+ register: remove_nonexistent_version_result
+
+- name: assert uninstall of nonexistent version of an installed package
+ assert:
+ that:
+ - not remove_nonexistent_version is changed
+ - '"{{ test_choco_package1 }}|0.1.0" in remove_nonexistent_version_result.stdout_lines'
+
+- name: remove existing Chocolatey installation
+ win_shell: Remove-Item -Path "C:/ProgramData/chocolatey" -Recurse -Force
+
+- name: install Chocolatey using the test bootstrap script
+ win_chocolatey:
+ name: chocolatey
+ state: present
+ bootstrap_script: "{{ test_choco_bootstrap_script }}"
+
+- name: checking if the bootstrap file has been created
+ win_shell: Get-Content -Path "C:/temp/confirm-bootstrap.txt" -Raw
+ register: bootstrap_file_check
+
+- name: assert bootstrap file has been created
+ assert:
+ that:
+ - (bootstrap_file_check.stdout|from_json).bootstrap
+
+- name: remove chocolatey package directory
+ win_file:
+ path: 'C:/ProgramData/chocolatey/lib/chocolatey'
+ state: absent
+
+- name: ensure we can still upgrade packages with chocolatey package files missing
+ win_chocolatey:
+ name: chocolatey
+ state: upgrade
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_config/aliases b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_config/aliases
new file mode 100644
index 00000000..4cd27b3c
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_config/aliases
@@ -0,0 +1 @@
+shippable/windows/group1
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_config/tasks/main.yml b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_config/tasks/main.yml
new file mode 100644
index 00000000..046ed78a
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_config/tasks/main.yml
@@ -0,0 +1,32 @@
+---
+- name: ensure Chocolatey is installed
+ win_chocolatey:
+ name: chocolatey
+ state: present
+
+- name: create a copy of the existing config file
+ win_copy:
+ src: C:\ProgramData\chocolatey\config\chocolatey.config
+ dest: C:\ProgramData\chocolatey\config\chocolatey.config.ansiblebak
+ remote_src: yes
+
+- name: unset config setting as baseline
+ win_chocolatey_config:
+ name: cacheLocation
+ state: absent
+
+- block:
+ - name: run tests
+ include_tasks: tests.yml
+
+ always:
+ - name: restore config file
+ win_copy:
+ src: C:\ProgramData\chocolatey\config\chocolatey.config.ansiblebak
+ dest: C:\ProgramData\chocolatey\config\chocolatey.config
+ remote_src: yes
+
+ - name: remove the backup config file
+ win_file:
+ path: C:\ProgramData\chocolatey\config\chocolatey.config.ansiblebak
+ state: absent
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_config/tasks/tests.yml b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_config/tasks/tests.yml
new file mode 100644
index 00000000..5633e505
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_config/tasks/tests.yml
@@ -0,0 +1,141 @@
+---
+- name: fail if value is not set and state=present
+ win_chocolatey_config:
+ name: cacheLocation
+ state: present
+ register: fail_no_value
+ failed_when: 'fail_no_value.msg != "state is present but all of the following are missing: value"'
+
+- name: fail to set invalid config name
+ win_chocolatey_config:
+ name: fake
+ state: present
+ value: value
+ register: fail_invalid_name
+ failed_when: '"The Chocolatey config ''fake'' is not an existing config value, check the spelling. Valid config names: " not in fail_invalid_name.msg'
+
+- name: set config setting (check mode)
+ win_chocolatey_config:
+ name: cacheLocation
+ state: present
+ value: C:\temp
+ check_mode: yes
+ register: set_check
+
+- name: get actual config setting (check mode)
+ win_command: choco.exe config get -r --name cacheLocation
+ register: set_actual_check
+
+- name: assert set config setting (check mode)
+ assert:
+ that:
+ - set_check is changed
+ - set_actual_check.stdout_lines == [""]
+
+- name: set config setting
+ win_chocolatey_config:
+ name: cacheLocation
+ state: present
+ value: C:\temp
+ register: set
+
+- name: get actual config setting
+ win_command: choco.exe config get -r --name cacheLocation
+ register: set_actual
+
+- name: assert set config setting
+ assert:
+ that:
+ - set is changed
+ - set_actual.stdout_lines == ["C:\\temp"]
+
+- name: change config value (check mode)
+ win_chocolatey_config:
+ name: cacheLocation
+ state: present
+ value: C:\temp2
+ check_mode: yes
+ register: change_check
+
+- name: get actual config setting (check mode)
+ win_command: choco.exe config get -r --name cacheLocation
+ register: change_actual_check
+
+- name: assert change config value (check mode)
+ assert:
+ that:
+ - change_check is changed
+ - change_actual_check.stdout_lines == ["C:\\temp"]
+
+- name: change config value
+ win_chocolatey_config:
+ name: cacheLocation
+ state: present
+ value: C:\temp2
+ register: change
+
+- name: get actual config setting
+ win_command: choco.exe config get -r --name cacheLocation
+ register: change_actual
+
+- name: assert change config value
+ assert:
+ that:
+ - change is changed
+ - change_actual.stdout_lines == ["C:\\temp2"]
+
+- name: change config value (idempotent)
+ win_chocolatey_config:
+ name: cacheLocation
+ state: present
+ value: C:\temp2
+ register: change_again
+
+- name: assert change config value (idempotent)
+ assert:
+ that:
+ - not change_again is changed
+
+- name: unset config value (check mode)
+ win_chocolatey_config:
+ name: cacheLocation
+ state: absent
+ check_mode: yes
+ register: unset_check
+
+- name: get actual config setting (check mode)
+ win_command: choco.exe config get -r --name cacheLocation
+ register: unset_actual_check
+
+- name: assert unset config value (check mode)
+ assert:
+ that:
+ - unset_check is changed
+ - unset_actual_check.stdout_lines == ["C:\\temp2"]
+
+- name: unset config value
+ win_chocolatey_config:
+ name: cacheLocation
+ state: absent
+ register: unset
+
+- name: get actual config setting
+ win_command: choco.exe config get -r --name cacheLocation
+ register: unset_actual
+
+- name: assert unset config value
+ assert:
+ that:
+ - unset is changed
+ - unset_actual.stdout_lines == [""]
+
+- name: unset config value (idempotent)
+ win_chocolatey_config:
+ name: cacheLocation
+ state: absent
+ register: unset_again
+
+- name: assert unset config value (idempotent)
+ assert:
+ that:
+ - not unset_again is changed
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_facts/aliases b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_facts/aliases
new file mode 100644
index 00000000..4c08975b
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_facts/aliases
@@ -0,0 +1 @@
+shippable/windows/group6
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_facts/meta/main.yml b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_facts/meta/main.yml
new file mode 100644
index 00000000..76ff5d34
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_facts/meta/main.yml
@@ -0,0 +1,4 @@
+---
+
+dependencies:
+ - setup_win_chocolatey
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_facts/tasks/main.yml b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_facts/tasks/main.yml
new file mode 100644
index 00000000..d242656e
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_facts/tasks/main.yml
@@ -0,0 +1,96 @@
+---
+
+- block:
+ # Everything needed for installing and updating packages has been set up by the setup_win_chocolatey target.
+ - name: win_chocolatey_fact outdated tests
+ include_tasks: test_outdated.yml
+
+ # Delete things installed by setup_win_chocolatey target
+ always:
+ - name: ensure test package is uninstalled after tests
+ win_chocolatey:
+ name: '{{ test_choco_packages }}'
+ state: absent
+
+ - name: remove test sources
+ win_chocolatey_source:
+ name: '{{ item }}'
+ state: absent
+ with_items:
+ - ansible-test
+ - ansible-test-override
+
+ - name: remove testing dir
+ win_file:
+ path: '{{ test_choco_path }}'
+ state: absent
+
+# Run other tests for win_chocolatey_facts
+- name: ensure Chocolatey is installed
+ win_chocolatey:
+ name: chocolatey
+ state: present
+
+- name: create test source
+ win_chocolatey_source:
+ name: test|repo # use a pipe as that's a delimiter with Chocolatey, test edge case
+ state: disabled
+ admin_only: yes
+ allow_self_service: yes
+ bypass_proxy: yes
+ priority: 9
+ source: http://test-server/chocolatey
+ source_username: test-user
+ source_password: password
+ certificate: C:\temp\cert.pfx
+
+- name: set a config value
+ win_chocolatey_config:
+ name: proxyUser
+ state: present
+ value: test-user
+
+- block:
+ - name: Gather facts from chocolatey
+ win_chocolatey_facts:
+
+ always:
+ - name: remove test source
+ win_chocolatey_source:
+ name: test|repo
+ state: absent
+
+ - name: unset config value
+ win_chocolatey_config:
+ name: proxyUser
+ state: absent
+
+- name: assert facts from chocolatey
+ assert:
+ that:
+ - ansible_chocolatey is not changed
+ - ansible_chocolatey.config.commandExecutionTimeoutSeconds == 2700
+ - ansible_chocolatey.config.proxyBypassOnLocal == True
+ - ansible_chocolatey.config.proxyUser == 'test-user'
+ - ansible_chocolatey.feature.checksumFiles == true
+ - ansible_chocolatey.packages[0].package == 'chocolatey'
+ - ansible_chocolatey.packages[0].version is defined
+ - ansible_chocolatey.outdated is defined
+ - ansible_chocolatey.sources[0].admin_only == False
+ - ansible_chocolatey.sources[0].allow_self_service == False
+ - ansible_chocolatey.sources[0].bypass_proxy == False
+ - ansible_chocolatey.sources[0].certificate == None
+ - ansible_chocolatey.sources[0].disabled == False
+ - ansible_chocolatey.sources[0].name == 'chocolatey'
+ - ansible_chocolatey.sources[0].priority == 0
+ - ansible_chocolatey.sources[0].source == 'https://community.chocolatey.org/api/v2/'
+ - ansible_chocolatey.sources[0].source_username == None
+ - ansible_chocolatey.sources[1].admin_only == True
+ - ansible_chocolatey.sources[1].allow_self_service == True
+ - ansible_chocolatey.sources[1].bypass_proxy == True
+ - ansible_chocolatey.sources[1].certificate == 'C:\\temp\\cert.pfx'
+ - ansible_chocolatey.sources[1].disabled == True
+ - ansible_chocolatey.sources[1].name == 'test|repo'
+ - ansible_chocolatey.sources[1].priority == 9
+ - ansible_chocolatey.sources[1].source == 'http://test-server/chocolatey'
+ - ansible_chocolatey.sources[1].source_username == 'test-user'
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_facts/tasks/test_outdated.yml b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_facts/tasks/test_outdated.yml
new file mode 100644
index 00000000..8383d0e8
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_facts/tasks/test_outdated.yml
@@ -0,0 +1,74 @@
+- name: "install old version of {{ test_choco_package1 }} package"
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: present
+ version: 0.0.1
+ force: yes
+
+- block:
+ - name: Gather facts from chocolatey
+ win_chocolatey_facts:
+
+ # Example output
+ # "outdated": [
+ # {
+ # "available_version": "0.1.0",
+ # "current_version": "0.0.1",
+ # "package": "ansible",
+ # "pinned": false
+ # },
+
+ # When using selectattr in Ansible 2.9 we need to convert to a list with '| list' to prevent the error below:
+ #'TASK [win_chocolatey : Debug selected_package] *****************************************************************************************************************************************************************************************
+ # ok: [win10] => {
+ # "selected_package": "<generator object select_or_reject at 0x7fda04eaeea0> "
+ # }
+ # See: https://www.0xf8.org/2021/03/filtering-with-ansibles-selectattr-rejectattr-when-the-tested-attribute-can-be-absent/
+ # This can be removed if we no longer support Ansible 2.9
+ - name: set_fact selected_package
+ set_fact:
+ selected_package: "{{ ansible_chocolatey.outdated | selectattr('package', 'eq', test_choco_package1) | list}} "
+
+ - name: Debug selected_package
+ debug:
+ var: selected_package
+
+ - name: assert 'chocolatey outdated' facts
+ assert:
+ that:
+ - ansible_chocolatey is not changed
+ - ansible_chocolatey.outdated is defined
+ - selected_package[0] is defined
+ - selected_package[1] is not defined
+ - selected_package[0].current_version == '0.0.1'
+ - selected_package[0].available_version == '0.1.0'
+ - selected_package[0].pinned == false
+
+- block:
+ - name: "Update {{ test_choco_package1 }} package"
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: latest
+
+ - name: Gather facts from chocolatey
+ win_chocolatey_facts:
+
+ - name: set_fact selected_package
+ set_fact:
+ selected_package: "{{ ansible_chocolatey.outdated | selectattr('package', 'eq', test_choco_package1) | list}} "
+
+ - name: Debug selected_package
+ debug:
+ var: selected_package
+
+ - name: assert 'chocolatey outdated' facts
+ assert:
+ that:
+ - ansible_chocolatey.outdated is defined
+ - selected_package[0] is not defined
+
+ always:
+ - name: "Clean up after 'chocolatey outdated' tests. Remove {{ test_choco_package1 }} package"
+ win_chocolatey:
+ name: '{{ test_choco_package1 }}'
+ state: absent
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_feature/aliases b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_feature/aliases
new file mode 100644
index 00000000..4cd27b3c
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_feature/aliases
@@ -0,0 +1 @@
+shippable/windows/group1
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_feature/filter_plugins/choco_checksum_state.py b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_feature/filter_plugins/choco_checksum_state.py
new file mode 100644
index 00000000..8dff044d
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_feature/filter_plugins/choco_checksum_state.py
@@ -0,0 +1,14 @@
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+
+def choco_checksum_state(value):
+ return [i for i in value if i.startswith("checksumFiles|")][0].split("|")[1] == "Enabled"
+
+
+class FilterModule(object):
+
+ def filters(self):
+ return {
+ 'choco_checksum_state': choco_checksum_state
+ }
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_feature/tasks/main.yml b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_feature/tasks/main.yml
new file mode 100644
index 00000000..c2100be0
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_feature/tasks/main.yml
@@ -0,0 +1,20 @@
+---
+- name: ensure Chocolatey is installed
+ win_chocolatey:
+ name: chocolatey
+ state: present
+
+- name: ensure we start from a baseline for test feature
+ win_chocolatey_feature:
+ name: checksumFiles
+ state: disabled
+
+- block:
+ - name: run tests
+ include_tasks: tests.yml
+
+ always:
+ - name: set feature back to enabled
+ win_chocolatey_feature:
+ name: checksumFiles
+ state: enabled
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_feature/tasks/tests.yml b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_feature/tasks/tests.yml
new file mode 100644
index 00000000..94bbb7a9
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_feature/tasks/tests.yml
@@ -0,0 +1,95 @@
+---
+- name: fail on invalid feature
+ win_chocolatey_feature:
+ name: failFeature
+ state: enabled
+ register: fail_res
+ failed_when: '"Invalid feature name ''failFeature'' specified, valid features are: " not in fail_res.msg'
+
+- name: enable disabled feature (check mode)
+ win_chocolatey_feature:
+ name: checksumFiles
+ state: enabled
+ check_mode: yes
+ register: enable_check
+
+- name: get actual state of feature (check mode)
+ win_command: choco.exe feature list -r
+ register: enable_actual_check
+
+- name: assert enable disabled feature (check mode)
+ assert:
+ that:
+ - enable_check is changed
+ - enable_actual_check.stdout_lines|choco_checksum_state == False
+
+- name: enable disabled feature
+ win_chocolatey_feature:
+ name: checksumFiles
+ state: enabled
+ register: enable
+
+- name: get actual state of feature
+ win_command: choco.exe feature list -r
+ register: enable_actual
+
+- name: assert enable disabled feature
+ assert:
+ that:
+ - enable is changed
+ - enable_actual.stdout_lines|choco_checksum_state == True
+
+- name: enable disabled feature (idempotent)
+ win_chocolatey_feature:
+ name: checksumFiles
+ state: enabled
+ register: enable_again
+
+- name: assert enable disabled feature (idempotent)
+ assert:
+ that:
+ - not enable_again is changed
+
+- name: disable enabled feature (check mode)
+ win_chocolatey_feature:
+ name: checksumFiles
+ state: disabled
+ check_mode: yes
+ register: disable_check
+
+- name: get actual state of feature (check mode)
+ win_command: choco.exe feature list -r
+ register: disable_actual_check
+
+- name: assert disable enabled feature (check mode)
+ assert:
+ that:
+ - disable_check is changed
+ - disable_actual_check.stdout_lines|choco_checksum_state == True
+
+- name: disable enabled feature
+ win_chocolatey_feature:
+ name: checksumFiles
+ state: disabled
+ register: disable
+
+- name: get actual state of feature
+ win_command: choco.exe feature list -r
+ register: disable_actual
+
+- name: assert disable enabled feature
+ assert:
+ that:
+ - disable is changed
+ - disable_actual.stdout_lines|choco_checksum_state == False
+
+- name: disable enabled feature (idempotent)
+ win_chocolatey_feature:
+ name: checksumFiles
+ state: disabled
+ register: disable_again
+
+- name: assert disable enabled feature (idempotent)
+ assert:
+ that:
+ - not disable_again is changed
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/aliases b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/aliases
new file mode 100644
index 00000000..4cd27b3c
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/aliases
@@ -0,0 +1 @@
+shippable/windows/group1
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/defaults/main.yml b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/defaults/main.yml
new file mode 100644
index 00000000..0d8c6782
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/defaults/main.yml
@@ -0,0 +1,3 @@
+---
+# use some weird chars to test out the parser
+test_chocolatey_name: test'|"source 123^
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/library/choco_source.ps1 b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/library/choco_source.ps1
new file mode 100644
index 00000000..5bb87647
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/library/choco_source.ps1
@@ -0,0 +1,66 @@
+#!powershell
+
+# Copyright: (c) 2019, Ansible Project
+# Copyright: (c) 2020, Chocolatey Software
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#Requires -Module Ansible.ModuleUtils.Legacy
+
+$result = @{
+ changed = $false
+ sources = [System.Collections.Generic.List`1[System.Collections.Hashtable]]@()
+}
+
+$choco_app = Get-Command -Name choco.exe -CommandType Application
+$choco_config_path = "$(Split-Path -LiteralPath (Split-Path -LiteralPath $choco_app.Path))\config\chocolatey.config"
+
+[xml]$choco_config = Get-Content -LiteralPath $choco_config_path
+foreach ($xml_source in $choco_config.chocolatey.sources.GetEnumerator()) {
+ $source_username = $xml_source.Attributes.GetNamedItem("user")
+ if ($null -ne $source_username) {
+ $source_username = $source_username.Value
+ }
+
+ # 0.9.9.9+
+ $priority = $xml_source.Attributes.GetNamedItem("priority")
+ if ($null -ne $priority) {
+ $priority = [int]$priority.Value
+ }
+
+ # 0.9.10+
+ $certificate = $xml_source.Attributes.GetNamedItem("certificate")
+ if ($null -ne $certificate) {
+ $certificate = $certificate.Value
+ }
+
+ # 0.10.4+
+ $bypass_proxy = $xml_source.Attributes.GetNamedItem("bypassProxy")
+ if ($null -ne $bypass_proxy) {
+ $bypass_proxy = [System.Convert]::ToBoolean($bypass_proxy.Value)
+ }
+ $allow_self_service = $xml_source.Attributes.GetNamedItem("selfService")
+ if ($null -ne $allow_self_service) {
+ $allow_self_service = [System.Convert]::ToBoolean($allow_self_service.Value)
+ }
+
+ # 0.10.8+
+ $admin_only = $xml_source.Attributes.GetNamedItem("adminOnly")
+ if ($null -ne $admin_only) {
+ $admin_only = [System.Convert]::ToBoolean($admin_only.Value)
+ }
+
+ $source_info = @{
+ name = $xml_source.id
+ source = $xml_source.value
+ disabled = [System.Convert]::ToBoolean($xml_source.disabled)
+ source_username = $source_username
+ priority = $priority
+ certificate = $certificate
+ bypass_proxy = $bypass_proxy
+ allow_self_service = $allow_self_service
+ admin_only = $admin_only
+ }
+ $result.sources.Add($source_info)
+}
+
+Exit-Json -obj $result
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/tasks/main.yml b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/tasks/main.yml
new file mode 100644
index 00000000..0aa9b317
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/tasks/main.yml
@@ -0,0 +1,31 @@
+---
+- name: ensure Chocolatey is installed
+ win_chocolatey:
+ name: chocolatey
+ state: present
+
+- name: remove original Chocolatey source at the start of the test
+ win_chocolatey_source:
+ name: chocolatey
+ state: absent
+
+- name: ensure test Chocolatey source is removed
+ win_chocolatey_source:
+ name: '{{ test_chocolatey_name }}'
+ state: absent
+
+- block:
+ - name: run tests
+ include_tasks: tests.yml
+
+ always:
+ - name: ensure original Chocolatey source is re-added
+ win_chocolatey_source:
+ name: chocolatey
+ source: https://community.chocolatey.org/api/v2/
+ state: present
+
+ - name: remove test Chocolatey source
+ win_chocolatey_source:
+ name: '{{ test_chocolatey_name }}'
+ state: absent
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/tasks/tests.yml b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/tasks/tests.yml
new file mode 100644
index 00000000..66b7bbc5
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/targets/win_chocolatey_source/tasks/tests.yml
@@ -0,0 +1,373 @@
+---
+- name: create source (check mode)
+ win_chocolatey_source:
+ name: chocolatey
+ source: https://community.chocolatey.org/api/v2/
+ state: present
+ register: create_check
+ check_mode: yes
+
+- name: check if source exists (check mode)
+ choco_source:
+ register: create_actual_check
+
+- name: assert create source (check mode)
+ assert:
+ that:
+ - create_check is changed
+ - create_actual_check.sources == []
+
+- name: create source
+ win_chocolatey_source:
+ name: chocolatey
+ source: https://community.chocolatey.org/api/v2/
+ state: present
+ register: create
+
+- name: check if source exists
+ choco_source:
+ register: create_actual
+
+- name: assert create source
+ assert:
+ that:
+ - create is changed
+ - create_actual.sources|length == 1
+ - create_actual.sources[0].name == 'chocolatey'
+ - create_actual.sources[0].source == 'https://community.chocolatey.org/api/v2/'
+ - create_actual.sources[0].disabled == False
+ - create_actual.sources[0].source_username == None
+ - create_actual.sources[0].priority == 0
+ - create_actual.sources[0].certificate == None
+ - create_actual.sources[0].bypass_proxy == False
+ - create_actual.sources[0].allow_self_service == False
+ - create_actual.sources[0].admin_only == False
+
+- name: create source (idempotent)
+ win_chocolatey_source:
+ name: chocolatey
+ source: https://community.chocolatey.org/api/v2/
+ state: present
+ register: create_again
+
+- name: assert create source (idempotent)
+ assert:
+ that:
+ - not create_again is changed
+
+- name: remove source (check mode)
+ win_chocolatey_source:
+ name: chocolatey
+ state: absent
+ register: remove_check
+ check_mode: yes
+
+- name: check if source is removed (check mode)
+ choco_source:
+ register: remove_actual_check
+
+- name: assert remove source (check mode)
+ assert:
+ that:
+ - remove_check is changed
+ - remove_actual_check.sources == create_actual.sources
+
+- name: remove source
+ win_chocolatey_source:
+ name: chocolatey
+ state: absent
+ register: remove
+
+- name: check if source is removed
+ choco_source:
+ register: remove_actual
+
+- name: assert remove source
+ assert:
+ that:
+ - remove is changed
+ - remove_actual.sources == []
+
+- name: remove source (idempotent)
+ win_chocolatey_source:
+ name: chocolatey
+ state: absent
+ register: remove_again
+
+- name: assert remove source (idempotent)
+ assert:
+ that:
+ - not remove_again is changed
+
+- name: create a disabled service (check mode)
+ win_chocolatey_source:
+ name: '{{ test_chocolatey_name }}'
+ source: C:\chocolatey repos
+ source_username: username
+ source_password: password
+ certificate: C:\cert.pfx
+ certificate_password: password
+ bypass_proxy: yes
+ priority: 1
+ state: disabled
+ register: create_special_check
+ check_mode: yes
+
+- name: check if source is created (check mode)
+ choco_source:
+ register: create_special_actual_check
+
+- name: assert create a disabled service (check mode)
+ assert:
+ that:
+ - create_special_check is changed
+ - create_special_actual_check.sources == []
+
+- name: create a disabled service
+ win_chocolatey_source:
+ name: '{{ test_chocolatey_name }}'
+ source: C:\chocolatey repos
+ source_username: username
+ source_password: password
+ certificate: C:\cert.pfx
+ certificate_password: password
+ bypass_proxy: yes
+ priority: 1
+ state: disabled
+ register: create_special
+
+- name: check if source is created
+ choco_source:
+ register: create_special_actual
+
+- name: assert create a disabled service
+ assert:
+ that:
+ - create_special is changed
+ - create_special_actual.sources|length == 1
+ - create_special_actual.sources[0].name == test_chocolatey_name
+ - create_special_actual.sources[0].source == 'C:\\chocolatey repos'
+ - create_special_actual.sources[0].disabled == True
+ - create_special_actual.sources[0].source_username == 'username'
+ - create_special_actual.sources[0].priority == 1
+ - create_special_actual.sources[0].certificate == 'C:\\cert.pfx'
+ - create_special_actual.sources[0].bypass_proxy == True
+ - create_special_actual.sources[0].allow_self_service == False
+ - create_special_actual.sources[0].admin_only == False
+
+- name: create a disabled service pass always update
+ win_chocolatey_source:
+ name: '{{ test_chocolatey_name }}'
+ source: C:\chocolatey repos
+ source_username: username
+ source_password: password
+ certificate: C:\cert.pfx
+ certificate_password: password
+ bypass_proxy: yes
+ priority: 1
+ state: disabled
+ register: create_special_pass_always
+
+- name: assert create a disabled service pass always update
+ assert:
+ that:
+ - create_special_pass_always is changed
+
+- name: create a disabled service (idempotent)
+ win_chocolatey_source:
+ name: '{{ test_chocolatey_name }}'
+ source: C:\chocolatey repos
+ source_username: username
+ source_password: password
+ certificate: C:\cert.pfx
+ certificate_password: password
+ bypass_proxy: yes
+ priority: 1
+ state: disabled
+ update_password: on_create
+ register: create_special_again
+
+- name: assert create a disabled service (idempotent)
+ assert:
+ that:
+ - not create_special_again is changed
+
+- name: edit an existing source (check mode)
+ win_chocolatey_source:
+ name: '{{ test_chocolatey_name }}'
+ source: C:\chocolatey repos2
+ source_username: username2
+ source_password: password2
+ certificate: C:\cert2.pfx
+ priority: '5'
+ state: present
+ update_password: on_create
+ admin_only: yes
+ allow_self_service: yes
+ register: modify_source_check
+ check_mode: yes
+
+- name: check if source is changed (check mode)
+ choco_source:
+ register: modify_source_check_actual
+
+- name: assert edit an existing source (check mode)
+ assert:
+ that:
+ - modify_source_check is changed
+ - modify_source_check_actual.sources == create_special_actual.sources
+
+- name: edit an existing source
+ win_chocolatey_source:
+ name: '{{ test_chocolatey_name }}'
+ source: C:\chocolatey repos2
+ source_username: username2
+ source_password: password2
+ certificate: C:\cert2.pfx
+ priority: '5'
+ state: present
+ update_password: on_create
+ admin_only: yes
+ allow_self_service: yes
+ register: modify_source
+
+- name: check if source is changed
+ choco_source:
+ register: modify_source_actual
+
+- name: assert edit an existing source
+ assert:
+ that:
+ - modify_source is changed
+ - modify_source_actual.sources[0].name == test_chocolatey_name
+ - modify_source_actual.sources[0].source == 'C:\\chocolatey repos2'
+ - modify_source_actual.sources[0].disabled == False
+ - modify_source_actual.sources[0].source_username == 'username2'
+ - modify_source_actual.sources[0].priority == 5
+ - modify_source_actual.sources[0].certificate == 'C:\\cert2.pfx'
+ - modify_source_actual.sources[0].bypass_proxy == False
+ - modify_source_actual.sources[0].allow_self_service == True
+ - modify_source_actual.sources[0].admin_only == True
+
+- name: edit an existing source (idempotent)
+ win_chocolatey_source:
+ name: '{{ test_chocolatey_name }}'
+ source: C:\chocolatey repos2
+ source_username: username2
+ source_password: password2
+ certificate: C:\cert2.pfx
+ priority: '5'
+ state: present
+ update_password: on_create
+ admin_only: yes
+ allow_self_service: yes
+ register: modify_source_again
+
+- name: assert edit an existing source (idempotent)
+ assert:
+ that:
+ - not modify_source_again is changed
+
+- name: disable source (check mode)
+ win_chocolatey_source:
+ name: '{{ test_chocolatey_name }}'
+ state: disabled
+ register: disable_source_check
+ check_mode: True
+
+- name: get result of disable source (check mode)
+ choco_source:
+ register: disable_source_actual_check
+
+- name: assert disable source (check mode)
+ assert:
+ that:
+ - disable_source_check is changed
+ - disable_source_actual_check.sources == modify_source_actual.sources
+
+- name: disable source
+ win_chocolatey_source:
+ name: '{{ test_chocolatey_name }}'
+ state: disabled
+ register: disable_source
+
+- name: get result of disable source
+ choco_source:
+ register: disable_source_actual
+
+- name: assert disable source
+ assert:
+ that:
+ - disable_source is changed
+ - disable_source_actual.sources[0].name == test_chocolatey_name
+ - disable_source_actual.sources[0].source == 'C:\\chocolatey repos2'
+ - disable_source_actual.sources[0].disabled == True
+ - disable_source_actual.sources[0].source_username == 'username2'
+ - disable_source_actual.sources[0].priority == 5
+ - disable_source_actual.sources[0].certificate == 'C:\\cert2.pfx'
+ - disable_source_actual.sources[0].bypass_proxy == False
+ - disable_source_actual.sources[0].allow_self_service == True
+ - disable_source_actual.sources[0].admin_only == True
+
+- name: disable source (idempotent)
+ win_chocolatey_source:
+ name: '{{ test_chocolatey_name }}'
+ state: disabled
+ register: disable_source_again
+
+- name: assert disable source (idempotent)
+ assert:
+ that:
+ - not disable_source_again is changed
+
+- name: enable source (check mode)
+ win_chocolatey_source:
+ name: '{{ test_chocolatey_name }}'
+ state: present
+ register: enable_source_check
+ check_mode: True
+
+- name: get result of enable source (check mode)
+ choco_source:
+ register: enable_source_actual_check
+
+- name: assert enable source (check mode)
+ assert:
+ that:
+ - enable_source_check is changed
+ - enable_source_actual_check.sources == disable_source_actual.sources
+
+- name: enable source
+ win_chocolatey_source:
+ name: '{{ test_chocolatey_name }}'
+ state: present
+ register: enable_source
+
+- name: get result of enable source
+ choco_source:
+ register: enable_source_actual
+
+- name: assert enable source
+ assert:
+ that:
+ - enable_source is changed
+ - enable_source_actual.sources[0].name == test_chocolatey_name
+ - enable_source_actual.sources[0].source == 'C:\\chocolatey repos2'
+ - enable_source_actual.sources[0].disabled == False
+ - enable_source_actual.sources[0].source_username == 'username2'
+ - enable_source_actual.sources[0].priority == 5
+ - enable_source_actual.sources[0].certificate == 'C:\\cert2.pfx'
+ - enable_source_actual.sources[0].bypass_proxy == False
+ - enable_source_actual.sources[0].allow_self_service == True
+ - enable_source_actual.sources[0].admin_only == True
+
+- name: enable source (idempotent)
+ win_chocolatey_source:
+ name: '{{ test_chocolatey_name }}'
+ state: present
+ register: enable_source_again
+
+- name: assert enable source (idempotent)
+ assert:
+ that:
+ - not enable_source_again is changed
diff --git a/ansible_collections/chocolatey/chocolatey/tests/integration/vagrant-inventory.winrm b/ansible_collections/chocolatey/chocolatey/tests/integration/vagrant-inventory.winrm
new file mode 100644
index 00000000..ce7bfd36
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/integration/vagrant-inventory.winrm
@@ -0,0 +1,11 @@
+[windows]
+win10 ansible_host=10.0.0.11
+
+[windows:vars]
+ansible_user=vagrant
+ansible_password=vagrant
+ansible_connection=winrm
+ansible_port=5985
+ansible_winrm_transport=credssp
+ansible_winrm_server_cert_validation=ignore
+ansible_become_method=runas
diff --git a/ansible_collections/chocolatey/chocolatey/tests/requirements.txt b/ansible_collections/chocolatey/chocolatey/tests/requirements.txt
new file mode 100644
index 00000000..0cebf83c
--- /dev/null
+++ b/ansible_collections/chocolatey/chocolatey/tests/requirements.txt
@@ -0,0 +1,2 @@
+ansible.windows
+Jinja2<3.1.0