Update ssh_config to accept file path

This commit is contained in:
Ganesh B. Nalawade 2018-07-04 11:37:35 +05:30
parent fa8b07e452
commit d1ff8e2dca
3 changed files with 19 additions and 14 deletions

View file

@ -604,11 +604,14 @@ Enabling jump host setting
--------------------------
Bastion/jump host with netconf connection can be enable using
- Setting Ansible variable``ansible_netconf_ssh_config`` or
- Setting environment variable ``ANSIBLE_NETCONF_SSH_CONFIG`` or
- Setting ``ssh_config=Ture`` under ``netconf_connection`` section in ansible configuration file
- Setting Ansible variable``ansible_netconf_ssh_config`` either to ``True`` or custom ssh config file path
- Setting environment variable ``ANSIBLE_NETCONF_SSH_CONFIG`` to ``True`` or custom ssh config file path
- 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)
---------------------------------------

View file

@ -1633,11 +1633,12 @@ YAML_FILENAME_EXTENSIONS:
key: yaml_valid_extensions
type: list
NETCONF_SSH_CONFIG:
description: This variable is used to enable bastion/jump host with netconf connection. The bastion/jump
host ssh settings should be present in ssh configuration file (~/.ssh/config).
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/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}]
ini:
- {key: ssh_config, section: netconf_connection}
yaml: {key: netconf_connection.ssh_config}
type: boolean
default: None
...

View file

@ -153,11 +153,12 @@ options:
env:
- name: ANSIBLE_PERSISTENT_COMMAND_TIMEOUT
netconf_ssh_config:
type: boolean
default: False
default: None
description:
- This variable is used to enable bastion/jump host with netconf connection. The bastion/jump
host ssh settings should be present in ssh configuration file (~/.ssh/config).
- 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/config file,
alternatively it can be set to custom ssh configuration file path to read the
bastion/jump host settings.
ini:
- section: netconf_connection
key: ssh_config
@ -175,7 +176,7 @@ import json
from ansible.errors import AnsibleConnectionFailure, AnsibleError
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.connection import NetworkConnectionBase
@ -202,7 +203,7 @@ NETWORK_OS_DEVICE_PARAM_MAP = {
"ce": "huawei"
}
import q
class Connection(NetworkConnectionBase):
"""NetConf connections"""
@ -266,7 +267,7 @@ class Connection(NetworkConnectionBase):
ssh_config = self.get_option('netconf_ssh_config')
if ssh_config in BOOLEANS_TRUE:
ssh_config = True
else:
elif ssh_config in BOOLEANS_FALSE:
ssh_config = None
try: