Ansible installing package using Chocolatey in windows

Chocolatey is a package manager for Windows, it makes automating software installation, configuration, and uninstallation easier by wrapping the underlying installation technologies in an easy-to-use command-line syntax.

Using with Ansible

Ansible has the module win_chocolatey that will install chocolatey packages from Ansible playbooks. If on the first run through Ansible detects that chocolatey is not installed, it will install chocolatey as part of the task.

ansible-playbook for installing git on our windows target machine.

# cat windowschoco.yml

---

- hosts: all

gather_facts: no

tasks:

- name: Install git

win_chocolatey:

name: git

state: present


Let's run the playbook,

# ansible-playbook -i hosts windowschoco.yaml

PLAY [all] **************************************************************************************************************************************************


TASK [Install git] ******************************************************************************************************************************************

changed: [192.168.1.2]


PLAY RECAP **************************************************************************************************************************************************

192.168.1.2 : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0


Github repo for:https://github.com/zippyopstraining/winansible/blob/main/windowschoco.yml


Recent Comments

No comments

Leave a Comment