-
Notifications
You must be signed in to change notification settings - Fork 2
/
provision.yml
83 lines (76 loc) · 2.53 KB
/
provision.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
---
- name: Configuring environment
hosts: localhost
connection: local
vars_files:
- group_vars/spark/vars
- group_vars/spark/secret_vars
vars:
count: '{{ cluster_size - 1 }}'
tasks:
- name: creating Spark servers
linode.cloud.instance:
label: '{{ instance_prefix }}{{ item | int + 1 }}-{{ uuid }}'
api_token: '{{ token_password }}'
type: '{{ type }}'
region: '{{ region }}'
image: '{{ image }}'
root_pass: '{{ root_pass }}'
authorized_keys: '{{ ssh_keys }}'
private_ip: true
stackscript_id: 1407256
ua_prefix: 'marketplace-spark-occ'
tags: '{{ linode_tags }}'
state: present
register: linode
with_sequence: count='{{ count }}'
- name: Get info about an instance by label
linode.cloud.instance_info:
api_token: '{{ token_password }}'
label: '{{ instance_prefix }}{{ item | int }}-{{ uuid }}'
register: info
with_sequence: count='{{ cluster_size | int }}'
- name: update group_vars
blockinfile:
path: ./group_vars/spark/vars
marker: "# {mark} INSTANCE VARS"
block: |
#jinja2: trim_blocks:False
spark_data:
server:
{%- for server in range(cluster_size) %}
- spark{{ server + 1 }}:
instance:
hostname: spark{{ server + 1 }}
ip_pub1: {{ info.results[server].instance.ipv4[0] }}
ip_priv1: {{ info.results[server].instance.ipv4[1] }}
{%- endfor %}
- name: write spark password to group_vars
blockinfile:
path: ./group_vars/spark/vars
insertafter: EOF
block: |
#jinja2: trim_blocks:False
# Spark UI Password
spark_ui_password: {{ lookup('password', '/dev/null length=25 chars=ascii_letters,digits') }}
- name: update inventory
blockinfile:
path: ./hosts
marker: "# {mark} SPARK NODES"
block: |
#jinja2: trim_blocks:False
[spark_master]
localhost ansible_connection=local user=root
[spark_workers]
{%- for server in range(count | int) %}
{{ info.results[server + 1].instance.ipv4[0] }}
{%- endfor %}
- name: wait for port 22 to become open
wait_for:
port: 22
host: '{{ item.instance.ipv4[0] }}'
search_regex: OpenSSH
delay: 10
connection: local
with_items:
- "{{ info.results }}"