Google cloud platform 如何使用gcloud cli获取操作系统类型
我的Google cloud platform 如何使用gcloud cli获取操作系统类型,google-cloud-platform,gcloud,Google Cloud Platform,Gcloud,我的gcp项目中运行了几个实例 因此,我需要迭代每个实例并获取操作系统版本,如果操作系统版本与某个值匹配,我需要执行另一个gcloud命令来获取已安装的库 因此,我使用此命令迭代每个实例: $(gcloud compute instances list --format="value(name)") // which gives the output as below name: temp-1 --- name: temp-2 --- name: test1 我还需要去
gcp
项目中运行了几个实例
因此,我需要迭代每个实例并获取操作系统版本,如果操作系统版本与某个值匹配,我需要执行另一个gcloud
命令来获取已安装的库
因此,我使用此命令迭代每个实例:
$(gcloud compute instances list --format="value(name)")
// which gives the output as below
name: temp-1
---
name: temp-2
---
name: test1
我还需要去掉名称:
/etc/os-release
有没有可能在每台服务器(temp-1、temp-2、test1)中使用ssh(不使用真正的ssh-ing)并执行
awk-F='/^NAME/{print$2}'/etc/os release
命令,并将结果返回到命令行?我看到了几种方法。您可以使用以下任一命令:
$ gcloud compute ssh --zone us-central1-a instance-1 --command "uname -a"
Linux instance-1 4.19.0-11-cloud-amd64 #1 SMP Debian 4.19.146-1 (2020-09-17) x86_64 GNU/Linux
$ gcloud compute ssh --zone us-central1-a instance-1 -- uname -a
Linux instance-1 4.19.0-11-cloud-amd64 #1 SMP Debian 4.19.146-1 (2020-09-17) x86_64 GNU/Linux
Connection to n.n.n.n closed.
或者,在规模上,您可以使用VM Manager产品: