-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
win_powershell: script: filename.ps1 #245
Comments
This can be done today by using the file lookup - ansible.windows.win_powershell:
script: '{{ lookup("file", "foobar.ps1") }}'
executable: pwsh.exe
arguments:
- -ExecutionPolicy
- ByPass Except for
|
Hmmm..... as long as relative pathing works within a role, that might work just fine. I haven't actually used the file lookup plugin with relative ansible paths like this before, so hadn't occurred to me to try that. Thank you. |
Relative pathing definitely works, it's the same as if you did something like |
* Initial commit * Fix tests - ci_complete ci_coverage * removing chocolatey as they have moved to chocolatey.chocolatey (#65) * removing chocolatey as they have moved to chocolatey.chocolatey * more chocolatey removals * fix sanity error * fixing one last time I hope * Fix up docs after migration (#95) * Fix up docs after migration * Fix up sanity errors * fix up sanity ignores (#97) * fix up sanity ignores * Bump ansible-windows dep * Fix bad change for win_region * Rebalance the test targets (#128) * Rebalance the test targets * Make sure IIS test removes the service so our httptester works * Fix new santiy check and stabilise external downloads (#171) * Mark win_hotfix as unstable (#245) * Fix devel sanity checks - ci_complete (#331) * Update win_hotfix.ps1 (#386) * Update win_hotfix.ps1 * Fix up docs and return values Co-authored-by: Jordan Borean <jborean93@gmail.com> --------- Co-authored-by: Jordan Borean <jborean93@gmail.com> Co-authored-by: Jake Jackson <jljacks93@gmail.com> Co-authored-by: fsteve800 <91268425+fsteve800@users.noreply.github.com>
SUMMARY
I would like to pass a file on the ansible control node to win_powershell's script: parameter.
ISSUE TYPE
COMPONENT NAME
win_powershell
ADDITIONAL INFORMATION
With the ansible.builtin.script module, we can provide a script file to execute on a target and specify the executable and additional arguments to use. Making a script Idempotent, and telling Ansible if changes occured or not, can be difficult though.
With ansible.windows.win_powershell, one of the new features you introduced was the $Ansible object that we can set the changed and failed statuses on, however, you cannot pass a file to the script parameter of win_powershell like you can with the builtin script module. I find it very difficult to read powershell in a yaml syntax/highlighted file in vscode, and having to transpose powershell code from a ps1 file into yaml can be very tedious if you need to troubleshoot.
Right now, win_powershell is pretty great for small code executions and easy enough to work with, but it would definitely be much nicer to work with if ps1 files could be passed to the module instead of raw yaml code (this would especially lend itself well to roles and collections)
The text was updated successfully, but these errors were encountered: