0
我有我的Python腳本定義了以下啓動腳本變量:GCE啓動的啓動腳本不點火
default_startup_script = """
#! /bin/bash
cd ~/git/gcloud;
git config --global user.email "[email protected]";
git config --global user.name "my.name";
git stash;
git pull https://user:[email protected]/url/my_repo.git;
"""
和以下配置:
config = {
"name": "instance-bfb6559d-788f-48b7-85a3-8ff3ab6e5a60",
"zone": "projects/username-165421/zones/us-east1-b",
"machineType": "projects/username-165421/zones/us-east1-b/machineTypes/f1-micro",
"metadata": {
"items": [{'key':'startup-script','value':default_startup_script}]
},
"tags": {
"items": [
"http-server",
"https-server"
]
},
"disks": [
{
"type": "PERSISTENT",
"boot": True,
"mode": "READ_WRITE",
"autoDelete": True,
"deviceName": "instance-4",
"initializeParams": {
"sourceImage": "projects/username-165421/global/images/image-id",
"diskType": "projects/username-165421/zones/us-east1-b/diskTypes/pd-standard",
"diskSizeGb": "10"
}
}
],
"canIpForward": False,
"networkInterfaces": [
{
"network": "projects/username-165421/global/networks/default",
"subnetwork": "projects/username-165421/regions/us-east1/subnetworks/default",
"accessConfigs": [
{
"name": "External NAT",
"type": "ONE_TO_ONE_NAT"
}
]
}
],
"description": "",
"labels": {},
"scheduling": {
"preemptible": False,
"onHostMaintenance": "MIGRATE",
"automaticRestart": True
},
"serviceAccounts": [
{
"email": "[email protected]",
"scopes": [
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring.write",
"https://www.googleapis.com/auth/servicecontrol",
"https://www.googleapis.com/auth/service.management.readonly",
"https://www.googleapis.com/auth/trace.append"
]
}
]
}
現在 - 實例創建沒有問題,但啓動腳本不會觸發。
我通過運行在創建實例:
compute.instances().insert(
project=project,
zone=zone,
body=config).execute()
所有樣品都來自here檢索。
一旦創建了實例並手動粘貼我的啓動腳本,它就可以正常工作。
有沒有人有任何想法我在做什麼錯在這裏?