-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgen_influxdb_gce.py
56 lines (47 loc) · 1.64 KB
/
gen_influxdb_gce.py
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
import sys
from package.generate_conf import setup_configurations, get_inventory_path, merge_and_delete_ini_files
from package.execute_command import run_ansible_playbook
if len(sys.argv) != 2:
print('didn\'t get playbook path')
sys.exit(1)
playbook_path = sys.argv[1]
default_dir = 'playbook'
project_id = 'project-id'
region = 'asia-east1'
group_vars = {
'project_id' : project_id,
'region' : region,
}
inventory_vars = {
'group' : 'influxdb',
'hosts' :
[
{"hostname": "influxdb", "IP": "10.140.0.28", "zone": "asia-east1-b"},
]
}
instance_vars = {
'machine_type' : 'e2-medium',
'boot_disk_size' : '20',
'boot_disk_type' : 'pd-standard',
'attach_disk_size': '20',
'attach_disk_type': 'pd-standard',
'mount_path' : '/home/influxdb',
'scopes' : 'default',
'subnet' : 'projects/project-id/regions/asia-east1/subnetworks/asia-east1',
'labels': {
'env': 'dev',
},
'tags': ['dev', 'test'],
}
monitor_vars = {
'enabled_node_exporter': 'true',
}
configurations = {
'group_vars' : (group_vars, 'group_vars/all/env.j2', 'group_vars/all/env.yml'),
'inventory' : (inventory_vars, 'inventory/inventory.j2', 'inventory/inventory.yml'),
'instance' : (instance_vars, 'vars/instance/instance_var.j2', 'vars/instance/vars.yml'),
'monitor' : (monitor_vars, 'vars/monitor/monitor_var.j2', 'vars/monitor/vars.yml')
}
setup_configurations(configurations)
inventory_path = get_inventory_path(configurations)
run_ansible_playbook(inventory_path, playbook_path)