GCP에서 VM Manager가 활성화가 된 경우, 

콘솔의 os info에서 설치된 package 리스트 및 버전 조회가 가능하다.

또한, 아래의 gcloud 와 api로도 전체 리스트 조회가 가능하다.

 

- gcloud: 아래와 같이 VM 이름과 zone 정보를 넣고 view 파라미터를 full로하면 된다.
gcloud compute os-config inventories describe {VM이름/ID)--location={Zone정보} --view=full

출력 예제:

...

PACKAGE_NAME: google-guest-agent
ARCHITECTURE: x86_64
VERSION: 20220622.00-0ubuntu2~18.04.0
...
 
https://cloud.google.com/sdk/gcloud/reference/compute/os-config/inventories/describe

 

- API: 아래와 같이 Name에 project, location, instance 정보를 넣고 view 파라마터에 FULL로하면 된다.

curl \
  'https://osconfig.googleapis.com/v1/projects/{프로젝트ID}/locations/{Zone}/instances/{VM이름/ID}/inventory?view=FULL&key=[YOUR_API_KEY]' \
  --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
  --header 'Accept: application/json' \
  --compressed
 
출력 예제:
...
"installedPackage-google-guest-agent:x86_64:20210629.00-0ubuntu1~18.04.1": {
      "id": "installedPackage-google-guest-agent:x86_64:20210629.00-0ubuntu1~18.04.1",
      "originType": "INVENTORY_REPORT",
      "type": "INSTALLED_PACKAGE",
      "installedPackage": {
        "aptPackage": {
          "architecture": "x86_64",
          "version": "20210629.00-0ubuntu1~18.04.1",
          "packageName": "google-guest-agent"
        }
...
 
https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.instances.inventories/get