运行以下命令并获取其输出时:
$ knife node show webnode21.domain.tld -a openstack
webnode21.domain.tld:
openstack:
ami_id: ami-88171711
ami_launch_index: 0
ami_manifest_path: /var/os/manifest
block_device_mapping_ami: vdb
block_device_mapping_ebs0: /dev/vdb
block_device_mapping_root: /dev/vdb
block_device_mapping_swap: /dev/vdc
hostname: webnode21.domain.tld
instance_action: none
instance_id: i-11243010
instance_type: small
local_hostname: webnode21.domain.tld
local_ipv4: 192.168.20.101
placement_availability_zone: AZ002
provider: openstack
public_hostname: webnode21.domain.tld
public_ipv4:
public_keys_0_openssh_key: ssh-rsa somekey
reservation_id: r-88x801h
security_groups: default
我希望能够在配方中标记以下属性:hostname,ami_id,security_groups,local_ipv4。我知道你可以使用tag('key:value')进行标记..但是我不知道如何在配方中提取属性并仅标记特定的键/值对。
答案 0 :(得分:0)
最后想出来了。发布答案以防其他人遇到这样的事情:
if node['openstack']['ami_id']
tag("ami_id:#{node['openstack']['ami_id']}")
end