I have a machine.yml file as follows:
---
machines:
A:
ip: ABC
pass: vass
user: A
B:
ip: XYZ
pass: grass
user: B
C:
ip: klm
pass: pass
user: C
I tried to parse the above file as follows:
machines = YAML.load_file('machine.yml')
machines = machines['machines']
## Iterate through entries in YAML file
machines.each_value do |machines|
var = [machines["A"]["ip"], machines["A"]["pass"], machines["B"]["ip"],machines["B"]["pass"], machines["C"]["ip"],machines["C"]["pass"]]
# var should have all the values
end
The "var" should contain all the values as a string. But I am not able execute the above piece as it's throwing errors. How can I parse all the values of YAML separately?