AWS role

Our first role will create the VPC and launch the EC2 instance. To bootstrap the role change, go to the cloud folder and run:

$ cd cloud$ ansible-galaxy init roles/aws

Let's start with the contents of roles/aws/defaults/main.yml first:

vpc_cidr_block: "10.0.0.0/16"the_subnets:  - { use: 'ec2', az: 'a', subnet: '10.0.10.0/24' }ec2:  instance_type: "t2.large"  wait_port: "5986"image:  base: Windows_Server-2016-English-Full-Base-*  owner: amazon  architecture: x86_64  root_device: ebswin_initial_password: "{{ lookup('password', 'group_vars/generated_administrator chars=ascii_letters,digits length=30') }}"

As you can see, we are only going to be using a single subnet and we are going to be looking for a Windows Server 2016 AMI during the playbook ...

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.