-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfraestructure.yml
87 lines (79 loc) · 2.47 KB
/
infraestructure.yml
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
- name: "Get last aws amazon linux"
ec2_ami_find:
profile: "{{ boto_profile | default(omit) }}"
region: "{{ racker_region }}"
name: "amzn-ami-hvm-*"
sort: creationDate
sort_order: descending
sort_end: 1
register: ami_find
- set_fact:
aws_ami_id: "{{ ami_find.results[0].ami_id }}"
- name: "getting server certicated"
iam_server_certificate_facts:
profile: "{{ boto_profile | default(omit) }}"
region: "{{ racker_region }}"
name: "{{ racker_elb_cert_name }}"
register: server_cert
- set_fact:
arn_server_cert: "{{ server_cert['results']['elb-to-zuul-pre']['arn'] }}"
- name: "Building ELB"
local_action:
module: ec2_elb_lb
profile: "{{ boto_profile | default(omit) }}"
region: "{{ racker_region }}"
name: "{{ racker_name }}"
security_group_ids: "{{ racker_aws_security_groups }}"
subnets: "{{ racker_aws_subnets }}"
scheme: internal
state: present
purge_instance_ids: true
listeners:
- protocol: https
load_balancer_port: 443
instance_protocol: http
instance_port: 5000
ssl_certificate_id: "{{ arn_server_cert }}"
register: elb
- name: "Building launch configuration"
ec2_lc:
profile: "{{ boto_profile | default(omit) }}"
region: "{{ racker_region }}"
name: "{{ racker_name }}"
image_id: "{{ aws_ami_id }}"
instance_profile_name: "{{ racker_instance_profile }}"
key_name: "{{ racker_aws_key_pair }}"
security_groups: "{{ racker_aws_security_groups }}"
instance_type: "{{ racker_instance_type }}"
assign_public_ip: yes
register: launch_configuration
- set_fact:
lc_name: "{{ launch_configuration['name'] }}"
- name: "Building ASG"
ec2_asg:
profile: "{{ boto_profile | default(omit) }}"
region: "{{ racker_region }}"
name: "{{ racker_name }}"
vpc_zone_identifier: "{{ racker_aws_subnets }}"
launch_config_name: "{{ lc_name }}"
load_balancers: "{{ racker_name }}"
min_size: 1
max_size: 1
desired_capacity: 1
wait_for_instances: True
tags:
- Name: "{{ racker_name }}"
- name: "Getting ec2 with tag-name: pruebas and state: running"
ec2_remote_facts:
profile: "{{ boto_profile | default(omit) }}"
region: "{{ racker_region }}"
filters:
instance-state-name: running
"tag:Name": "{{ racker_name }}"
register: ec2_info
- name: "Adding hosts"
add_host:
name: "{{ item.public_dns_name }}"
groups: target_instances
with_items: "{{ ec2_info.instances }}"