I have yml file
- id: id1
memberPort: 8080
instance:
name: test
id: q1
site: us
dns: dns1
ip: 1p2
state: available
- id: id2
memberPort: 8080
instance:
name: test2
id: q2
site: us
dns: dns2
ip: ip1
state: available
I want to iterate through this and get the vauls of ip print ip1 and ip2
Tried looking at the examples and got the below code
import yaml
f = open('file.yml')
yaml_file = yaml.safe_load(f)
for entry in yaml_file["id"]:
print yaml_file[id]["ip"])
But it is not working
Any idea how to fix this python Thanks