add win_chocolatey role
This commit is contained in:
34
roles/win_chocolatey_install/tasks/main.yml
Normal file
34
roles/win_chocolatey_install/tasks/main.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
- 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
|
||||
Reference in New Issue
Block a user