-
Notifications
You must be signed in to change notification settings - Fork 2
/
provision.yml
107 lines (97 loc) · 3.09 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# create jitsi instnaces
- name: create Jitsi instances
hosts: localhost
vars_files:
- group_vars/jitsi/vars
- group_vars/jitsi/secret_vars
vars:
#jitsi_count: 1
jvb_count: '{{ cluster_size - jitsi_count }}'
tasks:
- name: get info about jitsi meet instances
linode.cloud.instance_info:
api_token: '{{ api_token }}'
label: '{{ jitsi_prefix }}{{ item }}-{{ uuid }}'
register: jitsi_info
with_sequence: count='{{ jitsi_count }}'
# JVB
- name: creating jitsi JVB instances
linode.cloud.instance:
label: '{{ jvb_prefix }}{{ item }}-{{ uuid }}'
api_token: '{{ api_token }}'
type: '{{ jvb_type }}'
region: '{{ region }}'
image: '{{ image }}'
stackscript_id: '1350734'
ua_prefix: 'marketplace-jitsi-occ'
root_pass: '{{ root_pass }}'
authorized_keys: '{{ ssh_keys }}'
private_ip: true
tags: '{{ linode_tags }}'
state: present
with_sequence: count='{{ jvb_count }}'
- name: get info about jitsi JVB instances
linode.cloud.instance_info:
api_token: '{{ api_token }}'
label: '{{ jvb_prefix }}{{ item }}-{{ uuid }}'
register: jvb_info
with_sequence: count='{{ jvb_count }}'
- name: set facts for jitsi meet instance
set_fact:
# Jitsi
# public ips
jitsi_ip1: '{{ jitsi_info.results.0.instance.ipv4[0] }}'
# private ips
jitsi_priv1: '{{ jitsi_info.results.0.instance.ipv4[1] }}'
# updated
- name: update group_vars
blockinfile:
path: ./group_vars/jitsi/vars
marker: "# {mark} INSTANCE VARS"
block: |
#jinja2: trim_blocks:False
jitsi_data:
results:
jitsi:
- jitsi-01:
instance:
hostname: jitsi01
jitsi_ip1: {{ jitsi_ip1 }}
ip_priv1: {{ jitsi_priv1 }}
jvb:
{%- for count in range(jvb_count | int) %}
- jvb-{{ count + 1 }}:
instance:
hostname: jvb{{ count + 1 }}
jitsi_ip1: {{ jvb_info.results[count].instance.ipv4[0] }}
ip_priv1: {{ jvb_info.results[count].instance.ipv4[1] }}
{%- endfor %}
- name: update jvb original cluster size
blockinfile:
path: ./group_vars/jitsi/vars
marker: "# {mark} ORIGINAL-JVB-SIZE"
block: |
# do not update. Modified by provision.yml
original_jvb_cluster_size: {{ jvb_count }}
- name: update inventory
blockinfile:
path: ./hosts
marker: "# {mark} Jitsi LINODES"
block: |
#jinja2: trim_blocks:False
[jitsi_servers]
localhost ansible_connection=local user=root
[jvb_servers]
{%- for count in range(jvb_count | int) %}
{{ jvb_info.results[count].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:
- "{{ jvb_info.results }}"
- "{{ jitsi_info.results }}"