Stable 2.5 (#36374)

* Set hostname to 'switch' on nxos_system (#36373)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit eb7f4460c8)

* fix nxos_config json pipeline error (#36236)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit 736d6406c0)
pull/36390/head
Trishna Guha 7 years ago committed by GitHub
parent 22b4d69a7b
commit 9692394c7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -113,9 +113,9 @@ options:
the modified lines are pushed to the device in configuration
mode. If the replace argument is set to I(block) then the entire
command block is pushed to the device in configuration mode if any
line is not correct. I(replace config) is supported on Nexus 9K device.
line is not correct. I(replace config) is supported only on Nexus 9K device.
required: false
default: lineo
default: line
choices: ['line', 'block', 'config']
force:
description:
@ -290,6 +290,7 @@ backup_path:
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.connection import ConnectionError
from ansible.module_utils.network.common.config import NetworkConfig, dumps
from ansible.module_utils.network.nxos.nxos import get_config, load_config, run_commands
from ansible.module_utils.network.nxos.nxos import get_capabilities
@ -390,12 +391,18 @@ def main():
config = None
info = get_capabilities(module).get('device_info', {})
os_platform = info.get('network_os_platform', '')
try:
info = get_capabilities(module)
api = info.get('network_api', 'nxapi')
device_info = info.get('device_info', {})
os_platform = device_info.get('network_os_platform', '')
except ConnectionError:
api = ''
os_platform = ''
if module.params['replace'] == 'config':
if api == 'cliconf' and module.params['replace'] == 'config':
if '9K' not in os_platform:
module.fail_json(msg='replace: config is supported only for Nexus 9K series switches')
module.fail_json(msg='replace: config is supported only on Nexus 9K series switches')
if module.params['replace_src']:
if module.params['replace'] != 'config':

@ -6,7 +6,7 @@
- block:
- name: configure hostname and domain-name
nxos_system: &hostname
hostname: "{{ inventory_hostname_short }}"
hostname: switch
domain_name: test.example.com
provider: "{{ connection }}"

@ -6,7 +6,7 @@
- block:
- name: setup
nxos_config:
lines: "hostname {{ inventory_hostname_short }}"
lines: hostname switch
match: none
provider: "{{ connection }}"
@ -33,7 +33,7 @@
always:
- name: teardown
nxos_config:
lines: "hostname {{ inventory_hostname_short }}"
lines: hostname switch
match: none
provider: "{{ connection }}"

Loading…
Cancel
Save