-
Notifications
You must be signed in to change notification settings - Fork 23.8k
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
ConfigureRemotingForAnsible.ps1 and upgrade_to_ps3.ps1 chicken/egg problem #10509
Comments
The comments in upgrade_to_ps3.ps1 were there before the ConfigureRemotingForAnsible.ps1 script even existed, and the steps to configure remoting were only described in the documentation at that time. It may make sense to remove those comments to avoid confusion. What is your target OS? |
I'm targeting windows 7 (which comes with powershell 2) and higher. I'm not super familiar with powershell -- I see that ConfigureRemotingForAnsible.ps1 explicitly checks for greater-than or equal to version 3 -- is there anything in that script which actually depends on such a shell version? It would be be nice to deploy powershell >=3 via ansible if it were possible as the upgrade process for powershell requires upgrading to compatible dotnet which requires a reboot. Its easier and cleaner to orchestrate automation like that with ansible than without ... I'm currently using a script which creates a scheduled task that runs ONSTART to get hosts from clean windows install up to powershell 4 without intervention, then calls ConfigureRemotingForAnsible. Not the cleanest thing but I'll go with it if there's no other way ... |
@breathe One reason we didn't use configure....ps1 to optionally install the required powershell version, is that changing the WMF version (Powershell is part of WMF) requires a reboot. I didn't have to go down the path of having to create a script that would persist between reboots since this is meant to be a quick and easy config-script. I have not tested the configure..ps1 script on PowerShell 2.0, there's a good chance it will work (maybe a little bit of tweaking is required). |
@breathe Not really a chicken-and-egg problem, because you can use the script, raw or win_psexec modules to run tasks without the need for Powershell 3 ! But you will have to enable WinRM yourself manually. That is always the first step, which means running a few things from the ConfigureRemotingForAnsible.ps1 ! The script-module is powershell-agnostic as well (like it is on Unix), which would allow for this as soon as WinRM is configured: - hosts: old_windows
gather_facts: no
tasks:
- script: files/upgrade_to_ps3.ps1 So the following task would work on a Powershell 2 system: - hosts: old_windows
gather_facts: no
tasks:
- raw: |
<powershell commands or script content> In fact what should work equally well is this: - hosts: old_windows
gather_facts: no
tasks:
- raw: {{ lookup("file', 'files/upgrade_to_ps3.ps1') }} Or you can run a script directly from a network share - hosts: old_windows
gather_facts: no
tasks:
- raw: powershell.exe -file \\system\share\path\upgrade_to_ps3.ps1 Good luck, report back and possibly send in a PR with suggested changes to the documentation ! |
@breathe Greetings! Thanks for taking the time to open this issue. In order for the community to handle your issue effectively, we need a bit more information. Here are the items we could not find in your description:
Please set the description of this issue with this template: |
ISSUE TYPE
Feature Idea
COMPONENT NAME
core
ANSIBLE VERSION
2.2
CONFIGURATION
OS / ENVIRONMENT
SUMMARY
The example powershell script for setting up winrm on a windows host in a manner suitable for management with ansible requires powershell 3: https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1
meanwhile this sample powershell script to upgrade to powershell3 suggests that it can be run inside an ansible task (in the comments at the top):
https://github.com/cchurch/ansible/blob/devel/examples/scripts/upgrade_to_ps3.ps1
Chicken and egg though -- you can't run upgrade_to_ps3.ps1 via ansible because you can't setup winrm for ansible correctly with ConfigureRemotingForAnsible.ps1 since ConfigureRemotingForAnsible.ps1 requires powershell 3 ...
Would be nice if ConfigureRemotingForAnsible.ps1 didn't require powershell 3 -- then getting ansible working on a node would be simpler as ansible itself could be used to get the node to powershell3 ...
STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: