本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
get_json
重要
AWS OpsWorks Stacks 服務已於 2024 年 5 月 26 日終止,並已針對新客戶和現有客戶停用。我們強烈建議客戶盡快將其工作負載遷移至其他解決方案。如果您對遷移有任何疑問,請透過 AWS re:Post
傳回 Chef 執行的相關資訊做為 JSON 物件。
sudo opsworks-agent-cli get_json [
activity
] [date
] [-i | --internal | --no-i | --no-internal]
根據預設,get_json
會顯示客戶針對最近 Chef 執行所提供的資訊。使用下列選項來指定一組特定的資訊。
- activity
-
顯示與最近指定活動相關聯之 Chef 執行的資訊。若要取得有效的活動清單,請執行 list_commands。
- date
-
顯示與在指定時間戳記執行的活動相關聯之 Chef 執行的資訊。若要取得有效的時間戳記清單,請執行 list_commands。
- -i, --internal
-
顯示 AWS OpsWorks Stacks 內部用於 Chef 執行的資訊。
- --no-i, --no-internal
-
明確顯示客戶針對 Chef 執行所提供的資訊。如果未指定其他選項,這會是預設值。
注意
若是 Chef 12 Linux 執行個體,執行此命令將傳回有效的資訊,例如執行個體的堆疊組態和部署屬性。不過,若要取得更完整的資訊,請參閱 AWS OpsWorks Stacks 在執行個體上建立的 Chef 資料包。如需詳細資訊,請參閱 AWS OpsWorks Stacks Data Bag 參考。
下列輸出範例會顯示客戶針對最近設定活動之 Chef 執行所提供的資訊。
$ sudo opsworks-agent-cli get_json configure
{
"run_list": [
"recipe[opsworks_cookbook_demo::configure]"
]
}
下列輸出範例顯示 AWS OpsWorks Stacks 在內部用於針對指定時間戳記執行之 Chef 執行的資訊。
$ sudo opsworks-agent-cli get_json 2015-12-01T18:20:24 -i
{
"aws_opsworks_agent": {
"version": "4004-20151201152533",
"valid_client_activities": [
"reboot",
"stop",
"deploy",
"grant_remote_access",
"revoke_remote_access",
"update_agent",
"setup",
"configure",
"update_dependencies",
"install_dependencies",
"update_custom_cookbooks",
"execute_recipes",
"sync_remote_users"
],
"command": {
"type": "configure",
"args": {
"app_ids": [
]
},
"sent_at": "2015-12-01T18:19:23+00:00",
"command_id": "5c2113f3-c6d5-40eb-bcfa-77da2885eeEX",
"iam_user_arn": null,
"instance_id": "cfdaa716-42fe-4e3b-9762-fef184ddd8EX"
},
"resources": {
"apps": [
],
"layers": [
{
"layer_id": "93f50d83-1e73-45c4-840a-0d4f07cda1EX",
"name": "MyCookbooksDemoLayer",
"packages": [
],
"shortname": "cookbooks-demo",
"type": "custom",
"volume_configurations": [
]
}
],
"instances": [
{
"ami_id": "ami-d93622EX",
"architecture": "x86_64",
"auto_scaling_type": null,
"availability_zone": "us-west-2a",
"created_at": "2015-11-18T00:21:05+00:00",
"ebs_optimized": false,
"ec2_instance_id": "i-a480e960",
"elastic_ip": null,
"hostname": "cookbooks-demo1",
"instance_id": "cfdaa716-42fe-4e3b-9762-fef184ddd8EX",
"instance_type": "c3.large",
"layer_ids": [
"93f50d83-1e73-45c4-840a-0d4f07cda1EX"
],
"os": "Amazon Linux 2015.09",
"private_dns": "ip-192-0-2-0.us-west-2.compute.internal",
"private_ip": "10.122.69.33",
"public_dns": "ec2-203-0-113-0.us-west-2.compute.amazonaws.com",
"public_ip": "192.0.2.0",
"root_device_type": "ebs",
"root_device_volume_id": "vol-f6f7e8EX",
"ssh_host_dsa_key_fingerprint": "f2:...:15",
"ssh_host_dsa_key_public": "ssh-dss AAAAB3Nz...a8vMbqA=",
"ssh_host_rsa_key_fingerprint": "0a:...:96",
"ssh_host_rsa_key_public": "ssh-rsa AAAAB3Nz...yhPanvo7",
"status": "online",
"subnet_id": null,
"virtualization_type": "paravirtual",
"infrastructure_class": "ec2",
"ssh_host_dsa_key_private": "-----BEGIN DSA PRIVATE KEY-----\nMIIDVwIB...g5OtgQ==\n-----END DSA PRIVATE KEY-----\n",
"ssh_host_rsa_key_private": "-----BEGIN RSA PRIVATE KEY-----\nMIIEowIB...78kprtIw\n-----END RSA PRIVATE KEY-----\n"
}
],
"users": [
],
"elastic_load_balancers": [
],
"rds_db_instances": [
],
"stack": {
"arn": "arn:aws:opsworks:us-west-2:80398EXAMPLE:stack/040c3def-b2b4-4489-bb1b-e08425886fEX/",
"custom_cookbooks_source": {
"type": "s3",
"url": "https://s3.amazonaws.com/amzn-s3-demo-bucket/opsworks-cookbook-demo.tar.gz",
"username": "AKIAJUQN...WG644EXA",
"password": "O5v+4Zz+...rcKbFTJu",
"ssh_key": null,
"revision": null
},
"name": "MyCookbooksDemoStack",
"region": "us-west-2",
"stack_id": "040c3def-b2b4-4489-bb1b-e08425886fEX",
"use_custom_cookbooks": true,
"vpc_id": null
},
"ecs_clusters": [
],
"volumes": [
]
},
"chef": {
"customer_recipes": [
"opsworks_cookbook_demo::configure"
],
"customer_json": "e30=\n",
"customer_data_bags": "e30=\n"
}
}
}