Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stable 2.5 #36374

Merged
merged 2 commits into from
Feb 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 13 additions & 6 deletions lib/ansible/modules/network/nxos/nxos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@
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:
Expand Down Expand Up @@ -290,6 +290,7 @@


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
Expand Down Expand Up @@ -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':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- block:
- name: setup
nxos_config:
lines: "hostname {{ inventory_hostname_short }}"
lines: hostname switch
match: none
provider: "{{ connection }}"

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

Expand Down