Commands - vishalkhondre/devops GitHub Wiki

Using Ansible - Establish connection with Windows VM

In ansible hosts file

[windows]

10.0.555.5555

[windows:vars]

ansible_user=aa

ansible_password=aa

ansible_connection=winrm

ansible_winrm_server_cert_validation=ignore

ansible_winrm_port=5985

ansible_winrm_transport=basic

Run below command on Windows VM

winrm quickconfig-q

winrm set winrm/config/service/path '@{Basic="true"}'

winrm set winrm/config/service '@{AllowUnencrypted="true"}'

On Ansible host run below command

ansible windows -m win_ping -vvvvv

Get list of directories of Windows machine from Ansible host

ansible windows -m win_command -a "cmd.exe /c dir c:\"

Fetch facts of Windows VM

ansible windows -m setup

Ansible shell module

ansible localhost -m shell -a "date"