cassandra—解析ruby/inspec中的casandra.yaml以获得seeds值

ycggw6v2  于 2021-06-13  发布在  Cassandra
关注(0)|答案(2)|浏览(314)

如何在ruby(inspec)概要文件中解析cassandra.yaml中的以下yaml以获得seeds值。我想得到所有的3个ip地址在一个刺或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"
hivapdat

hivapdat1#

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

l5tcr1uw

l5tcr1uw2#

也许有更好的方法,但这会奏效:

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"

相关问题