Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 'Dynamic inventory with AWS' example to use inventory plugin #303

Closed
geerlingguy opened this issue Jul 26, 2020 · 2 comments
Closed

Comments

@geerlingguy
Copy link
Owner

geerlingguy commented Jul 26, 2020

Related: #201 and #229.

Basically, need to start using the dynamic AWS inventory plugin instead of the inventory script the book currently mentions. There's a related episode of Ansible 101 on this topic: https://youtu.be/_rDzMYp-fBs?t=2464

@geerlingguy
Copy link
Owner Author

geerlingguy commented Jul 31, 2020

In chapter 8, I updated the "Dynamic inventory with AWS" example thusly:

Dynamic inventory with AWS

Many of this book's readers are familiar with Amazon Web Services (especially EC2, S3, RDS, and Route53), and likely have managed or currently manage an infrastructure within Amazon's cloud. Ansible has very strong support for managing AWS-based infrastructure, and includes a EC2 inventory plugin to help you run playbooks on your hosts in a variety of ways.

Ansible's own documentation includes a thorough Amazon Web Services Guide if you'd like to automate your AWS workflows with Ansible.

I won't be covering AWS dynamic inventory in this chapter, but will mention that the aws_ec2 inventory plugin, along with Ansible's extensive support for AWS infrastructure through ec2_* modules, makes Ansible an excellent choice for managing AWS infrastructure.

In the next chapter, one of the examples will include a guide for provisioning infrastructure on AWS, along with a quick overview of dynamic inventory on AWS.

@geerlingguy
Copy link
Owner Author

geerlingguy commented Jul 31, 2020

I'm also updating the example in Chapter 9 to be able to use the following aws_ec2 inventory plugin configuration:

---
plugin: aws_ec2

regions:
  - us-east-1

hostnames:
  - ip-address

keyed_groups:
  - key: tags.inventory_group
    separator: ''
  - key: tags.Application
    separator: ''

This allows you to use the dynamic inventory plugin instead of the extra add_hosts bit to work with the servers the provisioning play sets up:

$ ansible-inventory -i inventories/aws/aws_ec2.yml --graph
@all:
  |--@aws_ec2:
  |  |--54.148.41.134
  |  |--54.148.100.44
  |  |--54.69.160.32
  |  |--54.69.86.187
  |  |--54.148.120.23
  |  |--54.148.56.137
  |--@lamp_aws:
  |  |--54.148.41.134
  |  |--54.148.100.44
  |  |--54.69.160.32
  |  |--54.69.86.187
  |  |--54.148.120.23
  |  |--54.148.56.137
  |--@lamp_db:
  |  |--54.148.100.44
  |  |--54.148.120.23
  |--@lamp_memcached:
  |  |--54.148.41.134
  |--@lamp_varnish:
  |  |--54.148.56.137
  |--@lamp_www:
  |  |--54.69.160.32
  |  |--54.69.86.187
  |--@ungrouped:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant