From 5322f83dfb4385e2fe9d9db1a47220daf3e99cd5 Mon Sep 17 00:00:00 2001 From: L3D Date: Thu, 18 Jan 2024 17:03:06 +0100 Subject: [PATCH] Install chocolatey --- tasks/main.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tasks/main.yml diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..51c4a90 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,19 @@ +--- +- name: 'Install chocolatey' + block: + - name: try to install using ansible + chocolatey.chocolatey.win_chocolatey: + name: chocolatey + state: present + register: _choco + until: _choco is succeeded + retries: 4 + delay: 2 + rescue: + - name: Install choco using powershell + ansible.windows.win_powershell: + script: | + rm -rf C:\ProgramData\chocolatey; + Set-ExecutionPolicy Bypass -Scope Process -Force; + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; + iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))