Reputation: 169
I want to schedule following playbook:
- hosts: win_hv_hosts
tasks:
- name: Return list of found updates and log to C:\ans_found_updates.txt
win_updates:
category_names: SecurityUpdates
state: searched
log_path: C:/ans_found_updates.txt
My win_hv_hosts:
[win_hv_hosts]
192.168.1.36
192.168.1.37
[win_hv_hosts:vars]
ansible_user = [email protected]
ansible_password = Password
ansible_connection = winrm
ansible_winrm_server_cert_validation=ignore
ansible_port = 5985
When running manually
sudo ansible-playbook win_check_updates.yml -f 10
everything is OK. I want to schedule it to run with cron:
0 * * * * /usr/bin/ansible-playbook /etc/ansible/win_check_updates.yml -f 10 > /home/user/crontab.log
I am getting errors:
fatal: [192.168.1.36]: UNREACHABLE! => {"changed": false, "msg": "plaintext: the specified credentials were rejected by the server", "unreachable": true}
fatal: [192.168.1.37]: UNREACHABLE! => {"changed": false, "msg": "plaintext: the specified credentials were rejected by the server", "unreachable": true}
PLAY RECAP *********************************************************************
192.168.1.36 : ok=0 changed=0 unreachable=1 failed=0
192.168.1.37 : ok=0 changed=0 unreachable=1 failed=0
What I am missing?
Upvotes: 0
Views: 3472
Reputation: 2823
Then credentials error is because you have specified the password in plain text. Encrypt the password using encrypt or use ansible vault.
In terms of normal execution i.e without from you have provided password in plain text, right ?
If this is working then some issues with the ansible invocation
Also why you have used sudo to execute playbook ?
Upvotes: 0