Closed ric79 closed 6 years ago
At the moment the only way is:
- name: "Get running config"
juniper_junos_rpc:
host: "{{ ansible_ssh_host }}"
port: "{{ netconf_port }}"
user: "{{ ansible_ssh_user }}"
passwd: "{{ ansible_ssh_pass }}"
rpc: "get-config"
return_output: false
attr:
format: "text"
dest: "......."
no_log: true
Why not just use the juniper_junos_config
module to retrieve the configuration?
Something like:
tasks:
- name: 'Retrieve the committed configuration'
juniper_junos_config:
retrieve: 'committed'
format: 'text'
diff: false
check: false
commit: false
return_output: false
dest: "......."
Is there any error produced when you receive the truncated configuration with juniper_junos_command
?
Also, remember that the default timeout value (the maximum number of seconds to wait for RPC responses from the Junos device) is 30 seconds. You can increase this with the timeout
option.
Thanks this is working. I can attach here the log for juniper_junos_command with -vvvvv. I can see the full configuration in the log but not in the final file:
...
inactive: VLAN-99 {
description "xxxxx";
vlan-id 99;
interface ae1.99;
l3-interface irb.99;
}
}
</configuration-output>
</configuration-information>
</rpc-reply>
2018-03-15 16:33:17,181 ncclient.operations.rpc Delivering to <ncclient.operations.third_party.juniper.rpc.ExecuteRpc object at 0x3921ad0>
2018-03-15 16:33:17,181 ncclient.transport.ssh Trying another round of parsing since there is still data
2018-03-15 16:33:17,181 ncclient.transport.ssh parsing netconf v1.0
2018-03-15 16:33:17,201 jnpr.ansible_module.juniper_junos_command [xxx.xxx.231.137] Command "show configuration" executed successfully.
2018-03-15 16:33:17,201 jnpr.ansible_module.juniper_junos_command [xxx.xxx.231.137] Text configuration output set.
2018-03-15 16:33:17,202 jnpr.ansible_module.juniper_junos_command [xxx.xxx.231.137] Output saved to: /tmp/provaX_nfv-vb-spine-01.txt.
2018-03-15 16:33:17,203 ncclient.operations.rpc Requesting 'CloseSession'
2018-03-15 16:33:17,203 ncclient.transport.session queueing <?xml version="1.0" encoding="UTF-8"?><nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:573b8a32-327b-4195-acaa-6697b
a52bd09"><nc:close-session/></nc:rpc>
2018-03-15 16:33:17,204 ncclient.operations.rpc Sync request, will wait for timeout=30
2018-03-15 16:33:17,282 ncclient.transport.ssh Sending message
2018-03-15 16:33:17,282 ncclient.transport.ssh Sending: <?xml version="1.0" encoding="UTF-8"?><nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:573b8a32-327b-4195-acaa-6697ba52b
d09"><nc:close-session/></nc:rpc>]]>]]>
2018-03-15 16:33:17,285 ncclient.transport.ssh Selecting netconf:base:1.0 for encoding
2018-03-15 16:33:17,285 ncclient.transport.ssh parsing netconf v1.0
2018-03-15 16:33:17,286 ncclient.transport.ssh Selecting netconf:base:1.0 for encoding
2018-03-15 16:33:17,286 ncclient.transport.ssh parsing netconf v1.0
2018-03-15 16:33:17,287 ncclient.transport.session dispatching message to <ncclient.transport.session.NotificationHandler object at 0x3921510>: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmln
s:junos="http://xml.juniper.net/junos/17.4R1/junos" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:573b8a32-327b-4195-acaa-6697ba52bd09">
<ok/>
</rpc-reply>
2018-03-15 16:33:17,287 ncclient.transport.session dispatching message to <jnpr.junos.device.DeviceSessionListener object at 0x39217d0>: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos
="http://xml.juniper.net/junos/17.4R1/junos" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:573b8a32-327b-4195-acaa-6697ba52bd09">
<ok/>
</rpc-reply>
2018-03-15 16:33:17,287 ncclient.transport.session dispatching message to <ncclient.operations.rpc.RPCReplyListener object at 0x3921b50>: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:juno
s="http://xml.juniper.net/junos/17.4R1/junos" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:573b8a32-327b-4195-acaa-6697ba52bd09">
<ok/>
</rpc-reply>
2018-03-15 16:33:17,288 ncclient.operations.rpc Delivering to <ncclient.operations.session.CloseSession object at 0x39219d0>
2018-03-15 16:33:17,288 ncclient.transport.ssh Trying another round of parsing since there is still data
2018-03-15 16:33:17,288 ncclient.transport.ssh parsing netconf v1.0
2018-03-15 16:33:17,289 ncclient.transport.ssh [chan netconf-subsystem-0] EOF received (netconf-subsystem-0)
2018-03-15 16:33:17,290 ncclient.transport.ssh Broke out of main loop, error=SessionCloseError('Unexpected session close\nIN_BUFFER: `\n<!-- session end at 2018-03-15 16:33:35 CET -->\n`',)
2018-03-15 16:33:17,290 ncclient.transport.session dispatching error to <ncclient.transport.session.NotificationHandler object at 0x3921510>
2018-03-15 16:33:17,291 ncclient.transport.ssh [chan netconf-subsystem-0] EOF sent (netconf-subsystem-0)
2018-03-15 16:33:17,291 ncclient.transport.session dispatching error to <jnpr.junos.device.DeviceSessionListener object at 0x39217d0>
2018-03-15 16:33:17,292 ncclient.transport.session dispatching error to <ncclient.operations.rpc.RPCReplyListener object at 0x3921b50>
2018-03-15 16:33:17,319 jnpr.ansible_module.juniper_junos_command [xxx.xxx.231.137] Device closed.
2018-03-15 16:33:17,319 jnpr.ansible_module.juniper_junos_command [xxx.xxx.231.137] Exit JSON: {'msg': 'The command executed successfully.', 'failed': False, 'changed': False, 'command': 'show configuration'
, 'format': 'text'}
2018-03-15 16:33:17,395 p=12641 u=rrusso | ok: [nfv-vb-spine-01] => {
"changed": false,
"command": "show configuration",
"format": "text",
"invocation": {
"module_args": {
"attempts": null,
"baud": null,
"commands": [
"show configuration"
],
"console": null,
"dest": "/tmp/provaX_nfv-vb-spine-01.txt",
"dest_dir": null,
"format": "text",
"formats": [
"text"
],
"host": "xxx.xxx.231.137",
"logdir": null,
"logfile": null,
"mode": null,
"passwd": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": 830,
"provider": null,
"return_output": false,
"ssh_private_key_file": null,
"timeout": 30,
"user": "netconfadmin"
}
},
"msg": "The command executed successfully."
}
Yuppie I understood the problem.
When I run commit check:
netconfadmin@XXX# commit check
[edit protocols]
'bgp'
warning: requires 'bgp' license
[edit vlans VLAN-1048]
'vxlan'
warning: requires 'vxlan' license
configuration check succeeds
In the ansible.log I see:
<configuration-information>
**<configuration-output>**
## Last commit: 2018-03-15 11:18:06 CET by root
version 17.4R1.16;
system {
......
}
/* Role underlay-ebgp: bgp-spine-to-servicehub */
protocols {
**</configuration-output>**
<configuration-detail>
<indent>4</indent>
<configuration-detail-line>
<indent>4</indent>
<detail-name>Warning</detail-name>
<detail-value>requires 'bgp' license</detail-value>
</configuration-detail-line>
</configuration-detail>
<configuration-output>
bgp {
group a.a.a.a.aa.a. {
type internal;
local-address xxx.xx..xx.x.x.;
...
I suppose that the module spool to file the first configuration-output, but in my scenario I have several chunks. If you need the config and the log I can send you, but not via web. I work for TIM.
NOTE: I think that here https://github.com/Juniper/ansible-junos-stdlib/blob/master/library/juniper_junos_command.py#L481 you find just the first configuration-output chunk. I think you should use findall and not findtext
Rr
@ric79 You should use juniper_junos_config for fetching config. Closing this issue for now. Do open if you still face any issue.
Hello, If I execute:
I get the configuration truncated (non all lines). Same result if I use
junos_cli
or if I use aregister
variableAt the moment I'm using:
There are 2500 lines of configuration. File size: 65KB
Riccardo