Ansible and Windows
How PowerShell enables a Linux configuration manager to work in a Windows world
Paul Broadwith
|
Paul Broadwith
Technical Engineering Manager at Chocolatey Software, Inc.
- Glasgow, Scotland
- 30 years in IT in many different sectors
|
|
|
|
|
Agenda
- The TL;DR History of Ansible.
- Ansible infrastructure.
- How Ansible works on Windows …. is it maybe … PowerShell?
- DEMO: Writing an Ansible Windows module.
- Questions?
The TL;DR History of Ansible
%%{init: {'theme': 'default', 'themeVariables': { 'fontSize': '25px'}} }%%
flowchart LR
collections(("Ansible Galaxy
Roles
Plugins
Modules
Collections")) -.-> config
subgraph sgcomponents ["Ansible Control Node running on Linux"]
components>Playbooks
Modules
Plugins
Roles
] -.-> config{"Ansible Config"}
inventory>Inventory
Local, Cloud or CMDB] -.-> config
end
sgcomponents -- SSH ----> linuxclients["Linux Hosts
(agentless)"]
sgcomponents -- WinRM / OpenSSH ----> winclients["Windows Hosts
(agentless)"]
sgcomponents -- SSH / API ----> networking["Networking
(agentless)"]
sgcomponents -- API ----> cloud["Cloud Services"]
classDef green fill:#9f6,stroke:#333,stroke-width:2px;
classDef orange fill:#f96,stroke:#333,stroke-width:4px;
classDef blue fill:#9cbacc,stroke:#333,stroke-width:2px
class dis blue
How Does Ansible Work on Windows?
Ansible has the following minimum requirements for Windows hosts:
- Windows Server 2012 / Windows 8.1
- PowerShell 3.0
- .NET 4.0
- WinRM configured and listening
Options to run Ansible Control node on Windows:
- Windows Subsystem for Linux
- Linux Virtual Machine
- Docker container
- Cygwin (not officially supported)
Whatever you use, Python 3.8 and the pywinrm
module is required.
Writing Your First Windows Ansible Module
- Code is in the PowerShell script, documentation in the Python script
- Don’t use Write-Host / Debug / Verbose / Error
- Exceptions / Errors can be returned back to Ansible
- Can specify minimum PowerShell or OS requirements
- Modules are run under StrictMode version 2
Summary
- We know the TL;DR history of Ansible.
- We understand Ansible infrastructure.
- We know how Ansible works on Windows and how it does not run as a control node on Windows.
- We know how Windows Ansible modules are structured.
|
blog.pauby.com
|
Paul Broadwith
|
|
@pauby
|
|
github.com/pauby
|
|
pau.by/linkedin
|
pau.by/talks