The second command is what i'd expect to work. group_vars/ , host_vars/ etc
are relative to the directory holding the 'hosts' static list.
General rule: if you're going to target plays against different groups
of servers,
put them as groups in a single inventory.
There'd be nothing wrong with a single inventory with groups like
'dev3' , 'dev5', etc.
On 3 February 2017 at 20:11, Anthony Bond <
bond.a...@outlook.com> wrote:
> I have been using Ansible in a limited fashion and have configured a static
> inventory. I'm trying to build onto this inventory by adding groups_vars and
> host_vars for individual cluster groups. Problem is Ansible isn't picking up
> the required group_vars. Does anyone see why my group_vars wouldn't be
> loading with this inventory structure. I'm only testing with the dev3 group
> before filling out the remaining group_vars directories.
>
> Command: ansible -m debug dev3 -i /eprn/inventory -a
> "var=hostvars[inventory_hostname]"
>
> inventory/
> ├── batch
> │ ├── group_vars
> │ ├── hosts
> │ └── host_vars
> ├── dev0
> │ ├── group_vars
> │ ├── hosts
> │ └── host_vars
> ├── dev1
> │ ├── group_vars
> │ ├── hosts
> │ └── host_vars
> ├── dev2
> │ ├── group_vars
> │ ├── hosts
> │ └── host_vars
> ├── dev3
> │ ├── group_vars
> │ │ ├── dev3
> │ │ │ └── vars.yml
> │ │ └── dev3_db
> │ ├── hosts
> │ └── host_vars
> ├── dev4
> │ ├── group_vars
> │ ├── hosts
> │ └── host_vars
> ├── dev5
> │ ├── group_vars
> │ ├── hosts
> │ └── host_vars
> ├── dev6
> │ ├── group_vars
> │ ├── hosts
> │ └── host_vars
> └── dev7
> ├── group_vars
> ├── hosts
> └── host_vars
>
>
> Current Sample Output:
>
dev1.domain.com | SUCCESS => {
> "hostvars[inventory_hostname]": {
> "ansible_check_mode": false,
> "ansible_version": {
> "full": "2.1.2.0",
> "major": 2,
> "minor": 1,
> "revision": 2,
> "string": "2.1.2.0"
> },
> "group_names": [
> "dev3"
> ],
> "groups": {
> "all": [
> "
test1.domain.com",
> "
test2.domain.com",
> "
test3.domain.com",
> "
dev1.domain.com",
> "
dev2.domain.com",
> "
dev3.domain.com",
> "
dev4.domain.com"
> ],
> "dev3": [
> "
dev1.domain.com",
> "
dev2.domain.com",
> "
dev3.domain.com",
> "
dev4.domain.com",
> "
dev5.domain.com"
> ],
> "ungrouped": []
> },
> "inventory_dir": "/ansible/inventory",
> "inventory_file": null,
> "inventory_hostname": "
dev3.domain.com",
> "inventory_hostname_short": "dev3",
> "omit":
> "__omit_place_holder__998cd0b3347833ef6af77480e6387c8135a35469",
> "playbook_dir": "."
> }
> }
>
>
>
> Expected Output with the addition of my group_vars
> "app_location": "east",
> "db_connection": "some string value",
>
dev1.domain.com | SUCCESS => {
> "hostvars[inventory_hostname]": {
> "ansible_check_mode": false,
> "ansible_version": {
> "full": "2.1.2.0",
> "major": 2,
> "minor": 1,
> "revision": 2,
> "string": "2.1.2.0"
> },
> "app_location": "east",
> "db_connection": "some string value",
> "group_names": [
> "dev3"
> ],
> "groups": {
> "all": [
> "
test1.domain.com",
> "
test2.domain.com",
> "
test3.domain.com",
> "
dev1.domain.com",
> "
dev2.domain.com",
> "
dev3.domain.com",
> "
dev4.domain.com"
> ],
> "dev3": [
> "
dev1.domain.com",
> "
dev2.domain.com",
> "
dev3.domain.com",
> "
dev4.domain.com",
> "
dev5.domain.com"
> ],
> "ungrouped": []
> },
> "inventory_dir": "/ansible/inventory",
> "inventory_file": null,
> "inventory_hostname": "
dev3.domain.com",
> "inventory_hostname_short": "dev3",
> "omit":
> "__omit_place_holder__998cd0b3347833ef6af77480e6387c8135a35469",
> "playbook_dir": "."
> }
> }
>
>
> I do know that running the below command will produce the desired data that
> I'm expecting, but now I don't have all of my hosts that I want. I'm
> probably trying to over organize my hosts by breaking all my groups out into
> small clusters of groups. What I found odd is Ansible can read the hosts
> files located in the individual cluster directories but it won't recognize
> the group_vars unless I move my group_vars under /ansible/inventory..
>
> ansible -m debug dev403 -i /eprn/inventory/dev403 -a
> "var=hostvars[inventory_hostname]"
>
> --
> 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 post to this group, send email to
ansible...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/ansible-project/3f3a8785-eb2b-4945-a559-bac18c5bde29%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.