Open jborean93 opened 4 years ago
From @ShachafGoldstein on Jun 01, 2019 12:06
If you set a username in parameters, do you get the same issue for that task?
I also have the same problem. I did many tests and it seems to be related to the fact that the module uses win32 commands instead of Powershell cmdlets but it might not be related.
In Summary, I create task using this module since couple months. Recently we saw some errors that was becoming more and more present. Last week, while I was trying to disable a task , those errors on the screenshots below appeared.
I don't know if it's related or not , but it seems to be linked with those warnings that started to appear at some point and stated that the task has many instances trying to be started at the same time. I tried to create multiple tasks using powershell New-ScheduledTask cmdlet instead , and those errors disappeared. I'm not sure if those warning below are related to this issue but it seems to be.
Here are the warnings:
I have the exact same behavior in the newest version "2.0.0" from the community.windows collection.
@jborean93 If you add the the username I get then an "msg": "failed to modify scheduled task: The directory property cannot be found in the cache.\r\n"
With the update_password: no
it changes nothing on the wrong behavior.
Creating a batch of deactivated scheduled tasks works fine with the community.windows.win_scheduled_task, but activating them also causes the same bug as described above for deactivating it. I took a watch in the code but its overhelmingly for me, want to help but not able to.
@jborean93 If you add the the username I get then an "msg": "failed to modify scheduled task: The directory property cannot be found in the cache.\r\n" With the
update_password: no
it changes nothing on the wrong behavior.
I encountered this error while configuring scheduled tasks with domain accounts. The problem for me was that the account and/or password had expired on the domain.
Thanks @jborean93 for your input. It was something similiar. There was a wrong password in the Vault which Ansible used for the playbook and on top an Active directory security policy was blocking to allocate the scheduled task to a user in which context the task should run.
For me disabling scheduled tasks works with "community.windows.win_scheduled_task" now. It was a configuration failure from my side, works fine with version 2.2.0. Need to provide path if you use one and not just the root directory from the tasks directory. If there is a user account you have to provide username and password as well on a change, not only initially. I think the issue can be closed.
From @Gianlu on Aug 02, 2018 16:53
SUMMARY
Trying to disable a Windows Scheduled task throws an exception. The sintax to disable a task is described in documentation.
ISSUE TYPE
COMPONENT NAME
win_scheduled_task
ANSIBLE VERSION
CONFIGURATION
DEFAULT_LOAD_CALLBACK_PLUGINS(/etc/ansible/ansible.cfg) = False DEFAULT_LOG_PATH(/etc/ansible/ansible.cfg) = /home/adminsalvo/ansible.log DEFAULT_MODULE_PATH(/etc/ansible/ansible.cfg) = [u'/usr/share/ansible/modules']
OS / ENVIRONMENT
Ansible is running on Debian 9.5. Target host is Windows 2012 R2
STEPS TO REPRODUCE
EXPECTED RESULTS
changed: [myserver] => (item=myprefix_task01)
ACTUAL RESULTS
The password is correct because when i run
The task is enabled (or disabled). Also the command
is successfull.
Thank you.
Copied from original issue: ansible/ansible#43612