We have several existing Powershell scripts that we wanted to adapt to use with Ansible. Mostly dealing with VMware and so they don’t specifically need a Windows OS.
We didn’t want to just use the win_powershell command since it is tricky to securely pass secrets into the scripts, so we adapted several of the scripts into full Ansible modules as Powershell files so we could no_log the passwords. But this requires us to still run this on a Windows host due to the
#!powershell at the top of the file.
We would rather install Powershell 7 inside of our Execution Environment along with the powershell modules and still use a .ps1 based Ansible module to run completely inside of the Linux based EE to eliminate the delegate host to send it to Windows.
Is there a standard way to do this at this time? When we last looked a year or so ago there wasn’t a supported way. We found one third party repo that had a modified file to start to allow this, but not much movement on that front.
From this link:
I saw “Ansible modules can be written in any language that can return JSON, such as Ruby, Python, or bash.” but that doesn’t appear to include Powershell even if Powershell is available on the Linux box that is running Ansible, but I’m hoping I’ve missed something.