Instance discovery

We are going to simply call this role EC2, so we need to run the following command to create the role structure:

$ ansible-galaxy init roles/ec2

The primary goal of this role is to ensure that by the end of its execution, we have an instance, either a new or an existing one, that we can then use in the forthcoming roles to base an AMI on.

The defaults in roles/ec2/defaults/main.yml define which image we want to use if our role discovers that this is a new deployment. For our installation, we are going to be using the AMI provided by CentOS in the AWS Marketplace; this means we can reuse large chunks of our WordPress installation playbook:

image:  base: "CentOS Linux 7 x86_64*"  owner: "679593333241"  root_device: "ebs" architecture: ...

Get Learn Ansible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.