Here I have a small question about how to find a value in a structured file using Ansible. I've seen lineinfile but I'm not pretty sure that it will be helpful. If we assume that my file looks like this (in fact it's way way longer but for evident reasons I cannot post it here ^^)
################## junos.conf ##################
system {
auto-snapshot;
root-authentication {
encrypted-password ## SECRET-DATA
}
services {
ssh;
netconf ssh;
scp;
}
syslog {
user * {
any emergency;
}
file messages {
any notice;
authorization info;
}
file interactive-commands {
interactive-commands any;
}
}
processes {
dhcp-service {
traceoptions {
file dhcp_logfile size 10m;
level all;
flag all;
}
}
}
}
interfaces {
irb {
unit 0 {
family inet {
dhcp {
vendor-id Juniper-ex4300-48t;
}
}
}
}
vme {
unit 0 {
family inet {
address 172.0.0.1/24
}
}
}
}
forwarding-options {
storm-control-profiles default {
all;
}
}
vlans {
default {
vlan-id 1;
l3-interface irb.0;
}
}
It's a .conf
file but it looks like a structured file. Imagine, I want to find a way to get the value interfaces->vme->unit 0->family inet
within an Ansible playbook, how could I do ? Which parser could I use in Ansible ?
I've already read this page but I don't really know which parser to use and how to use it : https://docs.ansible.com/ansible/latest/network/user_guide/cli_parsing.html
Thanks, Max