Inventory Configuration Question

24 views
Skip to first unread message

Anthony Bond

unread,
Feb 3, 2017, 3:16:46 PM2/3/17
to Ansible Project
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 /ansible/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 /ansible/inventory/dev403 -a "var=hostvars[inventory_hostname]"
Reply all
Reply to author
Forward
0 new messages