Juniper / ansible-junos-stdlib

Junos modules for Ansible
Apache License 2.0
303 stars 157 forks source link

apply fix for issue #592 - pass through auth command line arguments #615

Closed cmason3 closed 11 months ago

cmason3 commented 1 year ago

It is no longer possible to pass through credentials on the command line using -u, -k or --private-key since ansible-core 2.13. This fix addresses this issue by checking for them within self._play_context and populating connection_args if they aren't present. This has been tested with ansible-core>=2.12,<=2.14.

Caveat - I am not that familiar with the coding standards of Ansible collections so there might be a better way to achieve this, but people are currently unable to authenticate with later versions of ansible-core.

cmason3 commented 11 months ago

Is anyone actually still maintaining this repository as it appears to be abandoned?

chidanandpujar commented 11 months ago

Is anyone actually still maintaining this repository as it appears to be abandoned?

Hi @cmason3 Thanks for the follow up . I will run UT and FT with fix and share the results .

Thanks

chidanandpujar commented 11 months ago

Hi @cmason3 Thanks, We are running the functional tests , will be sharing the results .

Basic command line args looks to be working fine .

~/sw_install_member/ansible-junos-stdlib/tests# ansible-playbook -i inventory pb.juniper_junos_rpc.yml -u root -e "ssh_private_key_file='/dev/null'" -k
SSH password: 

PLAY [Test juniper.device.rpc module] *************************************************************************************************************************************

TASK [Execute single RPC get-software-information without any kwargs] *****************************************************************************************************
ok: [test]

TASK [Check TEST 1] *******************************************************************************************************************************************************
ok: [test] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Get Device Configuration with dest] *********************************************************************************************************************************
ok: [test]

TASK [Check that the get_config.conf exists] ******************************************************************************************************************************
ok: [test]

TASK [Check TEST 2] *******************************************************************************************************************************************************
ok: [test] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Clean up TEST 2] ****************************************************************************************************************************************************
changed: [test]

TASK [Get Device Configuration in text] ***********************************************************************************************************************************
ok: [test]

TASK [Check TEST 3] *******************************************************************************************************************************************************
ok: [test] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Execute multiple RPCs without any kwargs] ***************************************************************************************************************************
ok: [test]

TASK [Check TEST 4] *******************************************************************************************************************************************************
ok: [test] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Clean up TEST 4] ****************************************************************************************************************************************************
changed: [test]

TASK [Execute multiple RPCs with multiple kwargs] *************************************************************************************************************************
ok: [test]

TASK [Check TEST 5] *******************************************************************************************************************************************************
ok: [test] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Creates directory] **************************************************************************************************************************************************
ok: [test]

TASK [Execute multiple RPCs with multiple kwargs and dest-dir] ************************************************************************************************************
ok: [test]

TASK [Check get-interface-information.xml exists] *************************************************************************************************************************
ok: [test]

TASK [Check get-software-information.xml exists] **************************************************************************************************************************
ok: [test]

TASK [Check TEST 6] *******************************************************************************************************************************************************
ok: [test] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Clean up TEST 6] ****************************************************************************************************************************************************
changed: [test]

TASK [Get Device Configuration for interface] *****************************************************************************************************************************
ok: [test]

TASK [Check TEST 7] *******************************************************************************************************************************************************
ok: [test] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Execute wrong RPC to generate RPC error] ****************************************************************************************************************************
fatal: [test]: FAILED! => {"attrs": null, "changed": false, "format": "xml", "kwargs": null, "msg": "Unable to execute the RPC: b'<wrong-rpc xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\" format=\"xml\"/>\\n'. Error: RpcError(severity: error, bad_element: wrong-rpc, message: syntax error)", "rpc": "wrong-rpc"}
...ignoring

TASK [Check TEST 8] *******************************************************************************************************************************************************
ok: [test] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Check configuration for errors] *************************************************************************************************************************************
ok: [test]

TASK [Check TEST 9] *******************************************************************************************************************************************************
ok: [test] => {
    "test9": {
        "changed": false,
        "failed": false,
        "results": [
            {
                "attrs": {},
                "changed": false,
                "failed": false,
                "format": "xml",
                "kwargs": {
                    "private": true
                },
                "msg": "The RPC executed successfully.",
                "rpc": "open-configuration",
                "stdout": "",
                "stdout_lines": []
            },
            {
                "attrs": {
                    "action": "set",
                    "format": "text"
                },
                "changed": false,
                "failed": false,
                "format": "xml",
                "kwargs": {
                    "configuration_set": "set system syslog file test1 any any"
                },
                "msg": "The RPC executed successfully.",
                "parsed_output": {
                    "load-configuration-results": {
                        "ok": ""
                    }
                },
                "rpc": "load-configuration",
                "stdout": "<load-configuration-results>\n  <ok/>\n</load-configuration-results>\n",
                "stdout_lines": [
                    "<load-configuration-results>",
                    "  <ok/>",
                    "</load-configuration-results>"
                ]
            },
            {
                "attrs": {},
                "changed": false,
                "failed": false,
                "format": "xml",
                "kwargs": {},
                "msg": "The RPC executed successfully.",
                "rpc": "close-configuration",
                "stdout": "",
                "stdout_lines": []
            }
        ]
    }
}

TASK [Check TEST 9] *******************************************************************************************************************************************************
ok: [test] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Check huge xml/text data] *******************************************************************************************************************************************
ok: [test]

TASK [Check TEST 10] ******************************************************************************************************************************************************
ok: [test] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Check rollback info] ************************************************************************************************************************************************
ok: [test]

TASK [Check TEST 11] ******************************************************************************************************************************************************
ok: [test] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Check rollback info with boolean values] ****************************************************************************************************************************
ok: [test]

TASK [Check TEST 12] ******************************************************************************************************************************************************
ok: [test] => {
    "changed": false,
    "msg": "All assertions passed"
}

PLAY RECAP ****************************************************************************************************************************************************************
test                       : ok=32   changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=1   

Thanks