forked from GoogleCloudPlatform/cluster-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartup_from_network_storage.tf
65 lines (57 loc) · 2.28 KB
/
startup_from_network_storage.tf
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
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
# This file is meant to be reused by multiple modules.
# "inputs":
# local.native_fstype : list of file systems that are supported automatically, but looking at the metadata.
# var.network_storage : to be passed into metadata somewhere else (not here)
# var.startup_script : to be changed into a more complete file system with all the fs runners
# "outputs":
# local.startup_from_network_storage : A full startup script with all the runners that are not supported
# natively and were included in the network_storage structure
locals {
startup_script_network_storage = [
for ns in var.network_storage :
ns if !contains(local.native_fstype, ns.fs_type)
]
# Pull out runners to include in startup script
storage_client_install_runners = [
for ns in local.startup_script_network_storage :
ns.client_install_runner if ns.client_install_runner != null
]
mount_runners = [
for ns in local.startup_script_network_storage :
ns.mount_runner if ns.mount_runner != null
]
startup_script_runner = [{
content = var.startup_script != null ? var.startup_script : "echo 'No user provided startup script.'"
destination = "passed_startup_script.sh"
type = "shell"
}]
full_runner_list = concat(
local.storage_client_install_runners,
local.mount_runners,
local.startup_script_runner
)
startup_from_network_storage = module.netstorage_startup_script.startup_script
}
module "netstorage_startup_script" {
source = "../../scripts/startup-script"
labels = local.labels
project_id = var.project_id
deployment_name = var.deployment_name
region = var.region
runners = local.full_runner_list
}