2017-05-30 11 views
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から取得しました。

インスタンスが作成され、起動スクリプトを手動で貼り付けると、問題なく動作します。

誰も私がここで間違っていることを知っていますか?

答えて

0

これは機能します。私の問題はユーザーアカウントに関連していました。私は既定のユーザーとしてログインしていませんでした(たとえば[email protected])。

この質問を読んでいる場合は、これを実行してそれに応じて管理する予定のユーザー名を確認してください。

関連する問題