Closed angelnu closed 2 years ago
Examples from my homelab:
resource "vyos_config_block_tree" "dhcp_server" {
path = "service dhcp-server shared-network-name LAN subnet 192.168.200.0/24"
configs = {
"default-router"= "192.168.200.1",
"domain-name"= "vyos.net",
"lease"= "86400",
"name-server"= "192.168.200.1",
"range foo start" = "192.168.200.9",
"range foo stop"= "192.168.200.254"
}
}
resource "vyos_config_block_tree" "interfaces" {
path = "interfaces"
configs = {
"ethernet eth0 address" = "dhcp"
"ethernet eth0 description" = "OUTSIDE"
"ethernet eth0 vif 2 address" = "dhcp"
"ethernet eth0 vif 2 description" = "lte"
"ethernet eth1 address" = "192.168.200.1/24"
"ethernet eth1 description" = "INSIDE"
}
}
The second one was a result of terraform import module.vyos.vyos_config_block_tree.interfaces "interfaces"
just to test that I could import a complex tree.
This add config_block_tree that defines a config block including all its children. It can be used to import full config trees.
NOTE: it depends on the array support changed made by @thomasfinstad at https://github.com/thomasfinstad/vyos-client-go I could make it work without them but ideally we would merge his changes first.
I have not done any real testing of my code there, and might try to merge the map and array functions together at some point, but if @Foltik wish to pull it in that is fine with me.
Looks good to me, thanks for the contribution! Going to test this on my end and merge shortly.
Great @Foltik - please notice that I made a change to support empty values -> https://github.com/thomasfinstad/vyos-client-go/pull/1
This add config_block_tree that defines a config block including all its children. It can be used to import full config trees.
NOTE: it depends on the array support changed made by @thomasfinstad at https://github.com/thomasfinstad/vyos-client-go I could make it work without them but ideally we would merge his changes first.