Comments (13)
I can't reproduce the issue, it is working as expected. "commit confirmed" will get triggered only when you pass confirmed: .
https://ansible-juniper-collection.readthedocs.io/config.html
Also, could you run the playbook enabling netconf trace options on the device and collect the playbook execution log if you find the issue?
set system services netconf traceoptions file netconf.log
set system services netconf traceoptions file size 1g
set system services netconf traceoptions flag all
---
- name: Test juniper. device.config module
hosts: all
gather_facts: no
collections:
- juniper.device
tasks:
#################
- name: "Execute set configuration"
config:
load: "set"
format: "set"
lines: 'set system login message "Login"'
comment: "comment"
register: test1
tags: [ test1 ]
- name: Check TEST 1
debug:
var: test1
Output:
TASK [Check TEST 1] *************************************************************************************************************************************
ok: [local_connection_testcases] => {
"test1": {
"changed": true,
"diff": {
"prepared": "\n[edit system]\n+ login {\n+ message Login;\n+ }\n"
},
"diff_lines": [
"",
"[edit system]",
"+ login {",
"+ message Login;",
"+ }"
],
"failed": false,
"msg": "Configuration has been: opened, loaded, checked, diffed, committed, closed."
}
}
Device output:
[edit]
jnpr# show system login
message Login;
[edit]
jnpr#
[edit]
jnpr#
from ansible-junos-stdlib.
TASK [Execute set configuration] *************************************************************************************************************************************************************
changed: [tor-it02-10d-1] => {"changed": true, "diff_lines": ["", "[edit system login]", "- message \"This is login message\";", "+ message Login;"], "msg": "Configuration has been: opened, loaded, checked, diffed, committed, closed."}
TASK [Check TEST 1] **************************************************************************************************************************************************************************
ok: [tor-it02-10d-1] => {
"test1": {
"changed": true,
"diff": {
"prepared": "\n[edit system login]\n- message \"This is login message\";\n+ message Login;\n"
},
"diff_lines": [
"",
"[edit system login]",
"- message \"This is login message\";",
"+ message Login;"
],
"failed": false,
"msg": "Configuration has been: opened, loaded, checked, diffed, committed, closed."
}
}
# show system login message
message Login;
# commit confirmed will be rolled back in 29 minutes
{master:0}
# run show log netconf.log
May 6 12:59:49 [NETCONF] Started tracing session: 56384
May 6 12:59:49 [NETCONF] - [56384] Outgoing: <!-- No zombies were killed during the creation of this user interface -->
May 6 12:59:49 [NETCONF] - [56384] Outgoing: <!-- user ansible, class j-AUTOMATE -->
May 6 12:59:49 [NETCONF] - [56384] Outgoing: <hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
May 6 12:59:49 [NETCONF] - [56384] Outgoing: <capabilities>
<capability>urn:ietf:params:netconf:base:1.0</capability>
<capability>urn:ietf:params:netconf:capability:candidate:1.0</capability>
<capability>urn:ietf:params:netconf:capability:confirmed-commit:1.0</capability>
<capability>urn:ietf:params:netconf:capability:validate:1.0</capability>
<capability>urn:ietf:params:netconf:capability:url:1.0?scheme=http,ftp,file</capability>
<capability>urn:ietf:params:xml:ns:netconf:base:1.0</capability>
<capability>urn:ietf:params:xml:ns:netconf:capability:candidate:1.0</capability>
<capability>urn:ietf:params:xml:ns:netconf:capability:confirmed-commit:1.0</capability>
<capability>urn:ietf:params:xml:ns:netconf:capability:validate:1.0</capability>
<capability>urn:ietf:params:xml:ns:netconf:capability:url:1.0?scheme=http,ftp,file</capability>
<capability>urn:ietf:params:xml:ns:yang:ietf-yang-metadata?module=ietf-yang-metadata&revision=2016-08-05</capability>
<capability>urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring</capability>
<capability>http://xml.juniper.net/netconf/junos/1.0</capability>
<capability>http://xml.juniper.net/dmi/system/1.0</capability>
May 6 12:59:49 [NETCONF] - [56384] Outgoing: <capability>http://yang.juniper.net/junos/jcmd?module=junos-configuration-metadata&revision=2021-09-01</capability>
May 6 12:59:49 [NETCONF] - [56384] Outgoing: </capabilities>
May 6 12:59:49 [NETCONF] - [56384] Outgoing: <session-id>56384</session-id>
May 6 12:59:49 [NETCONF] - [56384] Outgoing: </hello>
May 6 12:59:49 [NETCONF] - [56384] Outgoing: ]]>]]>
May 6 12:59:49 [NETCONF] - [56384] Incoming: <?xml version="1.0" encoding="UTF-8"?><nc:hello xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:capabilities><nc:capability>urn:ietf:params:netconf:base:1.0</nc:capability><nc:capability>urn:ietf:params:netconf:base:1.1</nc:capability><nc:capability>urn:ietf:params:netconf:capability:writable-running:1.0</nc:capability><nc:capability>urn:ietf:params:netconf:capability:candidate:1.0</nc:capability><nc:capability>urn:ietf:params:netconf:capability:confirmed-commit:1.0</nc:capability><nc:capability>urn:ietf:params:netconf:capability:rollback-on-error:1.0</nc:capability><nc:capability>urn:ietf:params:netconf:capability:startup:1.0</nc:capability><nc:capability>urn:ietf:params:netconf:capability:url:1.0?scheme=http,ftp,file,https,sftp</nc:capability><nc:capability>urn:ietf:params:netconf:capability:validate:1.0</nc:capability><nc:capability>urn:ietf:params:netconf:capability:xpath:1.0</nc:capability><nc:capability>urn:ietf:params:netconf:capability:notification:1.0</nc:capability><nc:capability>urn:ietf:params:netconf:capability:interleave:1.0</nc:capability><nc:capability>urn:ietf:params:netconf:capability:with-defaults:1.0</nc:capability></nc:capabilities></nc:hello>]]>]]>
May 6 12:59:49 [NETCONF] - [56384] Incoming: Received ']]>]]>' token which is split in two consecutive streams or has leading/trailing spaces/tabs or both.
May 6 12:59:49 [NETCONF] - [56384] Incoming: <?xml version="1.0" encoding="UTF-8"?><nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:804fcec7-a897-4a1e-b6e5-d31f9cff6d11"><lock-configuration/></nc:rpc>]]>]]>
May 6 12:59:49 [NETCONF] - [56384] Outgoing: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/22.2R0/junos" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:804fcec7-a897-4a1e-b6e5-d31f9cff6d11">
May 6 12:59:49 [NETCONF] - [56384] Outgoing: </rpc-reply>
May 6 12:59:49 [NETCONF] - [56384] Outgoing: ]]>]]>
May 6 12:59:49 [NETCONF] - [56384] Incoming: Received ']]>]]>' token which is split in two consecutive streams or has leading/trailing spaces/tabs or both.
May 6 12:59:49 [NETCONF] - [56384] Incoming: <?xml version="1.0" encoding="UTF-8"?><nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:c15a4e51-b54b-4137-9c4f-18a2f5b4c643"><load-configuration format="text" action="set"><configuration-set>set system login message "Login"</configuration-set></load-configuration></nc:rpc>]]>]]>
May 6 12:59:49 [NETCONF] - [56384] Outgoing: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/22.2R0/junos" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:c15a4e51-b54b-4137-9c4f-18a2f5b4c643">
May 6 12:59:49 [NETCONF] - [56384] Outgoing: <load-configuration-results>
May 6 12:59:49 [NETCONF] - [56384] Outgoing: <ok/>
May 6 12:59:49 [NETCONF] - [56384] Outgoing: </load-configuration-results>
May 6 12:59:49 [NETCONF] - [56384] Outgoing: </rpc-reply>
May 6 12:59:49 [NETCONF] - [56384] Outgoing: ]]>]]>
May 6 12:59:49 [NETCONF] - [56384] Incoming: Received ']]>]]>' token which is split in two consecutive streams or has leading/trailing spaces/tabs or both.
May 6 12:59:49 [NETCONF] - [56384] Incoming: <?xml version="1.0" encoding="UTF-8"?><nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:f74f63ae-0418-4e3c-a123-baba46c2c32c"><commit-configuration><check/></commit-configuration></nc:rpc>]]>]]>
May 6 12:59:49 [NETCONF] - [56384] Outgoing: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/22.2R0/junos" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:f74f63ae-0418-4e3c-a123-baba46c2c32c">
May 6 12:59:49 [NETCONF] - [56384] Outgoing: <commit-results>
May 6 12:59:50 [NETCONF] - [56384] Outgoing: <routing-engine junos:style="normal">
May 6 12:59:50 [NETCONF] - [56384] Outgoing: <name>localre</name>
May 6 12:59:50 [NETCONF] - [56384] Outgoing: <commit-check-success/>
May 6 12:59:50 [NETCONF] - [56384] Outgoing: </routing-engine>
May 6 12:59:50 [NETCONF] - [56384] Outgoing: </commit-results>
May 6 12:59:50 [NETCONF] - [56384] Outgoing: <ok/>
May 6 12:59:50 [NETCONF] - [56384] Outgoing: </rpc-reply>
May 6 12:59:50 [NETCONF] - [56384] Outgoing: ]]>]]>
May 6 12:59:50 [NETCONF] - [56384] Incoming: Received ']]>]]>' token which is split in two consecutive streams or has leading/trailing spaces/tabs or both.
May 6 12:59:50 [NETCONF] - [56384] Incoming: <?xml version="1.0" encoding="UTF-8"?><nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:3541cb6c-17e4-48f0-8b80-30710674056b"><get-configuration compare="rollback" rollback="0" format="text"/></nc:rpc>]]>]]>
May 6 12:59:50 [NETCONF] - [56384] Outgoing: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/22.2R0/junos" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:3541cb6c-17e4-48f0-8b80-30710674056b">
May 6 12:59:50 [NETCONF] - [56384] Outgoing: <configuration-information>
May 6 12:59:50 [NETCONF] - [56384] Outgoing: <configuration-output>
May 6 12:59:50 [NETCONF] - [56384] Outgoing: [edit system login]
May 6 12:59:50 [NETCONF] - [56384] Outgoing: - message "This is login message";
May 6 12:59:50 [NETCONF] - [56384] Outgoing: + message Login;
May 6 12:59:50 [NETCONF] - [56384] Outgoing: </configuration-output>
May 6 12:59:50 [NETCONF] - [56384] Outgoing: </configuration-information>
May 6 12:59:50 [NETCONF] - [56384] Outgoing: </rpc-reply>
May 6 12:59:50 [NETCONF] - [56384] Outgoing: ]]>]]>
May 6 12:59:50 [NETCONF] - [56384] Incoming: Received ']]>]]>' token which is split in two consecutive streams or has leading/trailing spaces/tabs or both.
May 6 12:59:50 [NETCONF] - [56384] Incoming: <?xml version="1.0" encoding="UTF-8"?><nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:078eae3a-5c55-444c-8b65-8dcadeba44b3"><commit-configuration><log>comment</log><confirmed/><confirm-timeout>30</confirm-timeout></commit-configuration></nc:rpc>]]>]]>
May 6 12:59:50 [NETCONF] - [56384] Outgoing: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/22.2R0/junos" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:078eae3a-5c55-444c-8b65-8dcadeba44b3">
May 6 12:59:50 [NETCONF] - [56384] Outgoing: <commit-results>
May 6 12:59:51 [NETCONF] - [56384] Outgoing: <routing-engine junos:style="normal">
May 6 12:59:51 [NETCONF] - [56384] Outgoing: <name>localre</name>
May 6 12:59:51 [NETCONF] - [56384] Outgoing: <commit-check-success/>
May 6 12:59:51 [NETCONF] - [56384] Outgoing: <commit-success/>
May 6 12:59:51 [NETCONF] - [56384] Outgoing: <commit-revision-information>
May 6 12:59:51 [NETCONF] - [56384] Outgoing: <new-db-revision>localre-1714993190-88</new-db-revision>
May 6 12:59:51 [NETCONF] - [56384] Outgoing: <old-db-revision>localre-1714993104-87</old-db-revision>
May 6 12:59:51 [NETCONF] - [56384] Outgoing: </commit-revision-information>
May 6 12:59:51 [NETCONF] - [56384] Outgoing: </routing-engine>
May 6 12:59:51 [NETCONF] - [56384] Outgoing: </commit-results>
May 6 12:59:51 [NETCONF] - [56384] Outgoing: <ok/>
May 6 12:59:51 [NETCONF] - [56384] Outgoing: </rpc-reply>
May 6 12:59:51 [NETCONF] - [56384] Outgoing: ]]>]]>
May 6 12:59:51 [NETCONF] - [56384] Incoming: Received ']]>]]>' token which is split in two consecutive streams or has leading/trailing spaces/tabs or both.
May 6 12:59:52 [NETCONF] - [56384] Incoming: <?xml version="1.0" encoding="UTF-8"?><nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:f60e2530-c98d-4d46-8e45-f30c9cc81097"><unlock-configuration/></nc:rpc>]]>]]>
May 6 12:59:52 [NETCONF] - [56384] Outgoing: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/22.2R0/junos" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:f60e2530-c98d-4d46-8e45-f30c9cc81097">
May 6 12:59:52 [NETCONF] - [56384] Outgoing: </rpc-reply>
May 6 12:59:52 [NETCONF] - [56384] Outgoing: ]]>]]>
May 6 12:59:52 [NETCONF] - [56384] Incoming: Received ']]>]]>' token which is split in two consecutive streams or has leading/trailing spaces/tabs or both.
May 6 12:59:52 [NETCONF] - [56384] Incoming: <?xml version="1.0" encoding="UTF-8"?><nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:38533529-7b13-4b29-a53a-be339957e8d6"><nc:close-session/></nc:rpc>]]>]]>
May 6 12:59:52 [NETCONF] - [56384] Outgoing: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/22.2R0/junos" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:38533529-7b13-4b29-a53a-be339957e8d6">
May 6 12:59:52 [NETCONF] - [56384] Outgoing: <ok/>
May 6 12:59:52 [NETCONF] - [56384] Outgoing: </rpc-reply>
May 6 12:59:52 [NETCONF] - [56384] Outgoing: ]]>]]>
May 6 12:59:52 [NETCONF] - [56384] Outgoing: <!-- session end at 2024-05-06 12:59:52 CEST -->
from ansible-junos-stdlib.
I noticed something strange: it looks like 2 commits are executed
show log messages
May 6 12:59:49 tor-it02-10d-1 mgd[56384]: UI_COMMIT: User 'ansible' requested 'commit' operation (comment: none)
May 6 12:59:50 tor-it02-10d-1 mgd[56384]: UI_COMMIT: User 'ansible' requested 'commit' operation (comment: comment)
May 6 12:59:51 tor-it02-10d-1 mgd[56384]: UI_COMMIT_CONFIRMED_REMINDER: 'commit confirmed' must be confirmed within 30 minutes
May 6 12:59:51 tor-it02-10d-1 mgd[56384]: UI_COMMIT_COMPLETED: : commit complete
from ansible-junos-stdlib.
Are you seeing the same behavior when you try manually on the device?
from ansible-junos-stdlib.
manually on the device, the behavior is as expected :
user: ansible (with class AUTOMATE : permissions all; allow-commands "configure private"; deny-commands configure;)
ansible@tor-it02-10d-1> show configuration system login message
message Login;
ansible@tor-it02-10d-1> configure private
warning: uncommitted changes will be discarded on exit
Entering configuration mode
ansible@tor-it02-10d-1# set system login message "hello"
ansible@tor-it02-10d-1# commit confirmed 5
error: commit confirmed not supported for private configuration
ansible@tor-it02-10d-1# commit comment test
configuration check succeeds
commit complete
another user (permissions all; allow-commands "(configure private)|(configure exclusive)"; deny-commands configure;)
slefol@tor-it02-10d-1> show configuration system login message
message hello;
slefol@tor-it02-10d-1> configure exclusive
warning: uncommitted changes will be discarded on exit
Entering configuration mode
slefol@tor-it02-10d-1# set system login message "Login"
slefol@tor-it02-10d-1# commit confirmed 42
configuration check succeeds
commit confirmed will be automatically rolled back in 42 minutes unless confirmed
commit complete
# commit confirmed will be rolled back in 42 minutes
from ansible-junos-stdlib.
@slefol Could you please let me know the use case? Why are performing commit confirmed
as well in manual execution?
from ansible-junos-stdlib.
Hi,
@dineshbaburam91
I want to execute a simple commit without commit confirmed. it does not work.
so I tried a confirmed commit but with 5 minutes, that doesn't work either (it's always 30 minutes whatever the value of the confirmed parameter).
The only way I found to work around the problem while waiting for this bug to be resolved is to do a second task which confirms the commit with a commit check. I would have preferred to do it with a commit but it doesn't work and it's a shame because compared to a check commit we have a trace in the "show system commit" for confirmation which is not the case with a simple commit check.
from ansible-junos-stdlib.
To exclude a user profile problem, I created on the remote device a user without a profile (class super-user) and I used this user in the playbook. The result is the same.
For information, a confirmed commit executed on the equipment rolls back for 10 minutes by default.
I don't know why the equipment rolls back for 30 minutes using the juniper.device.config module.
In the juniper/device/plugins/connection/pyez.py file, we have confirmed=None and in the playbook execution, we can see:
"invocation": {
"module_args": {
"confirmed": null,
from ansible-junos-stdlib.
I looked through the module code and I think I identified the bug.
The function name is commit_configuration.
The start of the function is :
def commit_configuration(self, ignore_warning=None, comment=None,
confirmed=None, timeout=30, full=False,
sync=False, force_sync=False):
The commit is called later in the function
if self.conn_type != "local":
self._pyez_conn.commit_configuration(ignore_warning, comment, timeout, confirmed, full, sync, force_sync)
return
the order of the parameters is not right.
I was able to do a quick update to the juniper_junos_common.py and it seems to resolve the issue.
I modified (by reversing the comment and confirmed parameters) the following code to the commit_configuration function:
if self.conn_type != "local":
self._pyez_conn.commit_configuration(ignore_warning, comment, confirmed, timeout, full, sync, force_sync)
return
the playbook works as expected with a simple commit or a confirmed commit with confirmed: 42 for example
from ansible-junos-stdlib.
Thank you for investigating. I will review and resolve the issue.
from ansible-junos-stdlib.
Fixed #661
from ansible-junos-stdlib.
HI,
@dineshbaburam91 there is an error in the proposed fix. see #661
from ansible-junos-stdlib.
Hi @slefol I have fixed and push the change
from ansible-junos-stdlib.
Related Issues (20)
- Current implementation doesn't handle multi member stacks where versions of members are inconsistent HOT 8
- Ansible SSH connection fails with Authentication Error if I connected to target via host jump HOT 2
- RPC "get-system-core-dumps" with formats "text" only prints the first line of rpc-reply HOT 4
- juniper.device.config module with set system login message " " with "," separated text message replaces "," with newline HOT 2
- Get facts and printing them results in invalid or malformed argument Error HOT 2
- Executing RPC with filters returns The error was: AttributeError: 'JuniperJunosModule' object has no attribute '_check_type_dict' HOT 3
- Address readthedocs upcoming changes HOT 3
- Ansible RPC error with junipe.device.rpc module HOT 2
- ansible-lint violation: missing required arguments: _inventory_hostname, _module_name, _module_utils_path (warning) HOT 2
- juniper.device.software - Software is downloaded for each RE when using remote_package HOT 8
- Feature Request: Add option to not discard uncommitted changes HOT 2
- PyEZ connection fails when ~/.ssh/config has a IdentityFile option for target hosts HOT 4
- sphinx-build -b html . _build/html/ fails with AttributeError: 'Sphinx' object has no attribute 'add_stylesheet' with sphinx 7.2.6 HOT 2
- Random diff on juniper SRX device HOT 1
- Update README to clarify the status of collections vs roles HOT 1
- Update tests to cover all modules, when using pyez connection plugin HOT 1
- All modules fail since Ansible 2.15.9 or >=2.16.3 ("missing required arguments") HOT 9
- Juniper's galaxy module download fails. HOT 1
- juniper.device.config does not transmit the error message with juniper.device.pyez connection HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible-junos-stdlib.