PowerShell 7 is a versatile shell and programming language.

Unlike many other configuration systems, it does not require an agent on the target system.

This makes it easy to use and set up.

Most package systems for Linux distributions have this built-in.

This is a virtualized instance of Linux that runs in parallel with Windows.

Notably, we need a hosts file to define our target locations.

A simple hosts file that creates a group of hosts under the

tag is outlined below.

Comments are useful to tell you what the actual hostname of the systems is.

You are able to create multiple groups of hosts and the same host can exist in multiple groups.

This makes grouping and “tagging” those hosts easier for managing them later on for more complex roles.

To do this let’s first create a new folder under theplaybooksfolder to contain our playbook.

In this case, we are going to call itdeploy-powershell.

Under that folder, we will create the following file,main.yml.

Themain.ymlfile is our primary entry point for the playbook.

It doesn’t necessarily have to be namedmain.ymlbut it is common convention.

Extending our Playbook for Other Hosts

Right now our playbook only handles Ubuntu Linux systems.

To update this, we can use Ansible conditionals to make this a bit more robust.

Let’s expand this to support Redhat Linux and Fedora systems.

To allow support for other package installation systems, we use thewhenconditional clause.

By reading theansible_distributionvalue, we can tell Ansible to only target certain distributions for specific commands.

To do this, we will execute the following command line.

Additionally, the conditionalwhenwill show as a skip within the results.

Conclusion

Ansible makes it easy to install PowerShell on multiple systems at once.