Skip to content

added inventory defaults ++ extras#3

Merged
hellt merged 8 commits intohellt:masterfrom
carlmontanari:inventory_things
Jul 10, 2021
Merged

added inventory defaults ++ extras#3
hellt merged 8 commits intohellt:masterfrom
carlmontanari:inventory_things

Conversation

@carlmontanari
Copy link
Contributor

Sorry for PR without checking if you're even interested in this -- was just playing about with commando and had this so figured I'd raise this just in case you were interested!

TL;DR -- added defaults and "extras" to inventory yaml.

Defaults: fairly self explanatory -- figured rather than having to have username/password entered for every device having a default setting would be cool. The implementation is pretty basic -- just load a slice of options with the defaults coming first -- that way any device specific settings override the defaults.

Extras: could do without the "extras" parent, but basically its just "extra" stuff... hence the name. Things that folks probably wouldn't mess with too often -- port, auth strict key (I left false as the default, but now users can turn it on if they want), transport type (you know I love me the system transport! though this of course could break for windows users), ssh config file, and the secondary password (so we can deal with "enable" passwords).

Carl

@hellt
Copy link
Owner

hellt commented Jul 10, 2021

Hey man, that is an awesome addition
I actually was thinking about something similar, but I wanted to take it even a tad further.
What do you say to the idea where a user can defined a set of credentials and transports, so that commando can use any of them and swap one with another.

Here is the rough config that shows that idea:

credentials:
  sros-pwd:
    username: admin
    password: admin
  arista-key-based:
    username: admin
    private-key: /some/key.pub
    
transports:
  default:
    port: 22 # defaults to 22
    ssh-config-file: /some/config # defaults to "~/.ssh/config"
    strict-key: false # defaults to false
    transport-type: standard # defaults to standard
  custom:
    port: 50022
    strict-key: true

devices:
  sros:
    platform: nokia_sros
    address: clab-scrapli-sros
    credentials: sros-pwd # refer to one of the configured credentials (if not specified, credentials["default"] is assumed)
    # omitting transport means apply transport defaults
    send-commands:
      - show version
      - show router interface
  eos:
    platform: arista_eos
    address: clab-scrapli-ceos
    credentials: arista-key-based
    transport: custom
    send-commands:
      - show version
      - show uptime

What do you think?

@carlmontanari
Copy link
Contributor Author

Dig it, will try to make this happen today 😁 !

@carlmontanari
Copy link
Contributor Author

Just pushed another update. Sorta ended up having a fair few changes that maybe should have been their own PR (sorry! I can break stuff out if you prefer!).

  • Updated go.mod to point to latest main branch of scrapligo -- this included some minor fixes in the standard transport (like actually having logging work 😄 )
  • Modified inventory to be like how you outlined -- we now have transports and credentials sections
  • transports has some sane defaults, but users can set a few options in there to tweak things as desired
  • credentials of course doesn't have defaults but users can set a "default" credentials entry that will auto apply to all devices unless they specify another "credentials" name in the device settings
  • im not entirely positive I did the right thing in the runCommands section, but basically if the connection failed to open we would just panic -- so I return nil on the channel prior to returning out of the goroutine -- this seems to make things behave nicely however obviously breaks printing output....
  • added private writeFailure and writeSuccess methods in the response writer to do ... like what they sound like they do!
  • updated the demo inventory file to show some more stuff/options
  • removed the username/password from devices directly -- now they'll always need to be set via the credentials section

@hellt hellt merged commit 122a905 into hellt:master Jul 10, 2021
@carlmontanari carlmontanari deleted the inventory_things branch July 6, 2022 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants