Update ssh_config to accept file path
This commit is contained in:
parent
fa8b07e452
commit
d1ff8e2dca
3 changed files with 19 additions and 14 deletions
|
@ -604,11 +604,14 @@ Enabling jump host setting
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
Bastion/jump host with netconf connection can be enable using
|
Bastion/jump host with netconf connection can be enable using
|
||||||
- Setting Ansible variable``ansible_netconf_ssh_config`` or
|
- Setting Ansible variable``ansible_netconf_ssh_config`` either to ``True`` or custom ssh config file path
|
||||||
- Setting environment variable ``ANSIBLE_NETCONF_SSH_CONFIG`` or
|
- Setting environment variable ``ANSIBLE_NETCONF_SSH_CONFIG`` to ``True`` or custom ssh config file path
|
||||||
- Setting ``ssh_config=Ture`` under ``netconf_connection`` section in ansible configuration file
|
- Setting ``ssh_config = 1`` or ``ssh_config = <ssh-file-path>``under ``netconf_connection`` section
|
||||||
|
|
||||||
The ssh config file (~/.ssh/config) should have the correct proxycommand and required ssh configuration variables
|
If the configuration variable is set to 1 the proxycommand and other ssh variables are read from
|
||||||
|
default ssh config file (~/.ssh/config).
|
||||||
|
If the configuration variable is set to file path the proxycommand and other ssh variables are read
|
||||||
|
from the given custom ssh file path
|
||||||
|
|
||||||
Example ssh config file (~/.ssh/config)
|
Example ssh config file (~/.ssh/config)
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
|
@ -1633,11 +1633,12 @@ YAML_FILENAME_EXTENSIONS:
|
||||||
key: yaml_valid_extensions
|
key: yaml_valid_extensions
|
||||||
type: list
|
type: list
|
||||||
NETCONF_SSH_CONFIG:
|
NETCONF_SSH_CONFIG:
|
||||||
description: This variable is used to enable bastion/jump host with netconf connection. The bastion/jump
|
description: This variable is used to enable bastion/jump host with netconf connection. If set to True the bastion/jump
|
||||||
host ssh settings should be present in ssh configuration file (~/.ssh/config).
|
host ssh settings should be present in ~/.ssh/config file, alternatively it can be set
|
||||||
|
to custom ssh configuration file path to read the bastion/jump host settings.
|
||||||
env: [{name: ANSIBLE_NETCONF_SSH_CONFIG}]
|
env: [{name: ANSIBLE_NETCONF_SSH_CONFIG}]
|
||||||
ini:
|
ini:
|
||||||
- {key: ssh_config, section: netconf_connection}
|
- {key: ssh_config, section: netconf_connection}
|
||||||
yaml: {key: netconf_connection.ssh_config}
|
yaml: {key: netconf_connection.ssh_config}
|
||||||
type: boolean
|
default: None
|
||||||
...
|
...
|
||||||
|
|
|
@ -153,11 +153,12 @@ options:
|
||||||
env:
|
env:
|
||||||
- name: ANSIBLE_PERSISTENT_COMMAND_TIMEOUT
|
- name: ANSIBLE_PERSISTENT_COMMAND_TIMEOUT
|
||||||
netconf_ssh_config:
|
netconf_ssh_config:
|
||||||
type: boolean
|
default: None
|
||||||
default: False
|
|
||||||
description:
|
description:
|
||||||
- This variable is used to enable bastion/jump host with netconf connection. The bastion/jump
|
- This variable is used to enable bastion/jump host with netconf connection. If set to
|
||||||
host ssh settings should be present in ssh configuration file (~/.ssh/config).
|
True the bastion/jump host ssh settings should be present in ~/.ssh/config file,
|
||||||
|
alternatively it can be set to custom ssh configuration file path to read the
|
||||||
|
bastion/jump host settings.
|
||||||
ini:
|
ini:
|
||||||
- section: netconf_connection
|
- section: netconf_connection
|
||||||
key: ssh_config
|
key: ssh_config
|
||||||
|
@ -175,7 +176,7 @@ import json
|
||||||
|
|
||||||
from ansible.errors import AnsibleConnectionFailure, AnsibleError
|
from ansible.errors import AnsibleConnectionFailure, AnsibleError
|
||||||
from ansible.module_utils._text import to_bytes, to_native, to_text
|
from ansible.module_utils._text import to_bytes, to_native, to_text
|
||||||
from ansible.module_utils.parsing.convert_bool import BOOLEANS_TRUE
|
from ansible.module_utils.parsing.convert_bool import BOOLEANS_TRUE, BOOLEANS_FALSE
|
||||||
from ansible.plugins.loader import netconf_loader
|
from ansible.plugins.loader import netconf_loader
|
||||||
from ansible.plugins.connection import NetworkConnectionBase
|
from ansible.plugins.connection import NetworkConnectionBase
|
||||||
|
|
||||||
|
@ -202,7 +203,7 @@ NETWORK_OS_DEVICE_PARAM_MAP = {
|
||||||
"ce": "huawei"
|
"ce": "huawei"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import q
|
||||||
class Connection(NetworkConnectionBase):
|
class Connection(NetworkConnectionBase):
|
||||||
"""NetConf connections"""
|
"""NetConf connections"""
|
||||||
|
|
||||||
|
@ -266,7 +267,7 @@ class Connection(NetworkConnectionBase):
|
||||||
ssh_config = self.get_option('netconf_ssh_config')
|
ssh_config = self.get_option('netconf_ssh_config')
|
||||||
if ssh_config in BOOLEANS_TRUE:
|
if ssh_config in BOOLEANS_TRUE:
|
||||||
ssh_config = True
|
ssh_config = True
|
||||||
else:
|
elif ssh_config in BOOLEANS_FALSE:
|
||||||
ssh_config = None
|
ssh_config = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue