On a sidenote. Actually I have used powershell on linux. I managed to get it working over ssh, and Refactored the helper functions for powershell task development.
https://www.powershellgallery.com/packages/PSAnsibleHelperFunctions4Linux/0.0.1 I also wrote a proof of concept collection to do ms sql managememt through the local execution environment. https://github.com/weiyentan/community.dbatools Though I really only see the use case for powershell as "controller type of acttivity" where the controller is reaching out. Ie. Managing a sql database. Or application. There is room to customise and with the advent of execution environments it allows for this. I have an execution environment that has pwsh installed so I can do all of this. This was an older execution environment. A newer one exists. https://github.com/weiyentan/awx-ee_containers/blob/master/execution_environments/powershell_standard_dbatools/execution-environment.yml Managing linux servers, there is already tasks to do most things anyway to bother going through the effort of converting things to powershell imho. That's another discussion. Sent from Outlook for iOS<https://aka.ms/o0ukef> ________________________________ From: 'Rowe, Walter P. (Fed)' via Ansible Project <[email protected]> Sent: Thursday, March 16, 2023 12:50 AM To: [email protected] <[email protected]> Subject: Re: [ansible-project] Ansible Powershell Usage If you are truly managing Windows resources look at win_dsc. https://docs.ansible.com/ansible/latest/os_guide/windows_dsc.html Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Mar 14, 2023, at 3:59 PM, Shawn Singh <[email protected]> wrote: Also, I noticed this discussion: Ansible powershell module to be run on remote powershell on Linux machine. (https://groups.google.com/g/ansible-project/c/YZzYNEevzro) Where Matt suggests: That it [the module] is meant to be used with a Windows machine / over WinRM: Matt Davis unread, Oct 21, 2016, 1:24:06 PM to Ansible Project Some aspects of Ansible's Powershell support are currently built under the assumption that it would only ever run on Windows / over WinRM. There are a few things that would need to be moved around in order to allow "real" Ansible Powershell modules to work on Linux. By "real", I mean so that the module generation stuff works correctly whether the WinRM connection plugin runs it or something else, and that you can use our Powershell module API. So maybe that's my issue... ie not meant to run against Azure... On Tuesday, March 14, 2023 at 3:28:04 PM UTC-4 Shawn Singh wrote: I'm trying to use Powershell from Ansible. This is the code: - name: Log into Azure ansible.windows.win_powershell: script: | [CmdletBinding()] param ( [String] $TenantID, [String] $AccountID, [SecureString] $Secret ) Connect-AzAccount -ServicePrincipal -TenantId $TenantID -Credential $(New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $AccountID, $Secret) parameters: TenantID: "{{ tenant }}" AccountID: "{{ sp }}" Secret: "{{ secret }}" The Connect-AzAccount command works, when executed from my machine (running OS X) under pwsh; however, it blows up pretty ugly when executed using ansible-playbook... fatal: [localhost]: FAILED! => { "changed": false, "module_stderr": "\u001b[31;1mParserError: \u001b[0m/Users/j8683/.ansible/tmp/ansible-tmp-1678819559.972683-82400-269117048488035/AnsiballZ_win_powershell.ps1:159\u001b[0m\n\u001b[31;1m\u001b[0m\u001b[36;1mLine |\u001b[0m\n\u001b[31;1m\u001b[0m\u001b[36;1m\u001b[36;1m 159 | \u001b[0m \u001b[36;1m\u0000\u001b[0m\u0000\u0000\u0000{\"module_entry\": \"IyFwb3dlcnNoZWxsCgojIENvcHlyaWdodDogKGMpIDIwMjE …\u001b[0m\n\u001b[31;1m\u001b[0m\u001b[36;1m\u001b[36;1m\u001b[0m\u001b[36;1m\u001b[0m\u001b[36;1m | \u001b[31;1m ~\u001b[0m\n\u001b[31;1m\u001b[0m\u001b[36;1m\u001b[36;1m\u001b[0m\u001b[36;1m\u001b[0m\u001b[36;1m\u001b[31;1m\u001b[31;1m\u001b[36;1m | \u001b[31;1munexpected token '\u0000', expected 'begin', 'process', 'end', 'clean', or\u001b[0m\n\u001b[31;1m\u001b[0m\u001b[36;1m\u001b[36;1m\u001b[0m\u001b[36;1m\u001b[0m\u001b[36;1m\u001b[31;1m\u001b[31;1m\u001b[36;1m\u001b[31;1m\u001b[36;1m | \u001b[31;1m'dynamicparam'.\u001b[0m\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1 } Any ideas on what the win_powershell module might not like? This is the ansible version I'm using: ansible [core 2.14.0] python version = 3.9.6 (default, Sep 26 2022, 11:37:49) [Clang 14.0.0 (clang-1400.0.29.202)] (/Library/Developer/CommandLineTools/usr/bin/python3) jinja version = 3.1.2 Thanks, Shawn -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]<mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f3a8ab7d-ca56-44dd-a783-f54d5b816246n%40googlegroups.com<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2Ff3a8ab7d-ca56-44dd-a783-f54d5b816246n%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C7fed5500a3aa42d3fb7408db24c6a74b%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638144207857135322%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=MUkDIr2N85nvYa%2Fs9MYcsMSzngHAOLY3ISixRJLDsZE%3D&reserved=0>. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]<mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/C0FC9ADA-AEBA-4D3E-8838-7B3A3258842C%40nist.gov<https://groups.google.com/d/msgid/ansible-project/C0FC9ADA-AEBA-4D3E-8838-7B3A3258842C%40nist.gov?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/SYBP282MB3525F50F498E083B2413C357ADBF9%40SYBP282MB3525.AUSP282.PROD.OUTLOOK.COM.
