summaryrefslogtreecommitdiff
path: root/test/integration/targets/incidental_inventory_aws_ec2/playbooks/setup.yml
blob: 8a9b88937f100eac7c88994a77b5a8395251c892 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
- name: set connection information for all tasks
  set_fact:
    aws_connection_info: &aws_connection_info
      aws_access_key: '{{ aws_access_key }}'
      aws_secret_key: '{{ aws_secret_key }}'
      security_token: '{{ security_token }}'
      region: '{{ aws_region }}'
  no_log: yes

- name: get image ID to create an instance
  ec2_ami_info:
    filters:
      architecture: x86_64
      owner-id: '125523088429'
      virtualization-type: hvm
      root-device-type: ebs
      name: 'Fedora-Atomic-27*'
    <<: *aws_connection_info
  register: fedora_images

- set_fact:
    image_id: '{{ fedora_images.images.0.image_id }}'

- name: create a VPC to work in
  ec2_vpc_net:
    cidr_block: 10.10.0.0/24
    state: present
    name: '{{ resource_prefix }}_setup'
    resource_tags:
      Name: '{{ resource_prefix }}_setup'
    <<: *aws_connection_info
  register: setup_vpc

- set_fact:
    vpc_id: '{{ setup_vpc.vpc.id }}'

- name: create a subnet to use for creating an ec2 instance
  ec2_vpc_subnet:
    az: '{{ aws_region }}a'
    tags: '{{ resource_prefix }}_setup'
    vpc_id: '{{ setup_vpc.vpc.id }}'
    cidr: 10.10.0.0/24
    state: present
    resource_tags:
      Name: '{{ resource_prefix }}_setup'
    <<: *aws_connection_info
  register: setup_subnet

- set_fact:
    subnet_id: '{{ setup_subnet.subnet.id }}'

- name: create a security group to use for creating an ec2 instance
  ec2_group:
    name: '{{ resource_prefix }}_setup'
    description: 'created by Ansible integration tests'
    state: present
    vpc_id: '{{ setup_vpc.vpc.id }}'
    <<: *aws_connection_info
  register: setup_sg

- set_fact:
    sg_id: '{{ setup_sg.group_id }}'