--- | |
- hosts: windows | |
tasks: | |
- name: ping | |
win_ping: |
Hi @gravcat, I am new to ansible and trying to do the same task (pinging a windows client with control node: centos 7).
I am not sure what is going wrong? Kindly help.
@Gravecat In which file you are passing these?
ansible_user: username
ansible_password: super_secret_password
ansible_port: 5986
ansible_connection: winrm
ansible_winrm_server_cert_validation: ignore
Is this needed to add in the ping_windows_hosts.yml you are using or elsewhere? Please take a look
Hey @TridevGuha! Welcome to Ansible, it's a wonderful tool.
https://docs.ansible.com/ansible/latest/user_guide/intro_getting_started.html#action-create-a-basic-inventory
https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html#basics
As for the basics to get this rolling in a clean way you'll need
- a host inventory (
hosts
) - a group_vars file (
group_vars/windows.yml
) - a playbook (
main.yml
)
It looks like you are putting your playbook as group_vars by mistake, and ansible is trying to read it and failing. Move windows1.yml
to ../main.yml
In group_vars/windows.yml
, place:
ansible_user: username
ansible_password: super_secret_password
ansible_port: 5986
ansible_connection: winrm
ansible_winrm_server_cert_validation: ignore
At this point, it should work :)
unrelated, here's an example of a simple playbook. Doesn't include group_vars
like this one would, but shows how your main.yml
playbook entrypoint should be!
@gravcat I have made the changes and It is working now! Thanks for the response!
A config file will be needed, I used ansible conventions to have it sucked in as part of the "windows" host group. In
group_vars/windows.yml
(relative to the playbook):More info on this at the Ansible Windows Support page.
Upon execution, the output should be rather concise:
The ok near the Gathering Facts and ping tasks show us that the connection and execution against this machine(s) is good and well, ready to go!