ansible.windows
ansible.windows copied to clipboard
win_service_info error
SUMMARY
On some windows pcs I get an error when trying to use this module. Not on all, on some it works ok.
I want to mantion this was reported here https://github.com/ansible-collections/ansible.windows/issues/556 but is not solved. However 2 more laptops work. Before I had only laptop 2 working, now I have laptop 2, 4 and 5 from five laptops. Laptop 1 and 3 errors out.
ISSUE TYPE
- Bug Report
COMPONENT NAME
win_service_info
ANSIBLE VERSION
ansible [core 2.15.5]
config file = None
configured module search path = ['/home/ciprian/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/ciprian/.local/lib/python3.9/site-packages/ansible
ansible collection location = /home/ciprian/.ansible/collections:/usr/share/ansible/collections
executable location = /home/ciprian/.local/bin/ansible
python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
COLLECTION VERSION
# /home/ciprian/.ansible/collections/ansible_collections
Collection Version
--------------- -------
ansible.windows 2.1.0
# /home/ciprian/.local/lib/python3.9/site-packages/ansible_collections
Collection Version
--------------- -------
ansible.windows 1.14.0
CONFIGURATION
CONFIG_FILE() = /home/ciprian/ansible/windows_work_local/ansible.cfg
DEFAULT_BECOME_METHOD(/home/ciprian/ansible/windows_work_local/ansible.cfg) = runas
DEFAULT_HOST_LIST(/home/ciprian/ansible/windows_work_local/ansible.cfg) = ['/home/ciprian/ansible/windows_work_local/hosts.ini']
DEFAULT_ROLES_PATH(/home/ciprian/ansible/windows_work_local/ansible.cfg) = ['/home/ciprian/ansible/windows_work_local/roles']
DEFAULT_STDOUT_CALLBACK(/home/ciprian/ansible/windows_work_local/ansible.cfg) = yaml
HOST_KEY_CHECKING(/home/ciprian/ansible/windows_work_local/ansible.cfg) = False
INTERPRETER_PYTHON(/home/ciprian/ansible/windows_work_local/ansible.cfg) = auto_silent
OS / ENVIRONMENT
target win 10 and win 11 laptops
STEPS TO REPRODUCE
I am trying to the the state of all services to use this info in disabling some of them
- name: Get info for all services
ansible.windows.win_service_info:
register: pc_services_info
EXPECTED RESULTS
On one laptop and some pc's everything works as expected
ACTUAL RESULTS
On some laptops I get this:
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: at Microsoft.PowerShell.Commands.NewObjectCommand.CallConstructor(Type type, ConstructorInfo[] constructors, Object[] args)
fatal: [laptop3]: FAILED! => changed=false
msg: 'Unhandled exception while executing module: Exception calling ".ctor" with "2" argument(s): "Failed to query service config (The system cannot find the file specified, Win32ErrorCode 2 - 0x00000002)"'
Verbose:
The full traceback is:
The full traceback is:
Exception calling ".ctor" with "2" argument(s): "Failed to query service config (The system cannot find the file specified, Win32ErrorCode 2 - 0x00000002)"
At line:31 char:24
+ ... $service = New-Object -TypeName Ansible.Windows.SCManager.Service -A ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
ScriptStackTrace:
at <ScriptBlock>, <No file>: line 31
System.Management.Automation.MethodInvocationException: Exception calling ".ctor" with "2" argument(s): "Failed to query service config (The system cannot find the file specified, Win32ErrorCode 2 - 0x00000002)" ---> ansible_collections.ansible.windows.plugins.module_utils.SCManager.ServiceManagerException: Failed to query service config (The system cannot find the file specified, Win32ErrorCode 2 - 0x00000002)
at ansible_collections.ansible.windows.plugins.module_utils.SCManager.Service.Refresh() in c:\Users\asd\AppData\Local\Temp\tzirokdj.0.cs:line 1273
--- End of inner exception stack trace ---
at System.Management.Automation.DotNetAdapter.AuxiliaryConstructorInvoke(MethodInformation methodInformation, Object[] arguments, Object[] originalArguments)
at System.Management.Automation.DotNetAdapter.ConstructorInvokeDotNet(Type type, ConstructorInfo[] constructors, Object[] arguments)
at Microsoft.PowerShell.Commands.NewObjectCommand.CallConstructor(Type type, ConstructorInfo[] constructors, Object[] args)
fatal: [laptop1]: FAILED! => changed=false
msg: 'Unhandled exception while executing module: Exception calling ".ctor" with "2" argument(s): "Failed to query service config (The system cannot find the file specified, Win32ErrorCode 2 - 0x00000002)"'
The change that resolved #556 has not been pushed to a release yet. It will be present in ansible.windows 2.2.0
which should be out sometime this week.