Ansible Inventory

    In Ansible, an inventory is a list of hosts or groups of hosts that Ansible can manage. The inventory is used to specify the hosts that Ansible will be executing commands or playbooks against.

    An inventory file can be created in various formats, such as INI, YAML, or JSON, and can contain information about hosts, groups, and variables. The inventory file can be stored locally or remotely and can be dynamically generated from a script or a database.

    Here's an example of an inventory file in INI format:

    [domaincontrollers]
    dc01.winadmin.me
    
    [web]
    web1.winadmin.me
    web2.winadmin.me
    
    [db]
    db1.winadmin.me
    
    [all:vars]
    ansible_user=winadmin
    ansible_ssh_private_key_file=/path/to/private/key
    

    In this example, we have two groups of hosts, "web" and "db", each with their own hosts and IP addresses. The "all:vars" section contains global variables that can be used across all hosts, such as the SSH user and private key file.

    Once you have created an inventory file, you can use it to run Ansible commands or playbooks against the specified hosts or groups. For example, to ping all hosts in the inventory file, you can use the following command:

    ansible all -m ping -i /path/to/inventory/file
    

    A basic INI ansible hosts file is located at /etc/ansible/hosts.