So far I’ve found out that if I have an inventory file (E.G inventory.yml) within a playbook folder, and a file named web.yml in group_vars I can do a win_ping without issues when the inventory file contains a group named [web] and a server resides within this group - cool.
I expanded the inventory.yml and added additional groups [db] and added servers to this new group.
If I run ‘ansible all -i inventory.yml -m win_ping’ - only the server listed within the [web] group get’s a successful connection/response. The other servers listed within [db] fail with a message about failing to connect to the host via ssh.
[WARNING]: ansible_winrm_cert_validation unsupported by pywinrm (is an up-to-date version of pywinrm installed?)
webserver1 | SUCCESS => {
“changed”: false,
“ping”: “pong”
}
db1 | UNREACHABLE! => {
“changed”: false,
“msg”: “Failed to connect to the host via ssh: ssh: connect to host db1 port 22: Connection timed out\r\n”,
“unreachable”: true
}
db2 | UNREACHABLE! => {
“changed”: false,
“msg”: “Failed to connect to the host via ssh: ssh: connect to host db2 port 22: Connection timed out\r\n”,
“unreachable”: true
}
The web.yml file just contains connection information on how to connect to the Windows boxes (winrm etc)
I then made a copy of web.yml and named it db.yml so now I have web.yml and db.yml in the group_vars directory and ran the same ansible command again to test the ping to all servers in the inventory file - this worked without issues across all three hosts.
I want to know if there is a smarter/easier way to do this?
What is recommended practice - single inventory file for test, single inventory file for production which you reference for your playbooks? Inventory file must contains loads of groups so I’m guessing make a bunch of copies of the files in group_vars is not the best way to approach this…???
Thanks in advance.