Building an Ansible inventory
Ansible needs a description of the infrastructure network setup that we will build across the AWS public cloud. In this recipe, we create the host inventory file in Ansible, declaring our Virtual Private Clouds (VPCs) as nodes in the inventory, similar to defining a network node. The main difference is that VPCs don’t have a management IP address, so we skip the ansible_host argument for them.
Think of these inventory hosts not as machines to SSH into but as logical objects that your playbook will manage. The transport=local setting in ansible.cfg tells Ansible to run all tasks from the control node and interact directly with the AWS API.
In the inventory file, we organize VPCs into the following groups:
us_prod_vpcs: Grouping all VPCs in the USeu_prod_vpcs: Grouping all VPCs in Europeprod_vpcs: Grouping both the US and Europe VPCs together (equivalent to all VPCs, in this case)
Additionally, we configure...