【发布时间】:2020-11-10 15:52:28
【问题描述】:
我的gcp 项目中有几个实例正在运行。
所以我需要遍历每个实例并需要获取操作系统版本,如果操作系统版本匹配某个值,我需要执行另一个gcloud命令来获取安装的库。
所以我使用这个命令来遍历每个实例:
$(gcloud compute instances list --format="value(name)")
// which gives the output as below
name: temp-1
---
name: temp-2
---
name: test1
我也需要摆脱name:。
- 我需要使用
/etc/os-release获取每个实例的 linux 发行版(ubuntu、centos/rhel)
是否可以在每个服务器(temp-1、temp-2、test1)中 ssh(没有真正的 ssh-ing)并执行 awk -F= '/^NAME/{print $2}' /etc/os-release 命令并将结果返回到命令行?
【问题讨论】:
标签: google-cloud-platform gcloud