Fix: bashate E003 warnings
[releng/global-jjb.git] / shell / capture-instance-metadata.sh
index a5914ad..0998dd1 100644 (file)
@@ -17,11 +17,16 @@ if [ -n "${NOMAD_DC}" ]; then
     exit 0
 fi
 
+if [[ ! -f /run/cloud-init/result.json ]]; then
+    echo "INFO: Running in unsupported cloud, no metadata"
+    exit 0
+fi
+
 # AWS not supported, exit
 cloudtype="$(jq -r .v1.datasource /run/cloud-init/result.json)"
 if [[ $cloudtype == "DataSourceEc2Local" ]]; then
-   echo "INFO: Running in AWS, not capturing instance metadata"
-   exit 0
+    echo "INFO: Running in AWS, not capturing instance metadata"
+    exit 0
 fi
 
 # Retrive OpenStack instace metadata APIs at this IP.