Hi, not sure if it will help..
But here is what i know..
In general for group_vars, i do the below structure
../group_vars/web
../group_vars/db
Under those folders, you can use something like var.yml and put the
variables inside.
So when using the playbook, group names that matches the group_vars/<group
name>, the variables underneath it will get recognized.
That is if there is some specific thing you want to differentiate, if not,
you can just do
../group_vars/all
And all the variables defined under it will be recognized by all servers in
your inventory.
On Wednesday, May 9, 2018 at 5:07:30 PM UTC+8, java_cat33 wrote:
>
> 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.
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/e7ebaab3-a589-41d5-920c-a940b603a1f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.