## A MORE ADVANCED STATIC INVENTORY EXAMPLE

Ansible Terminal

    # A more advanced static inventory example:
    [control]
    mainserver ansible_host=10.42.0.2

    [web]
    node-[1:30] ansible_host=10.42.0.[31:60]

    [haproxy]
    haproxy ansible_host=10.42.0.100

    [all:vars]
    ansible_user=kev
    ansible_ssh_private_key_file=/home/kev/.ssh/id_rsa

The example shown here is a more practical and common example of a static inventory file.

Static inventory files are expressed in INI format. The headings in brackets are group names, which are used in classifying systems and deciding what systems you are controlling at what times and for what purpose. Hosts can belong to multiple groups and groups can be members of other groups. (The latter is not shown here.)

NOTE: This example contains variables, a topic we haven't touched on just yet. We'll go into them on the next slide.

Other noteworthy attributes in our example:

- `ansible_host` is an example of a host variable.
- Hosts can be assigned arbitrary human-meaningful names or aliases such as "control" and "haproxy". Ansible will instead use the value of `ansible_host` (one of several "magic" inventory variables) as the network address to connect.
- Static inventory files can support character ranges such as "node-[1:3]"
- Like localhost, Ansible infers an "all" group is present. As its name implies, all inventory hosts are members of this group.
- The heading "all:vars" is an example of group variable assignment using two more "magic" variables, `ansible_ssh_private_key_file` and `ansible_user`.

This example just covers the basics. There's a lot more to inventory that is not covered here. See the Ansible inventory documentation for more details.

## A MORE ADVANCED STATIC INVENTORY EXAMPLE

Ansible Terminal

    # A more advanced static inventory example:
    [control]
    mainserver ansible_host=10.42.0.2

    [web]
    node-[1:30] ansible_host=10.42.0.[31:60]

    [haproxy]
    haproxy ansible_host=10.42.0.100

    [all:vars]
    ansible_user=kev
    ansible_ssh_private_key_file=/home/kev/.ssh/id_rsa

The example shown here is a more practical and common example of a static inventory file.

Static inventory files are expressed in INI format. The headings in brackets are group names, which are used in classifying systems and deciding what systems you are controlling at what times and for what purpose. Hosts can belong to multiple groups and groups can be members of other groups. (The latter is not shown here.)

NOTE: This example contains variables, a topic we haven't touched on just yet. We'll go into them on the next slide.

Other noteworthy attributes in our example:

- `ansible_host` is an example of a host variable.
- Hosts can be assigned arbitrary human-meaningful names or aliases such as "control" and "haproxy". Ansible will instead use the value of `ansible_host` (one of several "magic" inventory variables) as the network address to connect.
- Static inventory files can support character ranges such as "node-[1:3]"
- Like localhost, Ansible infers an "all" group is present. As its name implies, all inventory hosts are members of this group.
- The heading "all:vars" is an example of group variable assignment using two more "magic" variables, `ansible_ssh_private_key_file` and `ansible_user`.

This example just covers the basics. There's a lot more to inventory that is not covered here. See the Ansible inventory documentation for more details.

## A MORE ADVANCED STATIC INVENTORY EXAMPLE

Ansible Terminal

    # A more advanced static inventory example:
    [control]
    mainserver ansible_host=10.42.0.2

    [web]
    node-[1:30] ansible_host=10.42.0.[31:60]

    [haproxy]
    haproxy ansible_host=10.42.0.100

    [all:vars]
    ansible_user=kev
    ansible_ssh_private_key_file=/home/kev/.ssh/id_rsa

The example shown here is a more practical and common example of a static inventory file.

Static inventory files are expressed in INI format. The headings in brackets are group names, which are used in classifying systems and deciding what systems you are controlling at what times and for what purpose. Hosts can belong to multiple groups and groups can be members of other groups. (The latter is not shown here.)

NOTE: This example contains variables, a topic we haven't touched on just yet. We'll go into them on the next slide.

Other noteworthy attributes in our example:

- `ansible_host` is an example of a host variable.
- Hosts can be assigned arbitrary human-meaningful names or aliases such as "control" and "haproxy". Ansible will instead use the value of `ansible_host` (one of several "magic" inventory variables) as the network address to connect.
- Static inventory files can support character ranges such as "node-[1:3]"
- Like localhost, Ansible infers an "all" group is present. As its name implies, all inventory hosts are members of this group.
- The heading "all:vars" is an example of group variable assignment using two more "magic" variables, `ansible_ssh_private_key_file` and `ansible_user`.

This example just covers the basics. There's a lot more to inventory that is not covered here. See the Ansible inventory documentation for more details.

## A MORE ADVANCED STATIC INVENTORY EXAMPLE

Ansible Terminal

    # A more advanced static inventory example:
    [control]
    mainserver ansible_host=10.42.0.2

    [web]
    node-[1:30] ansible_host=10.42.0.[31:60]

    [haproxy]
    haproxy ansible_host=10.42.0.100

    [all:vars]
    ansible_user=kev
    ansible_ssh_private_key_file=/home/kev/.ssh/id_rsa

The example shown here is a more practical and common example of a static inventory file.

Static inventory files are expressed in INI format. The headings in brackets are group names, which are used in classifying systems and deciding what systems you are controlling at what times and for what purpose. Hosts can belong to multiple groups and groups can be members of other groups. (The latter is not shown here.)

NOTE: This example contains variables, a topic we haven't touched on just yet. We'll go into them on the next slide.

Other noteworthy attributes in our example:

- `ansible_host` is an example of a host variable.
- Hosts can be assigned arbitrary human-meaningful names or aliases such as "control" and "haproxy". Ansible will instead use the value of `ansible_host` (one of several "magic" inventory variables) as the network address to connect.
- Static inventory files can support character ranges such as "node-[1:3]"
- Like localhost, Ansible infers an "all" group is present. As its name implies, all inventory hosts are members of this group.
- The heading "all:vars" is an example of group variable assignment using two more "magic" variables, `ansible_ssh_private_key_file` and `ansible_user`.

This example just covers the basics. There's a lot more to inventory that is not covered here. See the Ansible inventory documentation for more details.