Skip to content

Commit 6d92482

Browse files
authored
Add variable for SSH config file (#107)
1 parent 92453aa commit 6d92482

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ PLUGINS_CONFIG = {
8787
"USERNAME": "foo",
8888
"PASSWORD": "bar",
8989
"AUTH_SECONDARY": "foobar", # define here password for accessing Privileged EXEC mode, this variable is optional
90+
"PATH_TO_SSH_CONFIG_FILE": "/home/.ssh/config", # define here PATH to SSH config file, it will be used for device connections, this variable is optional
9091
},
9192
}
9293
```

netbox_config_diff/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__author__ = "Artem Kotik"
44
__email__ = "[email protected]"
5-
__version__ = "2.11.0"
5+
__version__ = "2.12.0"
66

77

88
class ConfigDiffConfig(PluginConfig):
@@ -19,6 +19,7 @@ class ConfigDiffConfig(PluginConfig):
1919
"USER_SECRET_ROLE": "Username",
2020
"PASSWORD_SECRET_ROLE": "Password",
2121
"SECOND_AUTH_SECRET_ROLE": "Second Auth",
22+
"PATH_TO_SSH_CONFIG_FILE": "",
2223
}
2324

2425

netbox_config_diff/models/data_models.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from dataclasses import dataclass
33

44
from dcim.models import Device
5+
from netbox.plugins import get_plugin_config
56
from scrapli import AsyncScrapli
67

78
from netbox_config_diff.choices import ConfigComplianceStatusChoices
@@ -35,7 +36,7 @@ def __str__(self) -> str:
3536
return self.name
3637

3738
def to_scrapli(self) -> dict:
38-
return {
39+
sccrapli_dict = {
3940
"host": self.mgmt_ip,
4041
"auth_username": self.username,
4142
"auth_password": self.password,
@@ -82,6 +83,12 @@ def to_scrapli(self) -> dict:
8283
},
8384
}
8485

86+
ssh_config = get_plugin_config("netbox_config_diff", "PATH_TO_SSH_CONFIG_FILE")
87+
if ssh_config:
88+
sccrapli_dict["ssh_config_file"] = ssh_config
89+
90+
return sccrapli_dict
91+
8592
def get_status(self) -> str:
8693
if self.error:
8794
return ConfigComplianceStatusChoices.ERRORED

0 commit comments

Comments
 (0)