1- name: set connection information for all tasks
2  set_fact:
3    aws_connection_info: &aws_connection_info
4      aws_access_key: '{{ aws_access_key }}'
5      aws_secret_key: '{{ aws_secret_key }}'
6      security_token: '{{ security_token }}'
7      region: '{{ aws_region }}'
8  no_log: yes
9
10- name: get image ID to create an instance
11  ec2_ami_info:
12    filters:
13      architecture: x86_64
14      owner-id: '125523088429'
15      virtualization-type: hvm
16      root-device-type: ebs
17      name: 'Fedora-Atomic-27*'
18    <<: *aws_connection_info
19  register: fedora_images
20
21- set_fact:
22    image_id: '{{ fedora_images.images.0.image_id }}'
23
24- name: create a VPC to work in
25  ec2_vpc_net:
26    cidr_block: 10.10.0.0/24
27    state: present
28    name: '{{ resource_prefix }}_setup'
29    resource_tags:
30      Name: '{{ resource_prefix }}_setup'
31    <<: *aws_connection_info
32  register: setup_vpc
33
34- set_fact:
35    vpc_id: '{{ setup_vpc.vpc.id }}'
36
37- name: create a subnet to use for creating an ec2 instance
38  ec2_vpc_subnet:
39    az: '{{ aws_region }}a'
40    tags: '{{ resource_prefix }}_setup'
41    vpc_id: '{{ setup_vpc.vpc.id }}'
42    cidr: 10.10.0.0/24
43    state: present
44    resource_tags:
45      Name: '{{ resource_prefix }}_setup'
46    <<: *aws_connection_info
47  register: setup_subnet
48
49- set_fact:
50    subnet_id: '{{ setup_subnet.subnet.id }}'
51
52- name: create a security group to use for creating an ec2 instance
53  ec2_group:
54    name: '{{ resource_prefix }}_setup'
55    description: 'created by Ansible integration tests'
56    state: present
57    vpc_id: '{{ setup_vpc.vpc.id }}'
58    <<: *aws_connection_info
59  register: setup_sg
60
61- set_fact:
62    sg_id: '{{ setup_sg.group_id }}'
63