foltik / terraform-provider-vyos

VyOS Router Provider for Terraform (WIP)
MIT License
18 stars 7 forks source link

Setting dhcp-server requires multiple commands in a session #6

Closed angelnu closed 2 years ago

angelnu commented 2 years ago

Thanks for your provider!

As as I am trying to move all my settings to be set by Terraform I noticed that I am not able to set the dchp-server. This are the commands (derived from the getting started documentation):

set service dhcp-server shared-network-name LAN subnet 192.168.200.0/24 default-router '192.168.200.1'
set service dhcp-server shared-network-name LAN subnet 192.168.200.0/24 name-server '192.168.200.1'
set service dhcp-server shared-network-name LAN subnet 192.168.200.0/24 domain-name 'vyos.net'
set service dhcp-server shared-network-name LAN subnet 192.168.200.0/24 lease '86400'
set service dhcp-server shared-network-name LAN subnet 192.168.200.0/24 range 0 start 192.168.200.9
set service dhcp-server shared-network-name LAN subnet 192.168.200.0/24 range 0 stop '192.168.200.254'

The problem is the range which is mandatory - it has to be set the same commit as the rest.

I might have overseen how to do it but if we would allow config to be an array of path,value tuples then we could use the support in the vyos API to execute multiple sets in the same session:

curl -k --location --request POST 'https://vyos/configure' \ --form data='[{"op": "set","path":["interfaces","vxlan","vxlan1","remote","203.0.113.99"]}, {"op": "set","path":["interfaces","vxlan","vxlan1","vni","1"]}]' \ --form key='MY-HTTPS-API-PLAINTEXT-KEY'

response: { "success": true, "data": null, "error": null }

I can help with a PR - I am familiar with golang and terraform but not with building local providers - but I should be able to tackle it if you are interested.

angelnu commented 2 years ago

I see that we have already support for multiple sets in the vyos go client -> SetTree

So I am not trying to make vyos_config_block to work with keys in configs that have spaces.

angelnu commented 2 years ago

Fixed by #8