Chocolatey role

The next role uses Chocolatey to install a few bits of software on the machine.

Chocolatey is a package manager for Windows, similar in principle and functionality to Homebrew, which we used in earlier chapters to install the software we needed on macOS with a single command. Chocolatey simplifies the installation of packages on the command line by wrapping the installation process for most common Windows installers into a common set of PowerShell commands—perfect for an orchestration tool such as Ansible.

To add the files needed for the role, run the following command:

$ ansible-galaxy init roles/choc

In roles/choc/defaults/main.yml, we have a list of the packages we want to install:

apps:
- "notepadplusplus.install"
- "putty.install"
- "googlechrome"

As you can see, we want to install Notepad++, PuTTY, and Google Chrome. The task itself, which needs to be added to roles/choc/tasks/main.yml, looks like the following:

- name: install software using chocolatey
win_chocolatey:
name: "{{ item }}"
state: "present"
with_items: "{{ apps }}"

Again, the win_chocolatey module takes a similar input to the package manager modules we have used in previous chapters when targeting a Linux-based host.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.190.93