Speed up ansible for windows with PSRP

Introduction

In our environment we used to use winrm. It just caught my attention (about a year too late) that from Ansible 2.7 you can use PSRP (PowerShell Remote Protocol) to execute your playbooks.

Featured image

$ cat inventories/com/group_vars/windows/windows.yml  | grep ansible_connection
ansible_connection: winrm

Run the playbook with winrm:

$time ansible-playbook -i inventories/com/inventory playbooks/domain_controller/com/02_ad-tree.yml
...
real	1m54.500s
user	0m5.781s
sys	0m0.605s

Install pysrp:

pip install pypsrp

Run the same playbook again:

$time ansible-playbook -i inventories/com/inventory playbooks/domain_controller/com/02_ad-tree.yml --extra-vars="ansible_connection=psrp cert_validation=ignore ansible_port=5985"
...
real	1m8.176s
user	0m4.071s
sys	0m0.317s

References