Groups

Group together related items as you see fit.

For example, Cisco devices may need a bunch of similar Ciphers to be set, you might have one specific key for all your AWS projects, or by AWS tenancy, etc.

In this example, all the web servers use port 2201, and they’ll all use the Digital Ocean key apart from the projects-aws node.

The shortened host names are handy for use with Ansible, as you would refer to the hosts by SSH config host name in your Ansible inventories.

---
web_servers:
  Config:
    Port: 2201
    IdentityFile: ~/.ssh/digital_ocean
  Hosts:
    projects-do-1: projects-do-1.example.com
    projects-do-2: projects-do-2.example.com
    projects-aws:
      HostName: projects-aws.example.com
      IdentityFile: ~/.ssh/aws

Will produce this config:

# web_servers
Host projects-do-1
    Port 2201
    IdentityFile ~/.ssh/digital_ocean
    HostName projects-do-1.example.com

Host projects-do-2
    Port 2201
    IdentityFile ~/.ssh/digital_ocean
    HostName projects-do-2.example.com

Host projects-aws
    Port 2201
    IdentityFile ~/.ssh/aws
    HostName projects-aws.example.com

Host *