1

如何在 Ruby (InSpec) 配置文件中解析 Cassandra.yaml 中的以下 yaml 以获取种子值。我会在一个字符串中获取所有 3 个 Ipaddress 或在 3 个字符串中获取 3 个 IP 地址。

种子提供者:

- class_name: org.apache.cassandra.locator.SimpleSeedProvider

  parameters:

      # seeds is actually a comma-delimited list of addresses.

      # Ex: "<ip1>,<ip2>,<ip3>"

      - seeds: "10.0.0.1, 10.0.0.2, 10.0.0.3"
4

2 回答 2

1

也许有更好的方法,但这会起作用:

require 'yaml'

config = YAML.load_file("/path/cassandra.yml")[0]
config.dig("parameters").first['seeds']
# => "10.0.0.1, 10.0.0.2, 10.0.0.3"
于 2020-08-02T21:33:35.810 回答
0

您可以尝试 InSpec 中的文件资源或yaml资源。

于 2020-08-13T05:32:48.403 回答