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

juniper_junos_rpc unexpected kwargs conversion to bool #538

Closed
pwlodawi opened this issue Jan 21, 2021 · 1 comment · Fixed by #564
Closed

juniper_junos_rpc unexpected kwargs conversion to bool #538

pwlodawi opened this issue Jan 21, 2021 · 1 comment · Fixed by #564
Assignees

Comments

@pwlodawi
Copy link

Issue Type

  • Bug Report

Module Name

juniper_junos_rpc

juniper.device collection and Python libraries version

ansible 2.10.4
  config file = /home/pwlodawi/ansible/playbooks/upgrade-lab/ansible.cfg
  configured module search path = ['/home/pwlodawi/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/pwlodawi/.venvs/ansible/lib/python3.8/site-packages/ansible
  executable location = /home/pwlodawi/.venvs/ansible/bin/ansible
  python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]

- juniper.junos, 2.4.3

junos-eznc==2.5.4

OS / Environment

Ubuntu 20.04.1 LTS

JUNOS 17.3R3-S6.3

Summary

Can't pass "0" and "1" to kwargs. They get converted to bool and make RPC fail.

Steps to reproduce

Run following two tasks.

      - name: Save rollback info
        juniper_junos_rpc:
          provider: "{{ provider }}"
          rpc: get-rollback-information
          kwargs:
            rollback: "3"
            compare: "2"
        register: res2

      - name: Save rollback info
        juniper_junos_rpc:
          provider: "{{ provider }}"
          rpc: get-rollback-information
          kwargs:
            rollback: "1"
            compare: "0"
        register: res

Expected results

Both tasks to succeed.

Actual results

The former task (args: 2 &3) succeeds,

ok: [bng101] => {                                                                                                                                                            
    "attrs": null,                                                                                                                                                           
    "changed": false,                                                                                                                                                        
    "format": "xml",                                                                                                                                                         
    "invocation": {                                                                                                                                                          
        "module_args": {                                                                                                                                                     
            "attempts": null,                                                                                                                                                
            "attrs": null,                                                                                                                                                   
            "baud": null,                                                                                                                                                    
            "console": null,                                                                                                                                                 
            "cs_passwd": null,                                                                                                                                               
            "cs_user": null,                                                                                                                                                 
            "dest": null,                                                                                                                                                    
            "dest_dir": null,                                                                                                                                                
            "filter": null,                                                                                                                                                  
            "formats": null,                                                                                                                                                 
            "host": "bng101",                                                                                                                                                
            "ignore_warning": null,                                                                                                                                          
            "kwargs": "{'rollback': '3', 'compare': '2'}",                                                                                                                   
            "level": null,                                                                                                                                                   
            "logdir": null,                                                                                                                                                  
            "logfile": null,                                                                                                                                                 
            "mode": null,                                                                                                                                                    
            "passwd": "secret-cut",                                                                                                                                             
            "port": 22,                                                                                                                                                      
            "return_output": true,                                                                                                                                           
            "rpc": "get-rollback-information",                                                                                                                               
            "rpcs": [                                                                                                                                                        
                "get-rollback-information"                                                                                                                                   
            ],                                                                                                                                                               
            "ssh_config": null,                                                                                                                                              
            "ssh_private_key_file": null,                                                                                                                                    
            "timeout": 1800,                                                                                                                                                 
            "user": "pwlodawi"                                                                                                                                               
        }                                                                                                                                                                    
    },                                                                                                                                                                       
    "kwargs": {                                                                                                                                                              
        "compare": "2",                                                                                                                                                      
        "rollback": "3"                                                                                                                                                      
    },                                                                                                                                                                       
    "msg": "The RPC executed successfully.",           
...        

the later task (args: 0 & 1) fails

fatal: [bng101]: FAILED! => {                                                                                                                                                
    "attrs": null,                                                                                                                                                           
    "changed": false,                                                                                                                                                        
    "format": "xml",                                                                                                                                                         
    "invocation": {                                                                                                                                                          
        "module_args": {                                                                                                                                                     
            "attempts": null,                                                                                                                                                
            "attrs": null,                                                                                                                                                   
            "baud": null,                                                                                                                                                    
            "console": null,                                                                                                                                                 
            "cs_passwd": null,                                                                                                                                               
            "cs_user": null,                                                                                                                                                 
            "dest": null,                                                                                                                                                    
            "dest_dir": null,                                                                                                                                                
            "filter": null,                                                                                                                                                  
            "formats": null,                                                                                                                                                 
            "host": "bng101",                                                                                                                                                
            "ignore_warning": null,                                                                                                                                          
            "kwargs": "{'rollback': '1', 'compare': '0'}",                                                                                                                   
            "level": null,                                                                                                                                                   
            "logdir": null,                                                                                                                                                  
            "logfile": null,                                                                                                                                                 
            "mode": null,                                                                                                                                                    
            "passwd": "secret-cut",                                                                                                                                             
            "port": 22,                                                                                                                                                      
            "return_output": true,                                                                                                                                           
            "rpc": "get-rollback-information",                                                                                                                               
            "rpcs": [                                                                                                                                                        
                "get-rollback-information"                                                                                                                                   
            ],                                                                                                                                                               
            "ssh_config": null,                                                                                                                                              
            "ssh_private_key_file": null,                                                                                                                                    
            "timeout": 1800,                                                                                                                                                 
            "user": "pwlodawi"                                                                                                                                               
        }                                                                                                                                                                    
    },                                                                                                                                                                       
    "kwargs": {                                                                                                                                                              
        "compare": false,                                                                                                                                                    
        "rollback": true                                                                                                                                                     
    },                                                                                                                                                                       
    "msg": "Unable to execute the RPC: b'<get-rollback-information xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\" format=\"xml\">\\n  <rollback/>\\n  <compare/>\\n</ge
t-rollback-information>\\n'. Error: RpcError(severity: error, bad_element: rollback, message: Invalid numeric value: '')",                                                   
    "rpc": "get-rollback-information"                                                                                                                                        
}                                                                                                                           

Junos logs confirm incorrect RPC call

Jan 21 21:57:39 [NETCONF] - [28479] 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:01b7fde1-8c1c-46be-bc37-6d9d1be4645f"><get-rollback-information format="xml"><rollback/><compare/></get-rollback-information></nc:rpc>]]>]]>
@rahkumar651991 rahkumar651991 self-assigned this Jan 29, 2021
@rahkumar651991
Copy link
Contributor

@pwlodawi - Was checking the issue. It seems, one of the internal functions of ansible used in the module uses 1 and 0 as boolean values.
Will get back with the resolution soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants