forked from typesafehub/conductr-ansible
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-training-cluster.yml
98 lines (83 loc) · 2.48 KB
/
build-training-cluster.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
88
89
90
91
92
93
94
95
96
---
- name: Provision and configure a ConductR cluster on AWS
hosts: localhost
connection: local
gather_facts: False
vars_files:
- "{{ VARS_FILE }}"
tasks:
- name: Launch Seed
local_action:
module: ec2
image: "{{ IMAGE }}"
instance_type: "{{ INSTANCE_TYPE }}"
keypair: "{{ KEYPAIR }}"
region: "{{ EC2_REGION }}"
group_id: "{{ NODE_SECURITY_GROUP }}"
vpc_subnet_id: "{{ SUBNET_SEED }}"
assign_public_ip: yes
instance_tags:
Name: "{{ TAG_NAME }}"
Role: Seed Node
count: 1
wait: yes
register: ec2
- debug: msg="Seed node {{ ec2.instances[0].private_ip }} --- {{ ec2.instances[0].public_dns_name }}"
- name: Add seed to seeds_public
add_host:
groupname: "seeds_public"
hostname: "{{ ec2.instances[0].public_ip }}"
- name: Add seed to seeds_private
add_host:
groupname: "seeds_private"
hostname: "{{ ec2.instances[0].private_ip }}"
- name: Add public ip to nodes
add_host:
groupname: "nodes"
hostname: "{{ ec2.instances[0].public_ip }}"
- name: Launch Nodes
local_action:
module: ec2
image: "{{ IMAGE }}"
instance_type: "{{ INSTANCE_TYPE }}"
keypair: "{{ KEYPAIR }}"
region: "{{ EC2_REGION }}"
group_id: "{{ NODE_SECURITY_GROUP }}"
vpc_subnet_id: "{{ item }}"
assign_public_ip: yes
instance_tags:
Name: "{{ TAG_NAME }}"
Role: Node
count: 1
wait: yes
register: ec2
with_items:
- "{{ SUBNET1 }}"
- name: Add public ip to nodes
add_host:
groupname: "nodes"
hostname: "{{ item.instances[0].public_ip }}"
with_items: "{{ ec2.results }}"
- name: Wait for SSH to come up
wait_for:
host: "{{ item.instances[0].public_dns_name }}"
port: 22
delay: 60
timeout: 320
state: started
with_items: "{{ ec2.results }}"
- name: Setup ConductR
hosts: nodes
user: "{{ REMOTE_USER }}"
gather_facts: True
sudo: True
# Get these from env to workaround https://github.com/ansible/ansible/issues/10638
vars:
aws_access_key: "{{ lookup('env','AWS_ACCESS_KEY_ID') }}"
aws_secret_key: "{{ lookup('env','AWS_SECRET_ACCESS_KEY') }}"
vars_files:
- "{{ VARS_FILE }}"
tasks:
- include: java/tasks/main.yml
- include: haproxy/tasks/main.yml
- include: conductr/tasks/main.yml