Ansible
Run role against arbitrary host
Section titled “Run role against arbitrary host”Note the comma after the IP or FQDN as described here. Additional hosts can be added by supplying -i parameter with more arguments (comma at the end only if total count is 1).
ansible-playbook -i '<IP or FQDN>,' -u '<user name>' --extra-vars \ 'ansible_winrm_server_cert_validation=ignore \ ansible_connection=winrm \ ansible_winrm_transport=credssp \ ansible_password=<password>' --tags '<tag value for a role>' playbook.ymlFrom here.
Run ad-hoc command against host
Section titled “Run ad-hoc command against host”Replace the final ‘all’ with a more precise host pattern if you passed more than one IP or FQDN to the initial list (comma at the end only if total count is 1).
ansible -i '<IP or FQDN>,' -u '<user name>' --extra-vars \ 'ansible_winrm_server_cert_validation=ignore \ ansible_connection=winrm \ ansible_winrm_transport=credssp \ ansible_password=<password>' -m 'win_shell' -a 'ipconfig' 'all'Add timing information to output
Section titled “Add timing information to output”The below is from an ansible.cfg file.
[defaults]callback_whitelist = profile_tasksFrom here.
Make verbose output more readable
Section titled “Make verbose output more readable”ANSIBLE_STDOUT_CALLBACK='yaml'Debug variables without playbook run
Section titled “Debug variables without playbook run”ansible -m debug <host> -a "var=hostvars[inventory_hostname].<variable>"