Ansible, Windows and PowerShell: the Basics - Part 2, Install PowerShell Modules
In Part 2 of this series we’ll move on from the introductory topics and look at how we can use Ansible to prepare servers with any external PowerShell Modules they need from the PowerShell Gallery.
Our job template in AWX is _1_install-psmodule
The contents of _1_install-psmodule.yml are are follows:
We can use the native Ansible module win_psmodule to do the work for us. In addition, we can ensure multiple modules are installed without needing a separate task for each one by looping using with_items. This enables us to simply supply the names of the modules for the PowerShell Gallery that we need and Ansible will install both of them.
Looking at our vanilla Windows 2016 server, we can observe that prior to running the job template neither the PowervRA or PowervRO modules are installed.
Running a job from the _1_install-psmodule job template produces a successful result:
Checking our vanilla Windows 2016 server, we can now observe that both the PowervRA or PowervRO modules are installed and available for further automation.
- Ansible, Windows and PowerShell: the Basics – Introduction
- Ansible, Windows and PowerShell: the Basics - Part 1, Windows Services
- Ansible, Windows and PowerShell: the Basics - Part 2, Install PowerShell Modules
- Ansible, Windows and PowerShell: the Basics – Part 3, Windows Roles and Features
- Ansible, Windows and PowerShell: the Basics – Part 4, Invoking PowerShell Code
- Ansible, Windows and PowerShell: the Basics – Part 5, Example PowerShell Error Handling
- Ansible, Windows and PowerShell: the Basics – Part 6, Displaying Output from PowerShell Code
- Ansible, Windows and PowerShell: the Basics – Part 7, Utilising PowerShell DSC
- Ansible, Windows and PowerShell: the Basics – Part 8, Rebooting & Waiting
- Ansible, Windows and PowerShell: the Basics – Part 9, Disk Creation
- Ansible, Windows and PowerShell: the Basics – Part 10, Local Users
- Ansible, Windows and PowerShell: the Basics – Part 11, Local Groups
- Ansible, Windows and PowerShell: the Basics – Part 12, Set TimeZone
- Ansible, Windows and PowerShell: the Basics – Part 13, Environment Variables
- Ansible, Windows and PowerShell: the Basics – Part 14, Registry Entries
- Ansible, Windows and PowerShell: the Basics – Part 15, Install Chocolatey Packages