-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-top.py
56 lines (49 loc) · 1.41 KB
/
wp-top.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
# NETWORK_NAME = 'global var.'
def GenerateConfig(context):
"""WordPress - top level templates."""
NETWORK_NAME = 'net-' + context.env['deployment']
VM_NAME = 'vm-' + context.env['deployment']
MYSQL_NAME = 'mysql-' + context.env['deployment']
resources = [{
'name': VM_NAME,
'type': 'vm-template.py',
'properties': {
'machineType': 'n1-standard-1',
'zone': 'us-central1-f',
'network': NETWORK_NAME,
'metadata-from-file':
{ 'startup-script': 'll.conf' }
}
}, {
'name': NETWORK_NAME,
'type': 'network-template.py'
}, {
'name': NETWORK_NAME + '-fw',
'type': 'firewall-template.py',
'properties': {
'network': NETWORK_NAME
}
}, {
'name': MYSQL_NAME,
'type': 'mysql-template.py',
'properties': {
'failover' : False,
'cloudsql': {
'zone': 'us-central1-f'
},
'wp': {
'wp-user-name': 'wp'
}
}
}]
outputs = [{
'name': 'VM-IP',
'value': '$(ref.' + VM_NAME + '.networkInterfaces[0].accessConfigs[0].natIP)'
}, {
'name': 'mysql-connectionName',
'value': ''.join(['$(ref.', MYSQL_NAME, '.connectionName)'])
}, {
'name': 'mysql-IP',
'value': ''.join(['$(ref.', MYSQL_NAME, '.ipAddresses[0].ipAddress)'])
}]
return {'resources': resources, 'outputs': outputs }