arista-eosplus/rbeapi

wildcard connection config

Closed this issue · 5 comments

Looking at the code, the [connection:*] is used when there are no explicit name matches. However, I think it's more useful to use it as a 'base' configuration. Setting from other explicit matches will be merged with the wildcard match.

For example:

[connection:*]
username: eapi
password: mysecret

[connection:veos1]
192.168.1.1

[connection:veos2]
192.168.1.2

The configuration for veos1 should be:

{
   'username' => 'eapi',
   'password' => 'mysecret',
   'host' => '192.168.1.1'
}

Right now, the username and password is needed for each switch even though they all have the same credentials.

ibawt commented

sounds like a job for yaml.

You can just create a default section to set values that you want to be the defaults. To default username and password I add the following to the start of my .eapi.conf file:

[DEFAULT]
username: admin
password: admin

Does this address your needs?

I can't get that to work.

[DEFAULT]
username: foo
password: bar

[connection:router1]
host: 192.168.1.2
#<Rbeapi::Client::Node:0x007f69217c7270 @connection=#<Rbeapi::Eapilib::HttpsEapiConnection:0x007f69217c73b0 @transport=#<Net::HTTP 192.168.1.2:443 open=false>, @error=nil, @username="admin", @password="", @open_timeout=10, @read_timeout=10>, @autorefresh=true>

I ended up using

[connection:*]
username: foo
password: bar

and just pass the host name

Rbeapi::Client.connect_to(host)

This way, I don't need an entry per host in the .eapi.conf file.

Not supporting

[DEFAULT]
username: foo
password: bar

[connection:router1]
host: 192.168.1.2

Is an issue. Need to fix this to get .eapi.conf semantics consistent across *eapi libraries.