Ansible/yml/Windows-Install-Chocloatey.yml
2023-07-03 20:39:45 +02:00

26 lines
739 B
YAML

- name: Install Chocolatey
win_shell: |
Set-ExecutionPolicy Bypass;
Invoke-Expression (
(New-Object System.Net.WebClient).DownloadString(
'https://chocolatey.org/install.ps1'
)
)
args:
creates: 'C:\ProgramData\chocolatey'
when: ansible_os_family == 'Windows'
- name: Check Path Variable on Windows hosts
win_shell: $Env:Path
register: path
changed_when: False
when: ansible_os_family == 'Windows'
- name: Add Choco Path to Path Variable on Windows hosts
win_environment:
state: present
name: Path
value: '{{ path.stdout }};C:\ProgramData\chocolatey\bin'
level: machine
when: (path.stdout.find('chocolatey') == -1 ) and
(ansible_os_family == 'Windows')