The subnets role

Now that we have our VPC, we can start to populate it. The first thing we are going to configure is the 10 subnets. If you recall, we need the following:

  • Three EC2 instances
  • Three ELB instances
  • Two RDS instances
  • Two EFS instances

Create the role by running the following command from your working directory:

$ ansible-galaxy init roles/subnets

Now, in roles/subnets/defaults/main.yml, enter the following:

the_subnets:  - { use: 'ec2', az: 'a', subnet: '10.0.10.0/24' }  - { use: 'ec2', az: 'b', subnet: '10.0.11.0/24' }  - { use: 'ec2', az: 'c', subnet: '10.0.12.0/24' }  - { use: 'elb', az: 'a', subnet: '10.0.20.0/24' }  - { use: 'elb', az: 'b', subnet: '10.0.21.0/24' }  - { use: 'elb', az: 'c', subnet: '10.0.22.0/24' } - { use: 'rds', ...

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.