Comments (5)
I was finally able to replicate this problem and have a PR which should solve it #244. The issue occurs when there is a mismatch between the UI Culture and the one the PSDesiredStateConfiguration
was installed with. Because the psrp
connection forces the locale to be en-US
you were having a failure where PSDesiredStateConfiguration
was trying to load data for en-US
when the resources only existed for ja-JP
.
What the changes in #244 have done is to temporary change the UI Culture to the installed culture so the import process runs properly before continuing on as normal.
from ansible.windows.
I'm not sure that proposed fix fixes win_dsc, the error here is that the Get-DscResource
cmdlet was found in the PSDesiredStateConfiguration
module but PowerShell couldn't load it from some reason.
Try running this task to see if it gives you any more errors as to why it couldn't be loaded.
- win_shell: Import-Module PSDesiredStateConfiguration
from ansible.windows.
I tried your idea and it didn't change the win_dsc message.
# diff win_dsc.before.yml win_dsc.yml -u
--- win_dsc.before.yml 2020-07-25 13:00:24.195217100 +0000
+++ win_dsc.yml 2020-07-25 12:53:33.405217100 +0000
@@ -14,6 +14,8 @@
name: xWebAdministration
state: present
+ - win_shell: Import-Module PSDesiredStateConfiguration
+
- win_dsc:
resource_name: xWebsite
Name: WebApi
# ansible-playbook -i hosts win_dsc.yml -vvvv
ansible-playbook 2.9.10
config file = /root/.ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.8/dist-packages/ansible
executable location = /usr/local/bin/ansible-playbook
python version = 3.8.2 (default, Apr 27 2020, 15:53:34) [GCC 9.3.0]
Using /root/.ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /root/Web/ansible/hosts as it did not pass its verify_file() method
script declined parsing /root/Web/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /root/Web/ansible/hosts as it did not pass its verify_file() method
Parsed /root/Web/ansible/hosts inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /usr/local/lib/python3.8/dist-packages/ansible/plugins/callback/default.py
PLAYBOOK: win_dsc.yml ********************************************************************************************************************************************************************************************
Positional arguments: win_dsc.yml
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/root/Web/ansible/hosts',)
forks: 5
1 plays in win_dsc.yml
PLAY [all] *******************************************************************************************************************************************************************************************************
TASK [Gathering Facts] *******************************************************************************************************************************************************************************************
task path: /root/Web/ansible/win_dsc.yml:2
Using module file /usr/local/lib/python3.8/dist-packages/ansible/modules/windows/setup.ps1
Pipelining is enabled.
<10.0.4.105> ESTABLISH PSRP CONNECTION FOR USER: Administrator ON PORT 5986 TO 10.0.4.105
PSRP: EXEC (via pipeline wrapper)
ok: [10.0.4.105]
META: ran handlers
TASK [win_shell] *************************************************************************************************************************************************************************************************
task path: /root/Web/ansible/win_dsc.yml:11
Using module file /usr/local/lib/python3.8/dist-packages/ansible/modules/windows/win_shell.ps1
Pipelining is enabled.
<10.0.4.105> ESTABLISH PSRP CONNECTION FOR USER: Administrator ON PORT 5986 TO 10.0.4.105
PSRP: EXEC (via pipeline wrapper)
changed: [10.0.4.105] => {
"changed": true,
"cmd": "Install-PackageProvider -Name NuGet",
"delta": "0:00:03.140734",
"end": "2020-07-25 01:19:01.644869",
"rc": 0,
"start": "2020-07-25 01:18:58.504135",
"stderr": "",
"stderr_lines": [],
"stdout": "",
"stdout_lines": []
}
TASK [win_psmodule] **********************************************************************************************************************************************************************************************
task path: /root/Web/ansible/win_dsc.yml:13
Using module file /usr/local/lib/python3.8/dist-packages/ansible/modules/windows/win_psmodule.ps1
Pipelining is enabled.
<10.0.4.105> ESTABLISH PSRP CONNECTION FOR USER: Administrator ON PORT 5986 TO 10.0.4.105
PSRP: EXEC (via pipeline wrapper)
ok: [10.0.4.105] => {
"changed": false,
"nuget_changed": false,
"output": "Module xWebAdministration already present",
"repository_changed": false
}
TASK [win_shell] *************************************************************************************************************************************************************************************************
task path: /root/Web/ansible/win_dsc.yml:17
Using module file /usr/local/lib/python3.8/dist-packages/ansible/modules/windows/win_shell.ps1
Pipelining is enabled.
<10.0.4.105> ESTABLISH PSRP CONNECTION FOR USER: Administrator ON PORT 5986 TO 10.0.4.105
PSRP: EXEC (via pipeline wrapper)
changed: [10.0.4.105] => {
"changed": true,
"cmd": "Import-Module PSDesiredStateConfiguration",
"delta": "0:00:00.859406",
"end": "2020-07-25 01:19:11.660835",
"rc": 0,
"start": "2020-07-25 01:19:10.801429",
"stderr": "",
"stderr_lines": [],
"stdout": "",
"stdout_lines": []
}
TASK [win_dsc] ***************************************************************************************************************************************************************************************************
task path: /root/Web/ansible/win_dsc.yml:19
Using module file /usr/local/lib/python3.8/dist-packages/ansible/modules/windows/win_dsc.ps1
Pipelining is enabled.
<10.0.4.105> ESTABLISH PSRP CONNECTION FOR USER: Administrator ON PORT 5986 TO 10.0.4.105
PSRP: EXEC (via pipeline wrapper)
The full traceback is:
The 'Get-DscResource' command was found in the module 'PSDesiredStateConfiguration', but the module could not be loaded. For more information, run 'Import-Module PSDesiredStateConfiguration'.
At line:332 char:21
+ $module_versions = (Get-DscResource -Name $resource_name -ErrorAction ...
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-DscResource:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
ScriptStackTrace:
at <ScriptBlock>, <No file>: line 332
fatal: [10.0.4.105]: FAILED! => {
"changed": false,
"msg": "Unhandled exception while executing module: The 'Get-DscResource' command was found in the module 'PSDesiredStateConfiguration', but the module could not be loaded. For more information, run 'Import-Module PSDesiredStateConfiguration'."
}
PLAY RECAP *******************************************************************************************************************************************************************************************************
10.0.4.105 : ok=4 changed=2 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
I tried running the command directly in Windows Server, but playbook result is the same.
PS C:\Users\Administrator> Import-Module PSDesiredStateConfiguration
PS C:\Users\Administrator> Get-Module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Binary 1.0.0.1 PackageManagement {Find-Package, Find-PackageProvider, Get-Package, Get-Pack...
Script 1.0.0.1 PowerShellGet {Find-Command, Find-DscResource, Find-Module, Find-RoleCap...
Manifest 1.1 PSDesiredStateConfiguration {Invoke-DscResource, Publish-DscConfiguration, Set-DscLoca...
Script 2.0.0 PSReadline {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PS...
from ansible.windows.
win_template, win_copy and win_service succeed in psrp.
I think this is not a win_dsc problem, although I've only encountered this error with win_dsc at the moment.
In some cases, the psrp response contains non-English messages.
I think psrp.py is not handling it properly.
from ansible.windows.
In some cases, the psrp response contains non-English messages.
That may be the case but the error message you are getting back from win_dsc
is
The 'Get-DscResource' command was found in the module 'PSDesiredStateConfiguration', but the module could not be loaded. For more information, run 'Import-Module PSDesiredStateConfiguration'.
At line:332 char:21
+ $module_versions = (Get-DscResource -Name $resource_name -ErrorAction ...
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-DscResource:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
It's saying that the cmdlet was found but for some reason the PSDesiredStateConfiguration
module could not be loaded. The win_shell example I asked you to try shows that Import-Module
works so something else is having issues. Can you try the following 2 tasks
- win_shell: |
Import-Module PSDesiredStateConfiguration -Verbose
Get-DscResource -Name xWebsite -Verbose
- win_shell: |
Get-DscResource -Name xWebsite -Verbose
It might also be a good idea to try using raw
instead of win_shell
for those 2 examples just to imitate the same context that psrp
runs a module in.
from ansible.windows.
Related Issues (20)
- win_get_url does not respect content-disposition HOT 1
- win_update failed since ansible 7.7.0 HOT 3
- win_update show different trigger in Event Viewer HOT 1
- ansible.windows.win_powershell misinterprets block scalar (string block) HOT 2
- win_package: support checksum verification HOT 2
- intermittent winrm connection failures with large hosts count HOT 8
- intermittent "unable to delete temporary file" errors HOT 9
- Win_updates fail with "Exception from HRESULT: 0x80072EE2" HOT 2
- Windows Update Module not installing any updates HOT 4
- Windows update failes due to update loop HOT 3
- win_environment : Maybe add an option to read variable content ? HOT 5
- Error during machine sid retrieval: An error (1788) occurred while enumerating the group membership. The member's SID could not be resolved. HOT 8
- Access denied after renaming windows host : Server not found in Kerberos database HOT 10
- Failed to create temporary directory when running win_template module against Windows Server 2019 HOT 10
- win_copy doesnt work when folder name has special character HOT 2
- Add account_expires functionality from the Set-LocalUser PowerShell Cmdlet HOT 2
- Using Machine credentials from AAP passed to playbook with ansible.windows.win_copy fails HOT 2
- ERROR DURING WINRM SEND INPUT - attempting to recover: WinRMTransportError Bad HTTP response returned from server. Code 413 HOT 1
- win_copy module not handling an invalid path correctly. HOT 1
- Feature request: A better win_acl module HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible.windows.