Connecting to Linux and Windows hosts

17 views
Skip to first unread message

PH

unread,
Apr 9, 2020, 8:03:27 AM4/9/20
to Ansible Project
Please, help me to understand, how fill hosts file.
Now i have linux hosts and it's work's fine.
Exaple, how host file look's like:
[all:vars]
ansible_connection=ssh
ansible_ssh_user=user
ansible_ssh_pass=user_pass
[host_linux]
192.168.[1:254].[1:3]

When trying to add windows hosts (ip adresses may be same as linux, because hosts about 1000 and i don't know exatly where linux\windows installed) with windows vars - all hosts including linux and windows hosts began connecting using winrm.
Host file looks like:
[host_linux]
ansible_connection=ssh
ansible_ssh_user=user
ansible_ssh_pass=user_pass
[host_linux]
192.168.[1:254].[1:3]
[host_windows:vars]
ansible_user=user
ansible_password=user_pass
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore
ansible_winrm_transport=basic
[host_windows]
192.168.[1:254].[1:3]

How do I fill in the host file so that Linux hosts run using ssh, Windows hosts using winrm.

Ankit Vashistha

unread,
Apr 14, 2020, 8:38:56 AM4/14/20
to Ansible Project
Not sure if i get your question. You can specify the group specific variables including connection method like below. You need to identify their OS so that you could specify which host will use which connection method.

[all:vars]
ansible_connection=ssh
ansible_ssh_user=user
ansible_ssh_pass=user_pass

[host_linux]
192.168.[1:254].[1:3]

[host_linux:vars]
ansible_connection=ssh

[host_windows]
10.10.10.10

[host_windows:vars]
ansible_connection=winrm

Regards,
Ankit


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6c39eaa7-6ddb-4bdd-af09-b201b777ac57%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages