Files
gitlab-mirror/roles/win_chocolatey_install/tasks/main.yml
2026-04-09 12:10:55 +03:00

35 lines
1014 B
YAML

---
- name: Check chocolatey existance
block:
- name: Get chocolatey status
ansible.windows.win_stat:
path: C:\ProgramData\chocolatey\bin\choco.exe
register: win_chocolatey_install_status
- name: Assert that choco binary exists
ansible.builtin.assert:
that: win_chocolatey_install_status.stat.exists
success_msg: Chocolatey IS installed
fail_msg: Chocolatey IS NOT installed
rescue:
- name: Create temp folder
ansible.windows.win_file:
path: C:\tmp
state: directory
- name: Download Chocolatey install script
ansible.windows.win_get_url:
url: https://community.chocolatey.org/install.ps1
dest: C:\tmp\install_choco.ps1
- name: Run Chocolatey install script
ansible.windows.win_shell: |
Set-ExecutionPolicy Bypass -Scope Process -Force
C:\tmp\install_choco.ps1
- name: Delete tmp directory
ansible.windows.win_file:
path: C:\tmp
state: absent