1

How do I parse the following yaml from Cassandra.yaml in Ruby (InSpec) profile to get the seeds value. I would to get all the 3 Ipaddress in one sting or the 3 IP addresses in 3 strings.

seed_provider:

- 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"
zxcvb
  • 11
  • 1

2 Answers2

1

Maybe there are better ways, but this would work:

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"
Robin
  • 866
  • 7
  • 19
0

You could try the file resource or yaml resource in InSpec.

kmf
  • 121
  • 4