Re: [ansible-project] Re: Ansible upgrade cisco switch stack firmware

2021-03-12 Thread Ganesh Nalawade
If the high value of persistent command timeout is applicable for one task
it can be set at task level. Refer
https://docs.ansible.com/ansible/devel/network/user_guide/network_debug_troubleshooting.html#command-timeout

On Sat, 13 Mar 2021 at 1:40 AM, madd...@gmail.com 
wrote:

> I answered my own question ;)
>
> I added command_timeout = 2700 to group_vars
>
> Have a good weekend
>
> On Friday, March 12, 2021 at 1:32:37 PM UTC-5 madd...@gmail.com wrote:
>
>> I resolved this by editing the ansible.cfg variable command_timeout = 30
>> to command_timeout = 2700 (accounting for the long operation of copying
>> files across stack members and updating.
>>
>> I'd rather not keep this variable at 2700. Is there a way I can
>> temporarily set this variable in group_var or elsewhere?
>> On Friday, March 12, 2021 at 8:57:43 AM UTC-5 madd...@gmail.com wrote:
>>
>>> I have tried using: ansible.netcommon.cli_command
>>>
>>> Here is the snippet of playbook that is failing:
>>>   - name: Copy IOS to all stack members and update
>>> ansible.netcommon.cli_command:
>>>   command: install add file
>>> flash:cat9k_lite_iosxe.16.12.04.SPA.bin activate commit
>>>   check_all: true
>>>   prompt:
>>>   - "This operation may require a reload of the system. Do you
>>> want to proceed"
>>>   - "Install will reload the system now"
>>>   answer:
>>>   - y
>>>   - y
>>>
>>>
>>> Since I tested initially I had some timeout issues, so prior to running,
>>> I ran:
>>> export ANSIBLE_PERSISTENT_TIMEOUT=2700
>>>
>>> I still receive timeout failures:
>>> The full traceback is:
>>> WARNING: The below traceback may *not* be related to the actual failure.
>>>   File
>>> "/tmp/ansible_ansible.netcommon.cli_command_payload_ApkceD/ansible_ansible.netcommon.cli_command_payload.zip/ansible_collections/ansible/netcommon/plugins/modules/cli_command.py",
>>> line 170,
>>>   File
>>> "/tmp/ansible_ansible.netcommon.cli_command_payload_ApkceD/ansible_ansible.netcommon.cli_command_payload.zip/ansible/module_utils/connection.py",
>>> line 185, in __rpc__
>>> raise ConnectionError(to_text(msg, errors='surrogate_then_replace'),
>>> code=code)
>>> fatal: [10.82.2.125]: FAILED! => {
>>> "changed": false,
>>> "invocation": {
>>> "module_args": {
>>> "answer": [
>>> "y",
>>> "y"
>>> ],
>>> "check_all": true,
>>> "command": "install add file
>>> flash:cat9k_lite_iosxe.16.12.04.SPA.bin activate commit",
>>> "newline": true,
>>> "prompt": [
>>> "This operation may require a reload of the system. Do
>>> you want to proceed",
>>> "Install will reload the system now"
>>> ],
>>> "sendonly": false
>>> }
>>> },
>>> "msg": "timeout value 30 seconds reached while trying to send
>>> command: install add file flash:cat9k_lite_iosxe.16.12.04.SPA.bin activate
>>> commit"
>>> }
>>>
>>>
>>> Any help is appreciated!
>>>
>>> On Thursday, March 11, 2021 at 11:25:50 AM UTC-5 madd...@gmail.com
>>> wrote:
>>>
 Thanks Ganesh,

 I'll give that a try and let you know.

 On Thursday, March 11, 2021 at 10:32:15 AM UTC-5 gane...@gmail.com
 wrote:

> You can use cli_command module to handle multiple prompts on network
> device.
> Refer:
>
> https://docs.ansible.com/ansible/latest/collections/ansible/netcommon/cli_command_module.html
>
> On Thu, 11 Mar 2021 at 8:37 PM, madd...@gmail.com 
> wrote:
>
>> I ended up running the following manually. I just need a way for
>> ansible to wait for certain prompts and allow the process to complete
>> without ansible failing the job. Again, any suggestions would be
>> appreciated.
>>
>> Here is the manual command ran:
>>
>> 9200L-24T-4G-E_2#$*install add file
>> flash:cat9k_lite_iosxe.16.12.04.SPA.bin activate commit*
>> install_add_activate_commit: START Thu Mar 11 08:43:55 EST 2021
>>
>> System configuration has been modified.
>> Press Yes(y) to save the configuration and proceed.
>> Press No(n) for proceeding without saving the configuration.
>> Press Quit(q) to exit, you may save configuration and re-enter the
>> command. *[y/n/q]y*
>> Modified configuration has been saved
>> Mar 11 08:44:10.982 %INSTALL-5-INSTALL_START_INFO: R0/0:
>> install_engine: Started install one-shot
>> flash:cat9k_lite_iosxe.16.12.04.SPA.bin
>> install_add_activate_commit: Adding PACKAGE
>> install_add_activate_commit: Checking whether new add is allowed 
>>
>> --- Starting initial file syncing ---
>> [1]: Copying flash:cat9k_lite_iosxe.16.12.04.SPA.bin from switch 1 to
>> switch 2
>> [2]: Finished copying to switch 2
>> Info: Finished copying flash:cat9k_lite_iosxe.16.12.04.SPA.bin to the
>> selected switch(es)
>> Finis

Re: [ansible-project] Re: Ansible upgrade cisco switch stack firmware

2021-03-11 Thread Ganesh Nalawade
You can use cli_command module to handle multiple prompts on network device.
Refer:
https://docs.ansible.com/ansible/latest/collections/ansible/netcommon/cli_command_module.html

On Thu, 11 Mar 2021 at 8:37 PM, madd...@gmail.com 
wrote:

> I ended up running the following manually. I just need a way for ansible
> to wait for certain prompts and allow the process to complete without
> ansible failing the job. Again, any suggestions would be appreciated.
>
> Here is the manual command ran:
>
> 9200L-24T-4G-E_2#$*install add file
> flash:cat9k_lite_iosxe.16.12.04.SPA.bin activate commit*
> install_add_activate_commit: START Thu Mar 11 08:43:55 EST 2021
>
> System configuration has been modified.
> Press Yes(y) to save the configuration and proceed.
> Press No(n) for proceeding without saving the configuration.
> Press Quit(q) to exit, you may save configuration and re-enter the
> command. *[y/n/q]y*
> Modified configuration has been saved
> Mar 11 08:44:10.982 %INSTALL-5-INSTALL_START_INFO: R0/0: install_engine:
> Started install one-shot flash:cat9k_lite_iosxe.16.12.04.SPA.bin
> install_add_activate_commit: Adding PACKAGE
> install_add_activate_commit: Checking whether new add is allowed 
>
> --- Starting initial file syncing ---
> [1]: Copying flash:cat9k_lite_iosxe.16.12.04.SPA.bin from switch 1 to
> switch 2
> [2]: Finished copying to switch 2
> Info: Finished copying flash:cat9k_lite_iosxe.16.12.04.SPA.bin to the
> selected switch(es)
> Finished initial file syncing
>
> --- Starting Add ---
> Performing Add on all members
>   [1] Add package(s) on switch 1
>   [1] Finished Add on switch 1
>   [2] Add package(s) on switch 2
>   [2] Finished Add on switch 2
> Checking status of Add on [1 2]
> Add: Passed on [1 2]
> Finished Add
>
> Image added. Version: 16.12.4.0.4480
> install_add_activate_commit: Activating PACKAGE
>
> gzip: initramfs.cpio.gz: decompression OK, trailing garbage ignored
> Following packages shall be activated:
> /flash/cat9k_lite-webui.16.12.04.SPA.pkg
> /flash/cat9k_lite-srdriver.16.12.04.SPA.pkg
> /flash/cat9k_lite-rpboot.16.12.04.SPA.pkg
> /flash/cat9k_lite-rpbase.16.12.04.SPA.pkg
>
> This operation may require a reload of the system. *Do you want to
> proceed? [y/n]y*
> --- Starting Activate ---
> Performing Activate on all members
> Mar 11 08:53:53.512: %INSTALL-5-INSTALL_AUTO_ABORT_TIMER_PROGRESS: R0/0:
> rollback_timer: Install auto abort timer will expire in 7200 seconds
>   [1] Activate package(s) on switch 1
> --- Starting list of software package changes ---
> Old files list:
>   Removed cat9k_lite-rpbase.16.12.03a.SPA.pkg
>   Removed cat9k_lite-rpboot.16.12.03a.SPA.pkg
>   Removed cat9k_lite-srdriver.16.12.03a.SPA.pkg
>   Removed cat9k_lite-webui.16.12.03a.SPA.pkg
> New files list:
>   Added cat9k_lite-rpbase.16.12.04.SPA.pkg
>   Added cat9k_lite-rpboot.16.12.04.SPA.pkg
>   Added cat9k_lite-srdriver.16.12.04.SPA.pkg
>   Added cat9k_lite-webui.16.12.04.SPA.pkg
> Finished list of software package changes
>   [1] Finished Activate on switch 1
>   [2] Activate package(s) on switch 2
> --- Starting list of software package changes ---
> Old files list:
>   Removed cat9k_lite-rpbase.16.12.03a.SPA.pkg
>   Removed cat9k_lite-rpboot.16.12.03a.SPA.pkg
>   Removed cat9k_lite-srdriver.16.12.03a.SPA.pkg
>   Removed cat9k_lite-webui.16.12.03a.SPA.pkg
> New files list:
>   Added cat9k_lite-rpbase.16.12.04.SPA.pkg
>   Added cat9k_lite-rpboot.16.12.04.SPA.pkg
>   Added cat9k_lite-srdriver.16.12.04.SPA.pkg
>   Added cat9k_lite-webui.16.12.04.SPA.pkg
> Finished list of software package changes
>   [2] Finished Activate on switch 2
> Checking status of Activate on [1 2]
> Activate: Passed on [1 2]
> Finished Activate
>
> --- Starting Commit ---
> Performing Commit on all members
>   [1] Commit package(s) on switch 1
>   [1] Finished Commit on switch 1
>   [2] Commit package(s) on switch 2
>   [2] Finished Commit on switch 2
> Checking status of Commit on [1 2]
> Commit: Passed on [1 2]
> Finished Commit
>
> Install will reload the system now!
> SUCCESS: install_add_activate_commit  Thu Mar 11 08:55:16 EST 2021
> Mar 11 08:55:17.946 %INSTALL-5-INSTALL_COMPLETED_INFO: R0/0:
> install_engine: Completed install one-shot PACKAGE
> flash:cat9k_lite_iosxe.16.12.04.SPA.bin
> 9200L-24T-4G-E_2#
>
> On Thursday, March 11, 2021 at 12:17:13 AM UTC-5 madd...@gmail.com wrote:
>
>> I'm trying to update a cisco switch stack with ansible and I would like
>> to use the archive command, but that doesn't work with .bin files.
>>
>> For the 9200 series switches, I can only download .bin files.
>>
>> I have tried:
>> ios_command:
>>   commands:
>> - command: install add file
>> flash:cat9k_lite_iosxe.16.12.04.SPA.bin
>>   wait_for: result[0] contains SUCCESS
>>
>> That isn't working for me either. I may need to enter a timeout as well.
>>
>> Please let me know if you have any suggestio

Re: [ansible-project] lxml.etree.XMLSyntaxError using python3.6

2020-10-06 Thread Ganesh Nalawade
It seems to be an issue within Ansible while trying to remove the namespace
from received XML response. Please check it the PR
https://github.com/ansible-collections/ansible.netcommon/pull/152 fixes the
issue you are seeing.

On Fri, Oct 2, 2020 at 12:14 AM angelo coluni  wrote:

> Here is the output..I cannot see any issue
>
> thanks
>
> 2020-10-01 14:08:46,140 p=862827 u=root n=ncclient.transport.ssh |
> [host 10.212.12.16 session-id 148] Received message from host
> 2020-10-01 14:08:46,141 p=862827 u=root n=ansible | jsonrpc response:
> {"jsonrpc": "2.0", "id": "d9df6042-c78a-486a-b9c3-6e2b38083fb6",
> "result": " xmlns:fabrics=\"urn:kaloom:faas:fabrics\"
> xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"
>
> xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">212e9fa6779-c667-4733-8db2-61f904b8205eaj08025933-upf-31uab48b157-fd08-46af-9355-5384e90979b4ak18000735-leaf-29u1c6e769f-02f0-41f7-a0f5-957d54d6e788controller-1"}
> 2020-10-01 14:08:46,161 p=862943 u=root n=ansible | <10.212.12.16>
> EXEC /bin/sh -c 'rm -f -r
>
> /root/.ansible/tmp/ansible-local-862814_qg5scng/ansible-tmp-1601575725.3798058-862943-225523550103615/
> > /dev/null 2>&1 && sleep 0'
> 2020-10-01 14:08:46,174 p=862814 u=root n=ansible | The full traceback is:
> Traceback (most recent call last):
>   File
> "/root/.ansible/tmp/ansible-local-862814_qg5scng/ansible-tmp-1601575725.3798058-862943-225523550103615/AnsiballZ_netconf_rpc.py",
> line 102, in 
> _ansiballz_main()
>   File
> "/root/.ansible/tmp/ansible-local-862814_qg5scng/ansible-tmp-1601575725.3798058-862943-225523550103615/AnsiballZ_netconf_rpc.py",
> line 94, in _ansiballz_main
> invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
>   File
> "/root/.ansible/tmp/ansible-local-862814_qg5scng/ansible-tmp-1601575725.3798058-862943-225523550103615/AnsiballZ_netconf_rpc.py",
> line 40, in invoke_module
>
> runpy.run_module(mod_name='ansible.modules.network.netconf.netconf_rpc',
> init_globals=None, run_name='__main__', alter_sys=True)
>   File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
> return _run_module_code(code, init_globals, run_name, mod_spec)
>   File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
> mod_name, mod_spec, pkg_name, script_name)
>   File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
> exec(code, run_globals)
>   File
> "/tmp/ansible_netconf_rpc_payload_ci30aiuw/ansible_netconf_rpc_payload.zip/ansible/modules/network/netconf/netconf_rpc.py",
> line 264, in 
>   File
> "/tmp/ansible_netconf_rpc_payload_ci30aiuw/ansible_netconf_rpc_payload.zip/ansible/modules/network/netconf/netconf_rpc.py",
> line 246, in main
>   File
> "/tmp/ansible_netconf_rpc_payload_ci30aiuw/ansible_netconf_rpc_payload.zip/ansible/module_utils/network/common/netconf.py",
> line 141, in remove_namespaces
>   File "/usr/local/lib/python3.6/site-packages/ncclient/xml_.py", line
> 174, in __init__
> self.__doc = self.remove_namespaces(self.__result)
>   File "/usr/local/lib/python3.6/site-packages/ncclient/xml_.py", line
> 222, in remove_namespaces
> parser=self.__parser))),
>   File "src/lxml/etree.pyx", line 3467, in lxml.etree.parse
>   File "src/lxml/parser.pxi", line 1856, in lxml.etree._parseDocument
>   File "src/lxml/parser.pxi", line 1876, in lxml.etree._parseMemoryDocument
>   File "src/lxml/parser.pxi", line 1757, in lxml.etree._parseDoc
>   File "src/lxml/parser.pxi", line 1068, in
> lxml.etree._BaseParser._parseUnicodeDoc
>   File "src/lxml/parser.pxi", line 601, in
> lxml.etree._ParserContext._handleParseResultDoc
>   File "src/lxml/parser.pxi", line 711, in lxml.etree._handleParseResult
>   File "src/lxml/parser.pxi", line 640, in lxml.etree._raiseParseError
>   File "", line 1
> lxml.etree.XMLSyntaxError: Start tag expected, '<' not found, line 1,
> column 1
>
> On Thu, Oct 1, 2020 at 11:59 AM Ganesh Nalawade 
> wrote:
> >
> > It looks like it is failing while parsing the response.
> > Please enable the persistent logging to identify exactly which RPC
> response is failing
> > Refer:
> https://docs.ansible.com/ansible/devel/network/user_guide/network_debug_troubleshooting.html#enabling-networking-device-interaction-logging
> >
> >
> > On Thu, Oct 1, 2020 at 9:11 PM angelo coluni 
> wrote:
> >>
> >> jxmlease is required if we want to display and store response in json,
> >> 

Re: [ansible-project] lxml.etree.XMLSyntaxError using python3.6

2020-10-06 Thread Ganesh Nalawade
It seems to be an issue within Ansible while trying to remove namespace
from received XML response.
Please check it the PR
https://github.com/ansible-collections/ansible.netcommon/pull/152 fixes the
issue
you are seeing.


> On Fri, Oct 2, 2020 at 12:14 AM angelo coluni  wrote:
>
>> Here is the output..I cannot see any issue
>>
>> thanks
>>
>> 2020-10-01 14:08:46,140 p=862827 u=root n=ncclient.transport.ssh |
>> [host 10.212.12.16 session-id 148] Received message from host
>> 2020-10-01 14:08:46,141 p=862827 u=root n=ansible | jsonrpc response:
>> {"jsonrpc": "2.0", "id": "d9df6042-c78a-486a-b9c3-6e2b38083fb6",
>> "result": "> xmlns:fabrics=\"urn:kaloom:faas:fabrics\"
>> xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"
>>
>> xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">212e9fa6779-c667-4733-8db2-61f904b8205eaj08025933-upf-31uab48b157-fd08-46af-9355-5384e90979b4ak18000735-leaf-29u1c6e769f-02f0-41f7-a0f5-957d54d6e788controller-1"}
>> 2020-10-01 14:08:46,161 p=862943 u=root n=ansible | <10.212.12.16>
>> EXEC /bin/sh -c 'rm -f -r
>>
>> /root/.ansible/tmp/ansible-local-862814_qg5scng/ansible-tmp-1601575725.3798058-862943-225523550103615/
>> > /dev/null 2>&1 && sleep 0'
>> 2020-10-01 14:08:46,174 p=862814 u=root n=ansible | The full traceback is:
>> Traceback (most recent call last):
>>   File
>> "/root/.ansible/tmp/ansible-local-862814_qg5scng/ansible-tmp-1601575725.3798058-862943-225523550103615/AnsiballZ_netconf_rpc.py",
>> line 102, in 
>> _ansiballz_main()
>>   File
>> "/root/.ansible/tmp/ansible-local-862814_qg5scng/ansible-tmp-1601575725.3798058-862943-225523550103615/AnsiballZ_netconf_rpc.py",
>> line 94, in _ansiballz_main
>> invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
>>   File
>> "/root/.ansible/tmp/ansible-local-862814_qg5scng/ansible-tmp-1601575725.3798058-862943-225523550103615/AnsiballZ_netconf_rpc.py",
>> line 40, in invoke_module
>>
>> runpy.run_module(mod_name='ansible.modules.network.netconf.netconf_rpc',
>> init_globals=None, run_name='__main__', alter_sys=True)
>>   File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
>> return _run_module_code(code, init_globals, run_name, mod_spec)
>>   File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
>> mod_name, mod_spec, pkg_name, script_name)
>>   File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
>> exec(code, run_globals)
>>   File
>> "/tmp/ansible_netconf_rpc_payload_ci30aiuw/ansible_netconf_rpc_payload.zip/ansible/modules/network/netconf/netconf_rpc.py",
>> line 264, in 
>>   File
>> "/tmp/ansible_netconf_rpc_payload_ci30aiuw/ansible_netconf_rpc_payload.zip/ansible/modules/network/netconf/netconf_rpc.py",
>> line 246, in main
>>   File
>> "/tmp/ansible_netconf_rpc_payload_ci30aiuw/ansible_netconf_rpc_payload.zip/ansible/module_utils/network/common/netconf.py",
>> line 141, in remove_namespaces
>>   File "/usr/local/lib/python3.6/site-packages/ncclient/xml_.py", line
>> 174, in __init__
>> self.__doc = self.remove_namespaces(self.__result)
>>   File "/usr/local/lib/python3.6/site-packages/ncclient/xml_.py", line
>> 222, in remove_namespaces
>> parser=self.__parser))),
>>   File "src/lxml/etree.pyx", line 3467, in lxml.etree.parse
>>   File "src/lxml/parser.pxi", line 1856, in lxml.etree._parseDocument
>>   File "src/lxml/parser.pxi", line 1876, in
>> lxml.etree._parseMemoryDocument
>>   File "src/lxml/parser.pxi", line 1757, in lxml.etree._parseDoc
>>   File "src/lxml/parser.pxi", line 1068, in
>> lxml.etree._BaseParser._parseUnicodeDoc
>>   File "src/lxml/parser.pxi", line 601, in
>> lxml.etree._ParserContext._handleParseResultDoc
>>   File "src/lxml/parser.pxi", line 711, in lxml.etree._handleParseResult
>>   File "src/lxml/parser.pxi", line 640, in lxml.etree._raiseParseError
>>   File "", line 1
>> lxml.etree.XMLSyntaxError: Start tag expected, '<' not found, line 1,
>> column 1
>>
>> On Thu, Oct 1, 2020 at 11:59 AM Ganesh Nalawade 
>> wrote:
>> >
>> > It looks like it is failing while parsing the response.
>> > Please enable the persistent logging to identify exactly which RPC
>> response is failing
>> > Refer:
>> https://d

Re: [ansible-project] lxml.etree.XMLSyntaxError using python3.6

2020-10-01 Thread Ganesh Nalawade
It looks like it is failing while parsing the response.
Please enable the persistent logging to identify exactly which RPC response
is failing
Refer:
https://docs.ansible.com/ansible/devel/network/user_guide/network_debug_troubleshooting.html#enabling-networking-device-interaction-logging


On Thu, Oct 1, 2020 at 9:11 PM angelo coluni  wrote:

> jxmlease is required if we want to display and store response in json,
> however if we want output to be xml we need lxml
> issue seems to be in removing name space from rpc reply , this could
> be ansible issue
>
> thanks
>
> ex:
> ---
>   - name: xml
> netconf_rpc:
>   rpc: get
>   display: xml
>   content: |
> 
>  < payload >
> 
> register: out   <--- fails
>
>
> On Thu, Oct 1, 2020 at 8:50 AM Dick Visser  wrote:
> >
> > The netconf_rpc module does not require lxml, but jxmlease instead.
> > Make sure that is installed (as per docs
> >
> https://docs.ansible.com/ansible/latest/collections/ansible/netcommon/netconf_rpc_module.html#requirements
> ).
> >
> > This is true for both of your python environments.
> > Probably 'pip list' will show it's installed, while 'pip3 list' won't.
> >
> > DIck
> >
> > On Thu, 1 Oct 2020 at 14:38, angelo coluni  wrote:
> > >
> > > Setup:
> > >
> > > ansible 2.9.13
> > >   config file = /etc/ansible/ansible.cfg
> > >   configured module search path = ['/root/.ansible/plugins/modules',
> '/usr/share/ansible/plugins/modules']
> > >   ansible python module location =
> /usr/lib/python3.6/site-packages/ansible
> > >   executable location = /usr/bin/ansible
> > >   python version = 3.6.8 (default, Dec  5 2019, 15:45:45) [GCC 8.3.1
> 20191121 (Red Hat 8.3.1-5)]
> > >
> > > installed lxml-4.5.2 ncclient-0.6.9
> > >
> > > Having an issue in ansible when using module netconf_rpc,  the
> following error occurs, however when I change interpreter_python =
> /usr/bin/python2.7 error is not present
> > >
> > > Any reason what can be causing this issue
> > >
> > > thanks..
> > >
> > >
> > > <10.10.10.10> EXEC /bin/sh -c '/usr/bin/python3.6
> /root/.ansible/tmp/ansible-local-9652MobtmE/ansible-tmp-1601554935.02-9754-119778420816035/AnsiballZ_netconf_rpc.py
> && sleep 0'
> > > <10.10.10.10> EXEC /bin/sh -c 'rm -f -r
> /root/.ansible/tmp/ansible-local-9652MobtmE/ansible-tmp-1601554935.02-9754-119778420816035/
> > /dev/null 2>&1 && sleep 0'
> > > The full traceback is:
> > > Traceback (most recent call last):
> > >   File
> "/root/.ansible/tmp/ansible-local-9652MobtmE/ansible-tmp-1601554935.02-9754-119778420816035/AnsiballZ_netconf_rpc.py",
> line 102, in 
> > > _ansiballz_main()
> > >   File
> "/root/.ansible/tmp/ansible-local-9652MobtmE/ansible-tmp-1601554935.02-9754-119778420816035/AnsiballZ_netconf_rpc.py",
> line 94, in _ansiballz_main
> > > invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
> > >   File
> "/root/.ansible/tmp/ansible-local-9652MobtmE/ansible-tmp-1601554935.02-9754-119778420816035/AnsiballZ_netconf_rpc.py",
> line 40, in invoke_module
> > >
>  runpy.run_module(mod_name='ansible.modules.network.netconf.netconf_rpc',
> init_globals=None, run_name='__main__', alter_sys=True)
> > >   File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
> > > return _run_module_code(code, init_globals, run_name, mod_spec)
> > >   File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
> > > mod_name, mod_spec, pkg_name, script_name)
> > >   File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
> > > exec(code, run_globals)
> > >   File
> "/tmp/ansible_netconf_rpc_payload_t8kmcb46/ansible_netconf_rpc_payload.zip/ansible/modules/network/netconf/netconf_rpc.py",
> line 264, in 
> > >   File
> "/tmp/ansible_netconf_rpc_payload_t8kmcb46/ansible_netconf_rpc_payload.zip/ansible/modules/network/netconf/netconf_rpc.py",
> line 246, in main
> > >   File
> "/tmp/ansible_netconf_rpc_payload_t8kmcb46/ansible_netconf_rpc_payload.zip/ansible/module_utils/network/common/netconf.py",
> line 141, in remove_namespaces
> > >   File "/usr/local/lib/python3.6/site-packages/ncclient/xml_.py", line
> 174, in __init__
> > > self.__doc = self.remove_namespaces(self.__result)
> > >   File "/usr/local/lib/python3.6/site-packages/ncclient/xml_.py", line
> 222, in remove_namespaces
> > > parser=self.__parser))),
> > >   File "src/lxml/etree.pyx", line 3521, in lxml.etree.parse
> > >   File "src/lxml/parser.pxi", line 1876, in lxml.etree._parseDocument
> > >   File "src/lxml/parser.pxi", line 1896, in
> lxml.etree._parseMemoryDocument
> > >   File "src/lxml/parser.pxi", line 1777, in lxml.etree._parseDoc
> > >   File "src/lxml/parser.pxi", line 1082, in
> lxml.etree._BaseParser._parseUnicodeDoc
> > >   File "src/lxml/parser.pxi", line 615, in
> lxml.etree._ParserContext._handleParseResultDoc
> > >   File "src/lxml/parser.pxi", line 725, in
> lxml.etree._handleParseResult
> > >   File "src/lxml/parser.pxi", line 654, in lxml.etree._raiseParseError
> > >   File "", line 1
> > > lxml.e

Re: [ansible-project] cisco.ios help

2020-07-14 Thread Ganesh Nalawade
Most likely the error is due to missing privilege escalation.
Refer
https://docs.ansible.com/ansible/latest/network/user_guide/platform_ios.html#using-cli-in-ansible
for
adding
ansible_become and ansible_become_password settings.

Also, FYI ios_vlan module is deprecated, instead use ios_vlans

resource module (available in Ansible 2.9 version)


On Tue, Jul 14, 2020 at 10:56 PM William Dossett 
wrote:

> Hi,
>
> I am writing a ansible pb to demonstrate the power of ansible to our
> NetOps team.
>
> I know enough about ansible and cisco switches to get around, but I am
> stuck on something probably really simple.
>
> I am trying to create a vlan and populate it with some interfaces, but I
>   - name: create vlan 10
> ios_vlan:
>   name: Vlan_10
>   vlan_id: 10
>   state: present
>
> and I get
>
>  "msg": "configure terminal\r\n^\r\n% Invalid input
> detected at '^' marker.\r\n\r\nterrapin-2960-bu>",
>
> and from the looks of the terrapin-2960-bu> prompt it is not at enable
> mode which would be why it is invalid input...
>
> I guess I don't know how to get to enable mode in ansible cisco.ios and I
> can't seem to find any reference that enlightens.
>
> Regards
> BIll
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/15ff7192-7f52-4813-8478-c673b49db926o%40googlegroups.com
> 
> .
>


-- 
Regards,
Ganesh B. Nalawade

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sFOnF%2B6_-9Tsj3zETQkkwwZvqi6sTzqNCFVGy6M5D4ZEw%40mail.gmail.com.


Re: [ansible-project] Ansible netconf module supporting netconf notifications

2020-04-12 Thread Ganesh Nalawade
You can use netconf_rpc module to create netconf subscription using
Ansible, processing notification is not supported with Ansible.

On Sun, Apr 12, 2020 at 8:05 PM Senthil Jayakumar <
senthil.jayaku...@gmail.com> wrote:

> Hi There,
>
> I appreciate if the excerpts could respond to this query.
>
> Thanks,
> Senthil Kumar Jayakumar
>
> On Thu, Apr 9, 2020 at 5:19 PM Senthil Jayakumar <
> senthil.jayaku...@gmail.com> wrote:
>
>> Hi There,
>>
>> I'm newbie to Ansible and would like to know if Ansible netconf module
>> supports subscribing and processing of netconf notifications?
>>
>> Please confirm and redirect me to appropriate documentation and samples.
>>
>> Thanks,
>> Senthil Kumar Jayakumar
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-project+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/cb5f5fd8-de81-42f6-aebc-f4d4e15090bd%40googlegroups.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAD9Vb1yCJFHcBc0A7m1V1tvimkbPkOpWGumwuOCh30%3Dvea8%2Bzg%40mail.gmail.com
> 
> .
>


-- 
Regards,
Ganesh B. Nalawade

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sEiu357ms8AqZC1RUeGOpDKkYM0tdrDCjDu7z-Hoh8Trg%40mail.gmail.com.


Re: [ansible-project] Problems with ios_command and prompt '[y/n]'

2020-02-04 Thread Ganesh Nalawade
The value of prompt option is a python regex hence either handle special
character in prompt correctly by using escape character or remove those
characters from prompt completely.
For example:

- name: remove old OS files
ios_command:
  commands:
- command: install remove inactive
   prompt: Do you want to remove above files
   answer: y


 On Tue, 4 Feb 2020 at 3:33 PM, Heinz Meier  wrote:

> Error output is:
>
> The full traceback is:
>   File
> "/tmp/ansible_ios_command_payload_hxb3x8bq/ansible_ios_command_payload.zip/ansible/module_utils/network/ios/ios.py",
> line 135, in run_commands
> return connection.run_commands(commands=commands, check_rc=check_rc)
>   File
> "/tmp/ansible_ios_command_payload_hxb3x8bq/ansible_ios_command_payload.zip/ansible/module_utils/connection.py",
> line 185, in __rpc__
> raise ConnectionError(to_text(msg, errors='surrogate_then_replace'),
> code=code)
>
> fatal: [switch]: FAILED! => {
> "changed": false,
> "invocation": {
> "module_args": {
> "auth_pass": null,
> "authorize": null,
> "commands": [
> {
> "answer": "y",
> "check_all": false,
> "command": "install remove inactive",
> "newline": true,
> "output": null,
> "prompt": "\\[y\\/n\\]",
> "sendonly": false
> }
> ],
> "host": null,
> "interval": 1,
> "match": "all",
> "password": null,
> "port": null,
> "provider": null,
> "retries": 10,
> "ssh_keyfile": null,
> "timeout": null,
> "username": null,
> "wait_for": null
> }
> },
> "msg": "command timeout triggered, timeout value is 180 secs.\nSee the
> timeout setting options in the Network Debug and Troubleshooting Guide."
> }
>
> Am Di., 4. Feb. 2020 um 15:28 Uhr schrieb Heinz Meier <
> heinz6.mei...@gmail.com>:
>
>> Hi,
>>
>> I have a problem with the ios_command and the C9200L switch when updating
>> the IOS-XE. One step of the upgrade is
>>
>> On step is to remove inactive IOS versions:
>>
>> #install remove inactive
>> (...)
>> Do you want to remove the above files? [y/n]
>>
>>
>> the part of the playbook looks like:
>>
>> ---
>> - hosts: cisco
>>   tasks:
>>
>> - name: Upgrade IOS-XE
>>   block:
>>
>>   - name: remove old OS files
>> ios_command:
>>   commands:
>> - command: install remove inactive
>>   prompt: '[y/n]'
>>   answer: 'y'
>> vars:
>>   ansible_command_timeout: 180
>>
>>   when: (ansible_net_version != compliant_ios_version) and
>> (ansible_net_model is regex("9200"))
>>
>>
>>
>> Anytime I run this playbook this tasks fails with the timeout. 180 sec
>> should be enough time to delete the files.
>>
>> I tried to prolong the timeout value, and all combinations of the full
>> text of the question and backslashes in front of the brackets and the
>> forward slash.
>>
>> Always timeout.
>>
>> Any ideas?
>>
>> Michael Schwartzkopff
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-project+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/0aae16a2-4463-4828-a3e5-bdf9190ce35e%40googlegroups.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAFFTi_JWXSKFuvtB_tHnAz3CG8Hr1a%3DNSMbPX446frsyueWiwQ%40mail.gmail.com
> 
> .
>
-- 
Regards,
Ganesh B. Nalawade
Principal Engineer
Ansible by Red Hat
irc: ganeshrn

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sGsK9621POh_NjYu6ioHokwcdAOuuikKyO4ahGnnVbtag%40mail.gmail.com.


[ansible-project] Re: Ansible with network equipment (Comware 5 switch)

2019-08-12 Thread Ganesh Nalawade

The module seems to use paramiko_ssh 
 to 
connect to the remote host.
Try changing the inventory entry as below since the module is expected to 
run on the control node.

[switch1]
192.168.xx.xx ansible_connection=local

OR

[switch1]
localhost

Also, this seems to be a very old module and not using the Ansible 
persistent connection framework.
You can add Ansible cliconf and terminal plugins for the network os to make 
it work with connection=network_cli 

After adding the required plugins you use cli_command  
and 
cli_config 
 
modules 
to manage the remote host.

On Friday, 9 August 2019 19:11:17 UTC+5:30, Ugo Bellavance wrote:
>
> Hi,
>
> I'm new to Ansible.  I wanted to manage my network devices with Ansible so 
> I did this:
>
>- Found this documentation: 
>http://patg.net/ansible,comware,switches/2014/10/16/ansible-comware/
>- Created an account on my switch, tested that it can login via SSH 
>(password only, haven't configured an SSH key yet)
>- Installed ansible (from EPEL), on RHEL7 (see below for version 
>details)
>- Cloned the comware 5.2 module in $HOME/.ansible/plugins/modules (git 
>clone https://github.com/CaptTofu/comware_5_2.git)
>- Cloned the Github project to get playbook examples (git clone 
>https://github.com/CaptTofu/comware_5_2_playbooks.git)
>- Created an inventory file (see below)
>- Created a playbook (see below)
>- Ran ansible-playbook (ansible-playbook -i switch1 -u ansiblehpe 
>--ask-pass playbook1.yml)
>- Got this error message
>   - fatal: [192.168.xx.xx]: FAILED! => {"msg": "module (setup) is 
>   missing interpreter line"}
>- So I though I would add the shebang with the path of the python 
>interpeter on my server running ansible in the setup.py file
>   - Got these errors: 
>   -  [WARNING]: Unhandled error in Python interpreter discovery for 
>  host 192.168.99.41: Failed to connect to the host via ssh:
>  -  [WARNING]: sftp transfer mechanism failed on [192.168.99.41]. 
>  Use ANSIBLE_DEBUG=1 to see detailed information
>  -  [WARNING]: scp transfer mechanism failed on [192.168.99.41]. 
>  Use ANSIBLE_DEBUG=1 to see detailed information
>   - I realized ansible wanted to discover where could python be on 
>the remote target, but there isn't any interpreter there, it's a network 
>switch...
>- I set an empty shebang in the setup.py file and got this error
>   - An exception occurred during task execution. To see the full 
>   traceback, use -vvv. The error was: IndexError: list index out of range
>   fatal: [192.168.99.41]: FAILED! => {"msg": "Unexpected failure 
>   during module execution.", "stdout": ""}
>
> How do I tell ansible that there isn't any interpreter on the target?
>
> Any help would be appreciated.
> Thanks in advance.
>
> $ ansible --version
> ansible 2.8.2
>   config file = /etc/ansible/ansible.cfg
>   configured module search path = 
> [u'/home/ubellavance/.ansible/plugins/modules', 
> u'/usr/share/ansible/plugins/modules']
>   ansible python module location = /usr/lib/python2.7/site-packages/ansible
>   executable location = /usr/bin/ansible
>   python version = 2.7.5 (default, Jun 11 2019, 12:19:05) [GCC 4.8.5 
> 20150623 (Red Hat 4.8.5-36)]
>
> Inventory file:
>
> [switch1]
> 192.168.xx.xx
>
> [switch1:vars]
> switch_host=192.168.xx.xx
> switch_user=
> switch_password=
>
> Playbook:
>
> - hosts: switch1
>   tasks:
>   - name: gather facts from switch
> comware_5_2:
>   gather_facts=true
>   host={{ switch_host }}
>   username={{ switch_user }}
>   password={{ switch_password }}
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9fb35535-2c63-4cee-81a1-e2971a510e01%40googlegroups.com.


[ansible-project] Re: problem copy/template module with edgerouter

2019-08-07 Thread Ganesh Nalawade

You can try with net_put module
 https://docs.ansible.com/ansible/latest/modules/net_put_module.html

On Wednesday, 7 August 2019 09:17:28 UTC+5:30, Chang Eric wrote:
>
> I want to configure some of edgerouters with ansible
> one of the tasks is send a user`s public key then config authenticate with 
> that key
> the task is quite simple
> but I found although the tasks runs successfully , but the file does not 
> show on edgerouter
>
>
> - name: "Copy SSH public key to 
>> router"  
>>
>>
>>   copy: 
>> src: "usera.pub"
>> dest: "/tmp/usera.pub"
>>
>
>
> and also I try to generate file by using templates , the same situation, 
> tasks runs ok , but destination file does not exists.
>
> ans here is the playbook
>
>> - hosts: all
>>   become: True
>>   become_user: root
>>   become_method: sudo
>>   connection: network_cli
>>   gather_facts: no
>>   vars:
>> - role_users: "{{ technical_users }}"
>> - server_location: hq
>> - ansible_network_os: edgeos
>> - ansible_connection: network_cli
>> - ansible_become: yes
>> - ansible_become_method: enable
>>
>>   roles:
>> - { role: hosts, tags: hosts }
>> - { role: edgerouter , tags: edgerouter }
>>
>
> any suggestions ?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/52bd-c8de-4522-9f2a-06e47bd7fa06%40googlegroups.com.


Re: [ansible-project] Re: What would be the checkpoint firewall ansible_network_os

2019-07-29 Thread Ganesh Nalawade
***
> task path: /etc/ansible/cp2.yml:8
>  attempting to start connection
>  using connection plugin network_cli
>  local domain socket does not exist, starting it
>  control socket path is
> /files0/home/singhtr/.ansible/pc/22a0ffc2f6
> 
> The full traceback is:
> Traceback (most recent call last):
>   File "/usr/bin/ansible-connection", line 106, in start
> self.connection._connect()
>   File
> "/usr/lib/python2.7/site-packages/ansible/plugins/connection/network_cli.py",
> line 334, in _connect
> self._terminal.on_open_shell()
>   File "/usr/lib/python2.7/site-packages/ansible/plugins/terminal/ios.py",
> line 58, in on_open_shell
> raise AnsibleConnectionFailure('unable to set terminal parameters')
> AnsibleConnectionFailure: unable to set terminal parameters
>
> fatal: [firewall]: FAILED! => {
> "msg": "unable to set terminal parameters"
> }
> to retry, use: --limit @/etc/ansible/cp2.retry
>
> PLAY RECAP
> **
> firewall : ok=0changed=0unreachable=0failed=1
>
>
> On Mon, Jul 29, 2019 at 5:11 PM Ganesh Nalawade 
> wrote:
>
>> Try with:
>>
>> ansible_connection=httpapi ansible_network_os=checkpoint
>>
>> On Saturday, 27 July 2019 21:22:09 UTC+5:30, Tribhuvan Yadav wrote:
>>>
>>> any idea what should be the ansible_network_os for checkpoint. I am
>>> getting below error while running my playbook
>>>
>>> TASK [SHOW COMMAND]
>>> *
>>> fatal: [HQFW]: FAILED! => {"msg": "Unable to automatically determine
>>> host network os. Please manually configure ansible_network_os value for
>>> this host"}
>>>
>>>
>>> my default shell is bash.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-project+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/bf902c48-0e1c-4c7d-94b5-39c5968e2bfb%40googlegroups.com
>> <https://groups.google.com/d/msgid/ansible-project/bf902c48-0e1c-4c7d-94b5-39c5968e2bfb%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
Regards,
Ganesh B. Nalawade
Principal Engineer
Ansible by Red Hat
irc: ganeshrn

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sELR_pgAuqVYypiLhyp-ayUyPPBXCEUwAiTjAK%3D6hj7Kg%40mail.gmail.com.


[ansible-project] Re: What would be the checkpoint firewall ansible_network_os

2019-07-29 Thread Ganesh Nalawade
Try with:

ansible_connection=httpapi ansible_network_os=checkpoint

On Saturday, 27 July 2019 21:22:09 UTC+5:30, Tribhuvan Yadav wrote:
>
> any idea what should be the ansible_network_os for checkpoint. I am 
> getting below error while running my playbook
>
> TASK [SHOW COMMAND] 
> *
> fatal: [HQFW]: FAILED! => {"msg": "Unable to automatically determine host 
> network os. Please manually configure ansible_network_os value for this 
> host"}
>
>
> my default shell is bash.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/bf902c48-0e1c-4c7d-94b5-39c5968e2bfb%40googlegroups.com.


[ansible-project] Re: How to get past network device introductory menu

2019-07-24 Thread Ganesh Nalawade

It is currently not supported. However, I have raised a feature PR to add 
this support

Refer: https://github.com/ansible/ansible/pull/59525

Please test this PR branch in your environment and comment on the PR if it 
works for you or not.


On Tuesday, 23 July 2019 21:20:53 UTC+5:30, Pete Siemsen wrote:
>
> I'm using Ansible to talk to several Cisco devices. Most work as expected, 
> but some of our terminal servers have an introductory menu. When I ssh to 
> these devices, I don't immediately get a prompt. Instead, I have to select 
> an item from the menu, then I get a CLI prompt.
>
> For example, when I use ssh manually to access one of these devices, it 
> looks like this:
>
> *Authorized Users Only*
>
> * Main Menu*
>
> *1  Exit from *
> *2  Close "active" connection*
> *3  Open CLI*
> *4  Connect to an ethernet switch in closet 1*
> *5  Connect to an ethernet switch in closet 2*
> *6  Connect to a test-bed device*
> *7  Connect to a dial-out modem*
> *8  Connect to a host*
>
> *3*
> *#*
>
>
> When I use Ansible to ssh to these devices, Ansible times out, which isn't 
> a big surprise.
>
> When using Ansible, how can I get past the menu?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/374e16d7-11e0-4785-a4d6-f018d590bba3%40googlegroups.com.


Re: [ansible-project] dealing with prompt scenario in privilege mode

2019-07-19 Thread Ganesh Nalawade
You can use the cli_command module to handle prompts
Refer:
https://docs.ansible.com/ansible/latest/modules/cli_command_module.html


On Fri, Jul 19, 2019 at 10:36 AM SR  wrote:

> Any pointers on how to deal with scenarios where system prompt for user
> input in ios_config module ? . I am trying to execute the command "crypto
> key zeroize" , which results a yes/no prompt . Saw a reference here
> https://github.com/ansible/ansible/issues/35494, reading " as a work
> around you should be able to use ios_command with prompt " , but I
> couldn't run the privilege commands using ios_command module . I am
> Running ansible version 2.7.10.
>
> Thanks,
> SR
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/54d1f69d-b224-4afe-9877-b98a49eb8ed4%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sEpGSpV4c3kNg4WmGeB%3D-OyqCHy5en7wFsdODskD%2Biv5A%40mail.gmail.com.


Re: [ansible-project] Re: frr_facts and/or frr_bgp give assertionError?

2019-06-26 Thread Ganesh Nalawade
Please try setting below variables in inventory file:
ansible_network_os=frr ansible_connection=network_cli

network_cli uses persistent connection and the value _socket_path is set
after the connection with the remote host is successful in task_executor

Also, frr action plugin is not required for connection=network_cli

On Wed, Jun 26, 2019 at 5:05 PM Piet Honkoop  wrote:

> Hi,
>
> ansible_network_os is not set.
>
> As indicated: this is a ubuntu vm with frr installed in it, so ansible
> does not really recognize a network_os variant.
>
> so it might be that frr_bgp can only be used on certain device types?
>
> For now, I'm going to try another way of generating the proper
> configuration.
>
> I've tried this on cumulus switches as well, network_os is unset there too.
>
> Thanks,
> Piet
>
> Op woensdag 26 juni 2019 12:44:44 UTC+2 schreef Chiu Hsia Peng:
>>
>> Hi,
>> I noticed there is no frr.py at lib/ansible/plugins/action.
>>
>> What's the ansible_network_os ?
>>
>> In my case (my customized network device, qnos) , I need add
>>
>> NETWORK_GROUP_MODULES:
>>
>>   name: Network module families
>>
>>   default: [..., qnos]
>>
>>
>> In this case, my ansible_network_os=qnos
>>
>> And the socket_path is set at the run()
>> at  lib/ansible/plugins/action/qnos.py.
>> You can refer to the  lib/ansible/plugins/action/ios.py or the
>> corresponding ansible_network_os file.
>>
>> sincerely,
>> Jane#
>>
>>
>>
>> Piet Honkoop於 2019年6月26日星期三 UTC+8下午4時28分43秒寫道:
>>>
>>> Hi Jane,
>>> Thanks for the reply. Alas, it didn't work :)
>>>
>>> A bit more on the environment I'm working with:
>>>
>>> Got a lab setup with ubuntu 18.04 VMs with FRR 7.0 installed.
>>>
>>> What I want to test is whether I can properly configure frr on there
>>> with ansible.
>>>
>>> so the regular network_cli connection is likely not to work.
>>>
>>> What confuses me is that the AssertionError seems to point to config
>>> error in the connection module (it calls Connection(module.socket_path) but
>>> socket_path is Null. The socket_path should be set somewhere, I just can't
>>> seem to find where :(
>>>
>>> Any ideas?
>>>
>>> Thanks,
>>> Piet
>>>
>>>
>>>
>>> Op woensdag 26 juni 2019 04:07:44 UTC+2 schreef Chiu Hsia Peng:

 What ansible_connection are you using?
 I encountered a similar problem when ansible_connection is set to local.
 1. I solved the problem by setting ansible_connection to network_cli

 2. adding frr to lib/ansible/config/base.yml also can solve the problem
 (ansible_connection is set to local)
 i.e.
 NETWORK_GROUP_MODULES:
   name: Network module families
   default: [..., frr]

 sincerely,
 Jane#

 Piet Honkoop於 2019年6月26日星期三 UTC+8上午5時48分40秒寫道:
>
> Trying to explore the possibilities of frr_bgp module.
>
> If I try a task like:
>
>
>   tasks:
> - name: Get setup frr
>   frr_facts:
> gather_subset: all
>
> That results in:
>
>  File
> \"/tmp/ansible_frr_facts_payload_UFKM_S/ansible_frr_facts_payload.zip/ansible/module_utils/connection.py\",
> line 125, in __init__\r\nAssertionError: socket_path must be a value
>
>
> How can I fix this?
>
> Thanks,
> Piet
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/969767bd-c51c-4539-b4f5-b7874d6d4af1%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sFOPENO4xdNG6_YkergwgMUHULWCrFNnXdqr-%3De4Q6-Fg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] junos_scp not working

2019-05-20 Thread Ganesh Nalawade
junos_scp module relies on junos-eznc
<https://pypi.org/project/junos-eznc/> library
for file transfer to a JUNOS device, that's the reason provider argument is
required. The provider deprecation warning for junos_scp module is not
correct and needs to be fixed. Please raise an issue on Github to track it.

junos_command module uses Ansible netconf connection type hence provider is
no longer required for the junos_command module.

Also FYI you can use net_put
<https://docs.ansible.com/ansible/latest/modules/net_put_module.html> and
net_get
<https://docs.ansible.com/ansible/latest/modules/net_get_module.html>
modules in Ansible which should work with JUNOS device for file transfer
and doesn't require provider argument.


On Mon, May 20, 2019 at 12:03 PM Yan Sun  wrote:

> Thanks!
> The provider has be deprecated since Ansible 2.5. In my case, Ansible
> server has NETCONF connection setup with password, but, it fails on
> junos_scp. If I replace juno_scp with junos_command, there are no this
> kinds of issue at all.
>
> On Friday, May 17, 2019 at 8:08:22 PM UTC-7, Ganesh Nalawade wrote:
>>
>> Based on the logs it seems you have not set the value of provider
>> argument in the task.
>> junos_scp module requires the provider key to be set. More details refer
>> the module documentation
>> https://docs.ansible.com/ansible/latest/modules/junos_scp_module.html
>>
>>
>> On Fri, May 17, 2019 at 4:38 PM Yan Sun  wrote:
>>
>>> WARNING: The below traceback may *not* be related to the actual failure.
>>>   File "/tmp/ansible_junos_scp_payload_jlnsCA/__main__.py", line 165, in
>>> main
>>> device = connect(module)
>>>   File "/tmp/ansible_junos_scp_payload_jlnsCA/__main__.py", line 114, in
>>> connect
>>> device = Device(host, **kwargs)
>>>   File "/usr/lib/python2.7/site-packages/jnpr/junos/device.py", line
>>> 1151, in __init__
>>> raise ValueError("You must provide either 'host' or 'sock_fd' value")
>>>
>>> failed: [tl1-mx5cb-1b] (item=/home/tl1-mx5cb-1b.config.txt) => {
>>> "changed": false,
>>> "invocation": {
>>> "module_args": {
>>> "dest": "/tmp/",
>>> "host": null,
>>> "password": null,
>>> "port": null,
>>> "provider": {},
>>> "recursive": false,
>>> "remote_src": false,
>>> "src": [
>>> "/home/tl1-mx5cb-1b.config.txt"
>>> ],
>>> "ssh_keyfile": null,
>>> "timeout": null,
>>> "transport": null,
>>> "username": null
>>> }
>>> },
>>> "item": "/home/tl1-mx5cb-1b.config.txt",
>>> "msg": "You must provide either 'host' or 'sock_fd' value"
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to ansible...@googlegroups.com.
>>> To post to this group, send email to ansible...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/3688461b-1e36-422b-8e63-1324c4fa82bc%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/3688461b-1e36-422b-8e63-1324c4fa82bc%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/bebb7c88-546e-46fb-a830-1d209ab9777a%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/bebb7c88-546e-46fb-a830-1d209ab9777a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Regards,
Ganesh B. Nalawade
Principal Engineer
Ansible by Red Hat
irc: ganeshrn

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sEoQe6tvTUKw5W%3DSOwvHtmGP2hdMHwayP8-OW-A8MvNbw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] junos_scp not working

2019-05-17 Thread Ganesh Nalawade
Based on the logs it seems you have not set the value of provider argument
in the task.
junos_scp module requires the provider key to be set. More details refer
the module documentation
https://docs.ansible.com/ansible/latest/modules/junos_scp_module.html


On Fri, May 17, 2019 at 4:38 PM Yan Sun  wrote:

> WARNING: The below traceback may *not* be related to the actual failure.
>   File "/tmp/ansible_junos_scp_payload_jlnsCA/__main__.py", line 165, in
> main
> device = connect(module)
>   File "/tmp/ansible_junos_scp_payload_jlnsCA/__main__.py", line 114, in
> connect
> device = Device(host, **kwargs)
>   File "/usr/lib/python2.7/site-packages/jnpr/junos/device.py", line 1151,
> in __init__
> raise ValueError("You must provide either 'host' or 'sock_fd' value")
>
> failed: [tl1-mx5cb-1b] (item=/home/tl1-mx5cb-1b.config.txt) => {
> "changed": false,
> "invocation": {
> "module_args": {
> "dest": "/tmp/",
> "host": null,
> "password": null,
> "port": null,
> "provider": {},
> "recursive": false,
> "remote_src": false,
> "src": [
> "/home/tl1-mx5cb-1b.config.txt"
> ],
> "ssh_keyfile": null,
> "timeout": null,
> "transport": null,
> "username": null
> }
> },
> "item": "/home/tl1-mx5cb-1b.config.txt",
> "msg": "You must provide either 'host' or 'sock_fd' value"
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/3688461b-1e36-422b-8e63-1324c4fa82bc%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sG22k4tozZRjYPJVqY4Sd2SXu8%3DtGneK56ibnyGdCf4%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Can ios_config handle responding to two prompts in a row?

2019-03-10 Thread Ganesh Nalawade

You can use cli_command module available in Ansible 2.7 version onwards

https://docs.ansible.com/ansible/latest/modules/cli_command_module.html

The task can be modified as below to support multiple prompts.

- name: Respond to double-password prompt
  cli_command:
commands:
  - command: crypto pki server my-ca start

check_all: True
prompt: 

 - "password"

 - "enter password"

answer: 

  - "mypassword\r"

  - "mypassword\r"




On Monday, 11 March 2019 10:13:06 UTC+5:30, ibdg wrote:
>
> Just noticed, my title here is wrong, it should be 'ios_command' not 
> 'ios_config'
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b7880b8c-3104-4207-af39-8e3ea803fb17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Can network_cli or expect run tasks via SSH on simple embedded devices?

2019-02-27 Thread Ganesh Nalawade

The value depends on the name of the new terminal/cliconf plugin file added 
to support the new OS.
So if the plugin file name is 'foo.py' the value of ansible_network_os 
should be 'foo'.

The ansible_network_os value is used to load the right terminal

On Thursday, 28 February 2019 06:02:03 UTC+5:30, CodeWaffle wrote:
>
> Hi Ganesh:
>
> I have indeed seen the docs you point to below, but the next question 
> remains:  What is the correct value for "ansible_network_os"?
>
>
>
> The docs seems to list only real gear like Cisco, etc.  Is there some base 
> or generic option to choose?   A quick look at the source code did not seem 
> to indicate anything obvious either.
>
> Thank you!
>
> ‐‐‐ Original Message ‐‐‐
> On Tuesday, February 26, 2019 11:51 PM, Ganesh Nalawade  > wrote:
>
>
> "network_cli" connection plugin creates a pseudo terminal on the control 
> node which establishes ssh connection with target host. 
> So ideally it can be used to talk to any SSH-based target host. 
> network_cli connection plugin relies on value of ansible_network_os
> config variable to load the appropriate terminal and cliconf plugin for 
> the target host.
>
> Fore more details refer: 
> https://github.com/ansible/community/blob/master/group-network/network_dev_network_cli.rst
>  
>
> On Monday, 25 February 2019 22:00:04 UTC+5:30, CodeWaffle wrote:
>
>> Hi all:
>>
>> Not sure if I'm going about this the right way since I'm pretty new to 
>> Ansible.
>>
>> Bu, can something like "network_cli" be used to drive simple to simple 
>> embedded devices over SSH in an expect-like manner?  
>>
>> I've got a few devices that don't have a custom network_os or custom 
>> Ansible module defined.  They also don't have a full shell and just expose 
>> a simple command-line REPL.  
>>
>> Some simple pxssh script might work too, but it would seem nice to expose 
>> these steps as first-class Ansible tasks too.
>>
>> If this is doable via Ansible in a nice manner, can someone point me to 
>> the docs that cover this kind of use case?
>>
>> Thank you!
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f9fc414b-3603-4b27-aa41-e6fca97f3b7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Can network_cli or expect run tasks via SSH on simple embedded devices?

2019-02-26 Thread Ganesh Nalawade

"network_cli" connection plugin creates a pseudo terminal on the control 
node which establishes ssh connection with target host. 
So ideally it can be used to talk to any SSH-based target host. network_cli 
connection plugin relies on value of ansible_network_os
config variable to load the appropriate terminal and cliconf plugin for the 
target host.

Fore more details 
refer: 
https://github.com/ansible/community/blob/master/group-network/network_dev_network_cli.rst
 

On Monday, 25 February 2019 22:00:04 UTC+5:30, CodeWaffle wrote:
>
> Hi all:
>
> Not sure if I'm going about this the right way since I'm pretty new to 
> Ansible.
>
> Bu, can something like "network_cli" be used to drive simple to simple 
> embedded devices over SSH in an expect-like manner?  
>
> I've got a few devices that don't have a custom network_os or custom 
> Ansible module defined.  They also don't have a full shell and just expose 
> a simple command-line REPL.  
>
> Some simple pxssh script might work too, but it would seem nice to expose 
> these steps as first-class Ansible tasks too.
>
> If this is doable via Ansible in a nice manner, can someone point me to 
> the docs that cover this kind of use case?
>
> Thank you!
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/046f1e52-5058-4509-b023-12aa742f48db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] netconf_config - Viptela

2019-02-21 Thread Ganesh Nalawade
The error is reported from ncclient. For edit-config RPC it tries to
validate if the  is the root element of XML payload [1] & [2].
Since namespace is added to the config element it results in failure.
Please remove namespace from "config" element and try again.

[1]
https://github.com/ncclient/ncclient/blob/master/ncclient/operations/edit.py#L62
[2] https://github.com/ncclient/ncclient/blob/master/ncclient/xml_.py#L147



On Thu, Feb 21, 2019 at 9:19 PM  wrote:

> The only difference with the RPC call is that I have to put  in.
>
> ok: [sdw-ssc-vbond-g01] => {
> "changed": false,
> "invocation": {
> "module_args": {
> "content": "\n \n\n xmlns=\"http://tail-f.com/ns/config/1.0\";>\n  http://viptela.com/system\";>\n  scooberdoober\n
> \n\n",
> "display": null,
> "rpc": "edit-config",
> "xmlns": null
> }
> },
> "output": null,
> "stdout": " xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"
> xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\"
> message-id=\"urn:uuid:1e74d2f9-be5e-4be1-8543-a990b7d207e4\">",
> "stdout_lines": [
> " xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\"
> message-id=\"urn:uuid:1e74d2f9-be5e-4be1-8543-a990b7d207e4\">"
> ]
> }
>
>
> On Thursday, February 21, 2019 at 10:34:19 AM UTC-5, Ganesh Nalawade wrote:
>>
>> > "Element [{http://tail-f.com/ns/config/1.0}config] does not meet
>> requirement"
>>
>> Based on the error received from netconf server running on target host it
>> seems the  rooted xml payload is not supported
>> by the server. As per netconf rfc for edit-config RPC the config value
>> should have "config" element mandatory as root.
>>
>> What the value of "content" option when using netconf_rpc module?
>>
>> On Thu, Feb 21, 2019 at 7:44 PM  wrote:
>>
>>> Hello,
>>>
>>> I am trying to use netconf_config module on vEdge 18.3 without success.
>>>
>>>
>>> ===
>>>
>>>   - name: bootstarp vbond
>>> netconf_config:
>>>   content: |
>>>  http://tail-f.com/ns/config/1.0";>
>>>   http://viptela.com/system";>
>>>scooberdoober
>>>   
>>>  
>>>   default_operation: merge
>>> tags: second
>>>
>>> ===
>>>
>>> The full traceback is:
>>> WARNING: The below traceback may *not* be related to the actual failure.
>>>   File
>>> "/var/folders/x6/1l9s4g75079_4c9fkbqgw4v8gn/T/ansible_netconf_config_payload_qhcEJi/__main__.py",
>>> line 367, in main
>>> conn.edit_config(**kwargs)
>>>   File
>>> "/var/folders/x6/1l9s4g75079_4c9fkbqgw4v8gn/T/ansible_netconf_config_payload_qhcEJi/ansible_netconf_config_payload.zip/ansible/module_utils/connection.py",
>>> line 173, in __rpc__
>>> raise ConnectionError(to_text(msg, errors='surrogate_then_replace'),
>>> code=code)
>>>
>>> fatal: [sdw-ssc-vbond-g01]: FAILED! => {
>>> "changed": false,
>>> "invocation": {
>>> "module_args": {
>>> "backup": false,
>>> "commit": true,
>>> "confirm": 0,
>>> "confirm_commit": false,
>>> "content": "http://tail-f.com/ns/config/1.0\";>\n
>>> http://viptela.com/system\";>\n
>>> scooberdoober\n \n\n",
>>> "default_operation": "replace",
>>> "delete": false,
>>> "error_option": "stop-on-error",
>>> "format": "xml",
>>> "host": null,
>>> "hostkey_verify": true,
>>> "lock": "always",
>>> "look_for_keys": true,
>>> "password": null,
>>> "port": 830,
>>> "save": false,
>>> "source_datastore": null,
>>> "src": null,
>>> "ssh_keyfile": null,
>>> &quo

Re: [ansible-project] netconf_config - Viptela

2019-02-21 Thread Ganesh Nalawade
> "Element [{http://tail-f.com/ns/config/1.0}config] does not meet
requirement"

Based on the error received from netconf server running on target host it
seems the  rooted xml payload is not supported
by the server. As per netconf rfc for edit-config RPC the config value
should have "config" element mandatory as root.

What the value of "content" option when using netconf_rpc module?

On Thu, Feb 21, 2019 at 7:44 PM  wrote:

> Hello,
>
> I am trying to use netconf_config module on vEdge 18.3 without success.
>
>
> ===
>
>   - name: bootstarp vbond
> netconf_config:
>   content: |
>  http://tail-f.com/ns/config/1.0";>
>   http://viptela.com/system";>
>scooberdoober
>   
>  
>   default_operation: merge
> tags: second
>
> ===
>
> The full traceback is:
> WARNING: The below traceback may *not* be related to the actual failure.
>   File
> "/var/folders/x6/1l9s4g75079_4c9fkbqgw4v8gn/T/ansible_netconf_config_payload_qhcEJi/__main__.py",
> line 367, in main
> conn.edit_config(**kwargs)
>   File
> "/var/folders/x6/1l9s4g75079_4c9fkbqgw4v8gn/T/ansible_netconf_config_payload_qhcEJi/ansible_netconf_config_payload.zip/ansible/module_utils/connection.py",
> line 173, in __rpc__
> raise ConnectionError(to_text(msg, errors='surrogate_then_replace'),
> code=code)
>
> fatal: [sdw-ssc-vbond-g01]: FAILED! => {
> "changed": false,
> "invocation": {
> "module_args": {
> "backup": false,
> "commit": true,
> "confirm": 0,
> "confirm_commit": false,
> "content": "http://tail-f.com/ns/config/1.0\";>\n
> http://viptela.com/system\";>\n
> scooberdoober\n \n\n",
> "default_operation": "replace",
> "delete": false,
> "error_option": "stop-on-error",
> "format": "xml",
> "host": null,
> "hostkey_verify": true,
> "lock": "always",
> "look_for_keys": true,
> "password": null,
> "port": 830,
> "save": false,
> "source_datastore": null,
> "src": null,
> "ssh_keyfile": null,
> "target": "auto",
> "timeout": 10,
> "username": null,
> "validate": false
> }
> },
> "msg": "Element [{http://tail-f.com/ns/config/1.0}config] does not
> meet requirement"
> }
> to retry, use: --limit
> @/Users/robdwyer/stuff/home_depot/ansible/deploy_bootstrap.retry
>
> PLAY RECAP
> 
> sdw-ssc-vbond-g01  : ok=0changed=0unreachable=0
> failed=1
>
>
> 
>
> Any idea on what I am doing wrong. I can use the exact same xml using
> netconf_rpc and edit-config and it will push the configurations.
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/4676b33f-9531-48a6-9299-f7d4566b6c77%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sFqDummj6NsP-w%3Dvjpzc%2BesWbYpEmPbpyR0fN8ZtEeixw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: sros network modules in ansible 2.7.0

2019-01-12 Thread Ganesh Nalawade

The issue is fixed by PR #49174 and the fix is available in Ansible version 
2.7.5 
Please retest with 2.7.5 version and check if the issue is still seen.

Regards,
Ganesh

On Saturday, 12 January 2019 06:01:40 UTC+5:30, Mike Dodd wrote:
>
> Here is a perfect example of the bug, also using Ansible 2.7.0:
>
>
> - name: TWO TASKS BREAKS SROS
>   hosts: sros
>   connection: local
>   gather_facts: no
>
>   vars_files:
>   - group_vars/all
>
>   tasks:
>
>   - name: Get Router system name
> sros_command:
>   provider: "{{ router_auth }}"
>   commands: show system information | match "System Name"
> register: system_name
>
>   - debug:
>   var: system_name
>
>
>   - name: Configure VPLS service
> sros_config:
>   provider: "{{ router_auth }}"
>   parents:
> - configure service
> - vpls "{{ internet_vpls_id }}" customer 1 create
> - allow-ip-int-bind
>   lines: exit
> register: vpls
>
>   - debug:
>   var: vpls
>
>
> ---
> -Failure:
>
> The full traceback is:
>
> Traceback (most recent call last):
>
>   File "/usr/local/bin/ansible-connection", line 290, in main
>
> messages.extend(conn.update_play_context(pc_data))
>
>   File 
> "/usr/local/lib/python2.7/site-packages/ansible/module_utils/connection.py", 
> line 173, in __rpc__
>
> raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), 
> code=code)
>
> ConnectionError: 'Connection' object has no attribute 'reset_history'
>
>
> fatal: [infr-rt002-d06.nae02.use1.viasat.cloud]: FAILED! => {
>
> "msg": "'Connection' object has no attribute 'reset_history'"
>
> }
>
>
>
> On Friday, October 12, 2018 at 9:26:04 AM UTC-7, DC wrote:
>>
>> Ansible newbie here.  I'm trying to learn about network_cli so installed 
>> a recent version of ansible
>>  ansible --version
>> ansible 2.7.0
>>   config file = /etc/ansible/ansible.cfg
>>   configured module search path = 
>> [u'/home/ubuntu/.ansible/plugins/modules', 
>> u'/usr/share/ansible/plugins/modules']
>>   ansible python module location = 
>> /usr/lib/python2.7/dist-packages/ansible
>>   executable location = /usr/bin/ansible
>>   python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]
>>
>> It appears the first task/commands executes ok, but as soon as I add a 
>> second task in the playbook (even a debug task) I end up with the error:
>> TASK [sros_command] 
>> 
>> task path: /tmp/sros.yml:7
>> The full traceback is:
>> Traceback (most recent call last):
>>   File "/usr/bin/ansible-connection", line 290, in main
>> messages.extend(conn.update_play_context(pc_data))
>>   File 
>> "/usr/lib/python2.7/dist-packages/ansible/module_utils/connection.py", line 
>> 173, in __rpc__
>> raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), 
>> code=code)
>> ConnectionError: 'Connection' object has no attribute 'reset_history'
>>
>> fatal: [sr]: FAILED! => {
>> "msg": "'Connection' object has no attribute 'reset_history'"
>> }
>>
>> Even trying to revert back to using 'provider' and 'connection: local' 
>> fails with a similar error.
>>
>> Thanks,
>> DC
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/12de3660-6cac-4ed1-a82f-cb72bf4180e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible and Huawei

2019-01-04 Thread Ganesh Nalawade
The error you are seeing is coming from ncclient library.
Are you able to connect to the device using a sample python script that 
uses ncclinet library?

Reference python script: 
https://github.com/ncclient/ncclient/blob/master/examples/nc01.py

Regards,
Ganesh

On Thursday, 3 January 2019 23:57:01 UTC+5:30, Anurag Bhatia wrote:
>
> Hello there
>
>
> Was wondering if anyone has experience of using ansible with Huawei 
> successfully?
> We are using Huawei at our IX and I am able to use ad-hoc commands with 
> Huawei but playbooks based on documentation fail with a ncclient related 
> error. We do have nc client as well as netconf installed on the machine. 
>
>
>
> Our sample playbook (IP and access details are removed)
>
>
> ---
>   - hosts: ###hidden###
> connection: local
> gather_facts: no
> vars:
>   cli:
> host: ###hidden###
> port: ###hidden###
> username: ###hidden###
> password: ###hidden###
> transport: cli
>
> tasks:
> - name: Test port
>   ce_switchport:
> interface: XGigabitEthernet0/0/44
> mode: access
> access_vlan: 100
> provider: '{{ cli }}'
> state: present
>
>
>
>
> and this throws the following error during execution: 
>
>
> The full traceback is:
> Traceback (most recent call last):
>   File "/usr/local/bin/ansible-connection", line 106, in start
> self.connection._connect()
>   File 
> "/Library/Python/2.7/site-packages/ansible/plugins/connection/netconf.py", 
> line 288, in _connect
> ssh_config=ssh_config
>   File "/Library/Python/2.7/site-packages/ncclient/manager.py", line 163, 
> in connect
> return connect_ssh(*args, **kwds)
>   File "/Library/Python/2.7/site-packages/ncclient/manager.py", line 128, 
> in connect_ssh
> session.connect(*args, **kwds)
>   File "/Library/Python/2.7/site-packages/ncclient/transport/ssh.py", line 
> 485, in connect
> raise SSHError("Could not open connection, possibly due to 
> unacceptable"
> SSHError: Could not open connection, possibly due to unacceptable SSH 
> subsystem name.
>
> fatal: [$Host]: FAILED! => {
> "msg": "Could not open connection, possibly due to unacceptable SSH 
> subsystem name."
> }
>
>
>
> Anyone with ideas on what could be wrong? 
>
>
> Thanks! 
>
>
> -- 
>
>
> Anurag Bhatia
> anuragbhatia.com
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/43884c30-4dff-406d-9464-e204a1afac89%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Rebooting a Cisco ASA device

2019-01-03 Thread Ganesh Nalawade
Try adding "meta: reset_connection" after wait_for task and before check 
version task.
Also, which Ansible version are you using?

Regards,
Ganesh

On Friday, 4 January 2019 04:26:41 UTC+5:30, Sahar wrote:
>
> I'm trying to reboot a Cisco ASA Firewall, and run the "show version" 
> command after it. It seems that rebooting works, but when the playbook gets 
> to the show version command, it will get failed by showing the error down 
> below. Any idea about it? 
>
>
>
>
>
> - name: Rebooting the ASA
>   asa_command:
> commands:
> - "reload\n"
>
>
> - wait_for: timeout=180
>
>
> - name: check the version
>   asa_command:
> commands:
> -  show version
>   register: output
>
>
> - name: check the version
>   debug: var=output.stdout
>
>
>
>
>
> TASK [Rebooting the ASA] 
> ***
> skipping: [Fw4Script-02.tor.bellnhs.int]
> ok: [Fw4Script-01.tor.bellnhs.int]
>
> TASK [wait_for] 
> 
> skipping: [Fw4Script-02.tor.bellnhs.int]
> ok: [Fw4Script-01.tor.bellnhs.int]
>
>
> TASK [check the version] 
> 
> skipping: [Fw4Script-02.tor.bellnhs.int]
> An exception occurred during task execution. To see the full traceback, 
> use -vvv. The error was: ansible.module_utils.connection.ConnectionError: 
> Socket is closed
> fatal: [Fw4Script-01.tor.bellnhs.int]: FAILED! => {"changed": false, 
> "module_stderr": "Traceback (most recent call last):\n  File 
> \"/home/shdianat/.ansible/tmp/ansible-local-12216t0E3Bw/ansible-tmp-1546555792.58-98199446309935/AnsiballZ_asa_command.py\",
>  
> line 113, in \n_ansiballz_main()\n  File 
> \"/home/shdianat/.ansible/tmp/ansible-local-12216t0E3Bw/ansible-tmp-1546555792.58-98199446309935/AnsiballZ_asa_command.py\",
>  
> line 105, in _ansiballz_main\ninvoke_module(zipped_mod, temp_path, 
> ANSIBALLZ_PARAMS)\n  File 
> \"/home/shdianat/.ansible/tmp/ansible-local-12216t0E3Bw/ansible-tmp-1546555792.58-98199446309935/AnsiballZ_asa_command.py\",
>  
> line 48, in invoke_module\nimp.load_module('__main__', mod, module, 
> MOD_DESC)\n  File \"/tmp/ansible_asa_command_payload_4Z1mL_/__main__.py\", 
> line 195, in \n  File 
> \"/tmp/ansible_asa_command_payload_4Z1mL_/__main__.py\", line 165, in 
> main\n  File 
> \"/tmp/ansible_asa_command_payload_4Z1mL_/ansible_asa_command_payload.zip/ansible/module_utils/network/asa/asa.py\",
>  
> line 124, in run_commands\n  File 
> \"/tmp/ansible_asa_command_payload_4Z1mL_/ansible_asa_command_payload.zip/ansible/module_utils/connection.py\",
>  
> line 173, in __rpc__\nansible.module_utils.connection.ConnectionError: 
> Socket is closed\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee 
> stdout/stderr for the exact error", "rc": 1}
>
>
>
>
> These are the parameters in ansible.cfg file:
>
> [persistent_connection]
>
> connect_timeout = 300
> command_timeout = 300
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f31d-7e0c-4eec-a39e-96aee001f124%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Does Ansible support actions for NETCONF devices?

2019-01-03 Thread Ganesh Nalawade

Since action is a netconf RPC defined in RFC 7950 it can be executed using 
Ansible netconf_rpc module.

- name: execute action rpc
  netconf_rpc:
rpc: action
xmlns: "urn:ietf:params:xml:ns:yang:1"
content: |
  
 apache-1
 
   2014-07-29T13:42:00Z
 
   



This task will send below XML RPC to remote Netconf server which is similar 
to that mentioned in RFC 7950





apache-1

2014-07-29T13:42:00Z





Hope this helps!

Regards,
Ganesh

On Thursday, 3 January 2019 00:53:47 UTC+5:30, steve...@gmail.com wrote:
>
> Hi
> Ansible supports netconf-rpc module allowing RPC operations to NETCONF 
> devices
> Does Ansible also support actions to NETCONF devices?
>
> From RFC 7950:
>
>The difference between an action and an rpc is that an action is tied
>to a node in the datastore, whereas an rpc is not.  When an action is
>invoked, the node in the datastore is specified along with the name
>of the action and the input parameters.
>
> Thank you
> Regards
> Steve
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3c7d71ae-1e6d-49a9-8481-0001750baff8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible netconf is not working with Cisco IOS

2018-10-29 Thread Ganesh Nalawade
Which Ansible version are you using?
There was a similar issue reported on 
2.7.0 https://github.com/ansible/ansible/issues/46257

This issue is fixed in 2.7.1 release. If you are still seeing this issue on 
2.7.1 please raise a Github issue with relevant details.

Regards,
Ganesh


On Saturday, 27 October 2018 00:10:01 UTC+5:30, Krishna Kotha wrote:
>
> Hello,
>
> I am trying to use Netconf_config model on Cisco switch catalyst 9300.
> I am getting following error message.
>
> You can see the playbook and the running the palybook. I tried with 
> different options like changing the RPC, indentation and changing the XML 
> to content in playbook. But nothing worked.
>
> Please let me know where i need to change.
>
>
>
> auto@automation:~/python/ansible$ ansible-playbook testing.yaml -u admin -k
> SSH password:
>
> PLAY [ios-xe] 
> ***
>
> TASK [interface configuration] 
> **
> fatal: [10.1.1.5]: FAILED! => {"changed": false, "msg": "{'info': ' version=\"1.0\" encoding=\"UTF-8\"?> xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" 
> xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">default-operation\\n\\n',
>  
> 'severity': 'error', 'tag': 'unknown-element', 'path': '\\n
> /rpc/edit-config\\n  ', 'message': None, 'type': 'protocol'}"}
> to retry, use: --limit @/home/auto/python/ansible/testing.retry
>
> PLAY RECAP 
> **
> 10.1.1.5   : ok=0changed=0unreachable=0failed=1
>
> auto@automation:~/python/ansible$
>
>
>
> - hosts: ios-xe
>   gather_facts: no
>   connection: netconf
>
>   tasks:
>   - name: interface configuration
> netconf_config:
>   xml: |
>   
>  xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
>   
> GigabitEthernet1/0/5
> testingbyyangsuite
>  xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd
>   
> 
>   
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f095be47-4d2b-433f-bbb6-eaa6691e980d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] ios_facts failing to populate all interfaces (edit and running-config) #44463

2018-10-10 Thread Ganesh Nalawade
I have posted a comment in issue with a possible workaround.
The final fix for this issue is still discussed and hopefully, it will be
resolved soon.

Regards,
Ganesh

On Tue, Oct 9, 2018 at 11:14 PM bill paxton <
epican.ansible.mail.l...@gmail.com> wrote:

> ios_facts failing to populate all interfaces #44463
>
> Any chance this issue is being addressed?  Its been over a month since OP.
>
> Thanks
>
> Bill
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/271d946a-ea8e-4427-bb8e-2ddd7c159c33%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sGO0KY6dEE3%3DYq3xJ5O%3D3Tgwx6bGicYxtg%2BGc%2BV11D4ug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Issue when backup cisco NXOS " fatal: [*************]: FAILED! => {"msg": "nothing to repeat"}"

2018-08-07 Thread Ganesh Nalawade

Can you please share the output of command in gist 


# show cdp global | include globally

Also please raise a Github issue here 
 with all the relevant details.

Regards,
Ganesh

On Thursday, 5 July 2018 21:09:28 UTC+5:30, Ahmed Aljawad wrote:
>
> [nwadmin@ddcmgtnwbkp ~]$ cat AutoBackup.yml
> ---
> - name: first network playbook with when
>   connection: network_cli
>   gather_facts: false
>   hosts: SFI
>   tasks:
> - name: backup
>   nxos_config:
> backup: yes
>   register: backup_nxos_location
>   when: ansible_network_os == 'nxos'
> ...
>
> here is my -vvv
> [nwadmin@ddcmgtnwbkp ~]$ ansible-playbook AutoBackup.yml -u admin -k -vvv
> ansible-playbook 2.5.3
>   config file = /home/nwadmin/ansible.cfg
>   configured module search path = 
> [u'/home/nwadmin/.ansible/plugins/modules', 
> u'/usr/share/ansible/plugins/modules']
>   ansible python module location = /usr/lib/python2.6/site-packages/ansible
>   executable location = /usr/bin/ansible-playbook
>   python version = 2.6.6 (r266:84292, Aug 18 2016, 08:36:59) [GCC 4.4.7 
> 20120313 (Red Hat 4.4.7-17)]
> Using /home/nwadmin/ansible.cfg as config file
> [DEPRECATION WARNING]: [defaults]hostfile option, The key is misleading as 
> it can also be a list of hosts, a directory or a list of paths , use 
> [defaults]
> inventory=/path/to/file|dir instead. This feature will be removed in 
> version 2.8. Deprecation warnings can be disabled by setting
> deprecation_warnings=False in ansible.cfg.
> SSH password:
> Parsed /home/nwadmin/INV_LIST inventory source with ini plugin
>
> PLAYBOOK: AutoBackup.yml 
> ***
> 1 plays in AutoBackup.yml
>
> PLAY [first network playbook with when] 
> 
> META: ran handlers
>
> TASK [backup] 
> **
> task path: /home/nwadmin/AutoBackup.yml:7
> The full traceback is:
> Traceback (most recent call last):
>   File "/usr/bin/ansible-connection", line 87, in start
> self.connection._connect()
>   File 
> "/usr/lib/python2.6/site-packages/ansible/plugins/connection/network_cli.py", 
> line 306, in _connect
> self._terminal = terminal_loader.get(network_os, self)
>   File "/usr/lib/python2.6/site-packages/ansible/plugins/loader.py", line 
> 366, in get
>
> return _compile(pattern, flags)
>   File "/usr/lib64/python2.6/re.py", line 245, in _compile
> raise error, v # invalid expression
> error: nothing to repeat
>  self._module_cache[path] = self._load_module_source(name, path)
>   File "/usr/lib/python2.6/site-packages/ansible/plugins/loader.py", line 
> 345, in _load_module_source
> module = imp.load_source(full_name, path, module_file)
>   File 
> "/usr/lib/python2.6/site-packages/ansible/plugins/terminal/nxos.py", line 
> 30, in 
> class TerminalModule(TerminalBase):
>   File 
> "/usr/lib/python2.6/site-packages/ansible/plugins/terminal/nxos.py", line 
> 33, in TerminalModule
> 
> re.compile(br'[\r\n]?(?!\s*<)?(\x1b\S+)*[a-zA-Z_]{1}[a-zA-Z0-9-_.]*[>|#|%](?:\s*)*(\x1b\S+)*$'),
>   File "/usr/lib64/python2.6/re.py", line 190, in compile
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/cd8b6047-1ad1-4e28-bf33-a77456ac73f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] junos_command

2018-03-29 Thread Ganesh Nalawade
You can use 'include_vars'

tasks:
- name: include commands
  include_vars:
file: shcmds.yaml

- name: Run a set of commands
  junos_command:
commands: "{{ show_commands }}"
output: text
provider: "{{ netconf }}"
  register: showcmds


$ cat shcmds.yaml
---
show_commands:
- show version
- show interfaces


Regards,
Ganesh




On Fri, Mar 30, 2018 at 1:19 AM, Gary Rubel  wrote:

> Hello,
>
> I'm trying to execute show commands on a Juniper using the playbook
> below.  I would like to use a separate file with the list of show commands
> but can't find the correct way to do it.  Any help would be appreciated.
>
> thanks
>
>  showfile: "{{ lookup('file', 'template/shcmds.txt') }}"
>
>   - name: Run a set of commands
>   junos_command:
> commands: "{{ showfile }}"
> #  src: template/shcmds.j2
> output: text
> provider: "{{ netconf }}"
>   register: showcmds
>
> - set_fact:
> readout: "{{ showcmds.stdout_lines | to_nice_yaml }}"
>
> - name: copy content
>   local_action:
> copy content="{{ readout }}"
> dest="{{ report_dir }}/{{ inventory_hostname }}.txt"
>
>
> # Input file ##
> template]$ more shcmds.txt
> - "show bgp sum"
> - "show route summary"
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/dab7fb64-5efa-4229-a9df-bebe8f1b7cee%40googlegroups.
> com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sEhc85qtumYp4wApGPW47XD%2BRqiuOMQP8CASsO3XsknGA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] determining network os type?

2018-03-08 Thread Ganesh Nalawade
ansible_network_os is a reserved variable and need to be set manually.
More details can be found here
https://docs.ansible.com/ansible/devel/network/user_guide/platform_index.html

Regards,
Ganesh

On Fri, Mar 9, 2018 at 11:17 AM, Marcos Georgopoulos  wrote:

> Hi,
>
> There are various network modules for iOS,EOS, etc etc...
>
> What I was wondering is there a way to determine a hosts base os type so
> that the correct network module can be called? I have seen some sites
> reference 'ansible_network_os'
>
> like below. However I am not sure is this is simple a variable that has
> been set manually of something ansible sets when initially connecting to a
> device?
>
> eos_facts:
>   when: ansible_network_os == 'eos'
>
> - name: Gather facts (ops)
>   ios_facts:
>   when: ansible_network_os == 'ios'
>
> - name: Gather facts (vyos)
>   vyos_facts:
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/54f1f07f-cefd-474f-950b-7cf181573e7e%40googlegroups.
> com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sGsPcFu9AJs5q%2BuyUuVsg_PUQhM1LFx9AovqTcVNQxdRQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: junos_command

2018-02-08 Thread Ganesh Nalawade
 
> *AnsibleError: ncclient is not installed*

Please install ncclient and retry.

Command to install ncclient using pip:
# pip install ncclient


Regards,
Ganesh

On Friday, 9 February 2018 04:00:01 UTC+5:30, Gennadiy Krokodilov wrote:
>
> Boker Tov Asaf,  did you managed to solve it?
>
> I have exactly the same problem with ex4200 and Ansible 2.3.3. netconf is 
> enabled on port 830 and accessible:
>
> *[ playbooks]# ssh -s -p 830 ansible@juniper_12 netconf*
> *Welcome to Juniper ex4300-48t *
> *Password:*
> **
> **
> **
> *  *
> *urn:ietf:params:netconf:base:1.0*
> *
> urn:ietf:params:netconf:capability:candidate:1.0*
> *
> urn:ietf:params:netconf:capability:confirmed-commit:1.0*
> *
> urn:ietf:params:netconf:capability:validate:1.0*
> *
> urn:ietf:params:netconf:capability:url:1.0?scheme=http,ftp,file*
> *urn:ietf:params:xml:ns:netconf:base:1.0*
> *
> urn:ietf:params:xml:ns:netconf:capability:candidate:1.0*
> *
> urn:ietf:params:xml:ns:netconf:capability:confirmed-commit:1.0*
> *
> urn:ietf:params:xml:ns:netconf:capability:validate:1.0*
> *
> urn:ietf:params:xml:ns:netconf:capability:url:1.0?protocol=http,ftp,file*
> *http://xml.juniper.net/netconf/junos/1.0 
> *
> *http://xml.juniper.net/dmi/system/1.0 
> *
> *  *
> *  11528*
> **
> *]]>]]>*
>
>
> This is debug log:
>
> *2018-02-09 01:13:25,964 p=17223 u=root |  creating new control socket for 
> host 192.168.89.240:830  as user ansible*
> *2018-02-09 01:13:25,965 p=17223 u=root |  control socket path is 
> /root/.ansible/pc/1007ccc67b*
> *2018-02-09 01:13:25,965 p=17223 u=root |  current working directory is 
> /etc/ansible/playbooks*
> *2018-02-09 01:13:25,966 p=17223 u=root |  using connection plugin netconf*
> *2018-02-09 01:13:25,968 p=17223 u=root |  failed to create control socket 
> for host 192.168.89.240*
> *2018-02-09 01:13:25,969 p=17223 u=root |  Traceback (most recent call 
> last):*
> *  File "/opt/ansible/bin/ansible-connection", line 298, in main*
> *server = Server(sf_path, pc)*
> *  File "/opt/ansible/bin/ansible-connection", line 134, in __init__*
> *self.conn = connection_loader.get(play_context.connection, 
> play_context, sys.stdin)*
> *  File "/opt/ansible/lib/ansible/plugins/__init__.py", line 358, in get*
> *self._module_cache[path] = self._load_module_source(name, path)*
> *  File "/opt/ansible/lib/ansible/plugins/__init__.py", line 343, in 
> _load_module_source*
> *module = imp.load_source(full_name, path, module_file)*
> *  File "/opt/ansible/lib/ansible/plugins/connection/netconf.py", line 39, 
> in *
> *raise AnsibleError("ncclient is not installed")*
> *AnsibleError: ncclient is not installed *
>
>
> If you realised how to fix it, please share. 
> Thanks!
>
>
> вторник, 25 апреля 2017 г., 22:31:13 UTC+3 пользователь Asif Iqbal написал:
>>
>> I am failing to make junos_command work
>>
>> 2017-04-25 15:28:49,152 p=4058 u=user |  PLAY [sdwan-routers] 
>> 
>> 2017-04-25 15:28:49,171 p=4058 u=user |  TASK [junos_command] 
>> 
>> 2017-04-25 15:28:49,572 p=4084 u=user |  creating new control socket for 
>> host router.example.net:830 as user None
>> 2017-04-25 15:28:49,572 p=4084 u=user |  control socket path is 
>> /home/user/.ansible/pc/c08d46d021
>> 2017-04-25 15:28:49,572 p=4084 u=user |  current working directory is 
>> /home/user/ansible/sdwan
>> 2017-04-25 15:28:49,572 p=4084 u=user |  using connection plugin netconf
>> 2017-04-25 15:28:49,629 p=4084 u=user |  network_os is set to junos
>> 2017-04-25 15:28:49,629 p=4084 u=user |  ssh connection done, stating 
>> ncclient
>> 2017-04-25 15:28:59,694 p=4084 u=user |  failed to create control socket 
>> for host router.example.net
>> 2017-04-25 15:28:59,695 p=4084 u=user |  Traceback (most recent call 
>> last):
>>   File "/usr/bin/ansible-connection", line 298, in main
>> server = Server(sf_path, pc)
>>   File "/usr/bin/ansible-connection", line 135, in __init__
>> self.conn._connect()
>>   File 
>> "/usr/lib/python2.7/dist-packages/ansible/plugins/connection/netconf.py", 
>> line 95, in _connect
>> device_params={'name': self._network_os}
>>   File "/usr/lib/python2.7/dist-packages/ncclient/manager.py", line 149, 
>> in connect
>> return connect_ssh(*args, **kwds)
>>   File "/usr/lib/python2.7/dist-packages/ncclient/manager.py", line 118, 
>> in connect_ssh
>> session.connect(*args, **kwds)
>>   File "/usr/lib/python2.7/dist-packages/ncclient/transport/ssh.py", line 
>> 372, in connect
>> raise SSHError("Could not open socket to %s:%s" % (host, port))
>> SSHError: Could not open socket to router.example.net:830
>>
>> 2017-04-25 15:29:19,598 p=4084 u=user |  number of connection 

Re: [ansible-project] cannot load cliconf for network os sros

2018-01-11 Thread Ganesh Nalawade
Can you please share the playbook you are running and contents of the log
file?

Regards,
Ganesh

On Thu, Jan 11, 2018 at 9:31 PM, Daniel Heffner 
wrote:

> I've run into a problem when trying to use the sros_command module
>  on
> virtual nokia devices. I enabled logging with log_path
> ,
> and saw that I'm successfully authenticating, but I get the error message
> "cannot load cliconf for network os sros." I did some digging in the
> ansible repo, and found that the folder where ansible is trying to load a
> cliconf from
> 
> does not have an sros file. I don't know whether this is the issue or not,
> but it seems like it might be.
>
> I'd have to write up mock code because this is a project for work, but if
> anyone thinks a particular piece of information would help diagnose the
> issue, I can go get it. General info - I'm running ansible 2.4.0.0 with
> python 2.7.13, the only things in my ansible.cfg file are setup for
> ansible-vault, specifying a default inventory file, setting
> host_key_checking to false, and forks = 25.
>
> Is anyone successfully using the sros_command module? Anyone seen the same
> error message and found a way to fix it?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/911030f7-a6b0-4053-9130-fb530eec09bd%40googlegroups.
> com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sFirVSJSGdvNVoZVpAvpWffZS1BEuLbNZe%3Dz7WrYs4iJA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] network_cli.py help

2017-09-23 Thread Ganesh Nalawade
If I understand the question correctly you want to access port value within
network_cli.py, if yes you can do it by accessing
self._play_context.port

Regards,
Ganesh

On Sat, Sep 23, 2017 at 4:42 AM,  wrote:

> Would anyone happen to know if the ansible_port variable is accessible
> anywhere in this module?  I'd like to make an update (for personal use)
> that differentiates an action based on port.  Thanks for any info!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/48e457f9-62e0-473f-8996-71df4b06c1f4%40googlegroups.
> com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sE%3DK%2Bb1JDQUOVuGfbaYMwSMc3U65fY1qVdLf3MezvoL3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Aggregates in network modules

2017-09-20 Thread Ganesh Nalawade

ios_logging module does not support purge as of now, as you figured it out 
this is a feature under development.

Also, the way currently aggregate works is subject to change in future as 
there are ongoing discussions to
implement this using Ansible loops (something similar to with_*).
Stay tuned for more updates on this.

Regards,
Ganesh

On Thursday, 21 September 2017 01:48:16 UTC+5:30, Steve Kersley wrote:
>
> Am I misunderstanding something with the way aggregates work with network 
> modules on 2.4?
>
> From the 2.4 'coming soon' blog post describing aggregate resources, it 
> mentions using them in playbooks to set state without prior knowledge of 
> configuration.  The example for the ios_vrf module says that the final 
> configuration includes the specified VRFs and removes all other 
> configurations, which sounds very useful.
>
> When I try to use this with the ios_logging module, the logging 
> destinations I listed i nthe aggregate get added to the configuration on 
> the device, but extra pre-existing destinations are not removed. Looking 
> more, I see ios_vrf has a 'purge' statement which ios_logging does not.  Is 
> that intentional, or is this still a feature under development and it 
> simply hasn't been written yet?
>
> Unfortunately there is no way in IOS to reset or delete all logging 
> targets simply - it requires looking at the running config and then 
> explicitly removing each unwanted target.  I guess I could write something 
> to fetch the running config and iterate through lines that match the 
> logging configuration to delete them, but using an aggregate to list all of 
> the desired targets and have ansible remove all others seems far simpler...
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/52e69922-1030-4fc6-b4bb-979ca2c84a1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: fatal: [XXXX]: FAILED! => {"changed": false, "failed": true, "msg": "unable to open shell.

2017-09-20 Thread Ganesh Nalawade


Can you please re-try this on the released version of 2.4 and check if you 
are still seeing this issue.


Regards,
Ganesh

On Wednesday, 23 August 2017 07:18:02 UTC+5:30, Sunil6057 wrote:
>
> Help...
>
> On Monday, August 14, 2017 at 10:52:45 AM UTC-5, Sunil6057 wrote:
>>
>> Hi 
>>
>> When running playbook i am geting (running Ansible 2.4)
>>
>> fatal: [X]: FAILED! => {"changed": false, "failed": true, "msg": 
>> "unable to open shell.
>>
>> Try host_key .False no use..
>>
>> need advice / help
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f9269d1c-aead-4f1f-80aa-abc25d8b4684%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] can ansible gather info on network different devices?

2017-09-19 Thread Ganesh Nalawade
Please refer this link
http://docs.ansible.com/ansible/latest/list_of_network_modules.html
for the list of available network modules.

Use *_facts modules based on platform (eg: ios_facts, junos_facts) which
will fetch device information that you are looking for.

Regards,
Ganesh

On Sun, Sep 17, 2017 at 3:01 PM, איתי מלכה  wrote:

> Hi all,
> I'm new with ansible,
> I need a tool for my LAB at work and wondering if ansible is the one.
> can I gather information on all devices in the same network with ansible?
> the devices are may vary by types OS, and even bare metal devices.
> the info that I need is:
> OS type
> CPU (id number, frequency,cores etc...)
> RAM (type,frequency,how many cards, capacity of each card)
> and more of that kind
>
> the different devices on the network may by with different kind of OS, or
> pre installed OS.
>
>
> thanks,
> Itay.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/37189707-853e-4569-81b8-d2c5b46585e3%40googlegroups.
> com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sHrUPw%2BDmzU99jxHK_%3DFe1MpUmVY%3DLs7_x5Jq74euK6og%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: How to login to Avocent servers and run ansible playbooks on the Network devices which are connected serially

2017-09-19 Thread Ganesh Nalawade
Ansible does not support serial console connection.
However, there are other ways to bootstrap a working ssh connection to the
network device and that can be managed by Ansible.

One possible way is you can use pyserial
 to write a script that connects to
the network device over serial console connection and perform
minimal configuration that enables Ansible to talk to Network device over
ssh.  

Regards,
Ganesh

On Tue, Sep 19, 2017 at 2:41 AM, Mini  wrote:

> I have been redirected from git hub issue list to here. Could someone
> please take a look and suggest:
>
> I am trying to work on a scenario in which I want to access Cisco and
> Juniper network devices and run my ansible network modules like get facts,
> get config, push config commands on them through ansible. The network
> devices are connected via console ports to an Avocent AS6000 server. So
> from a CentOS machine which is my ansible host machine, I want to login to
> the Avocent Server and then access the network devices using ansible
> playbooks. I am not sure how to go about it. Can anyone please guide me. I
> am new to this and sorry if i have posted in the wrong forum.
> Please note: I am able to run playbooks directly through management port
> of the Network devices. This serial console route is a second way to access
> the devices and need to write playbooks in case the management IP goes down
> or is inaccessible.
>
> COMPONENT NAME
> Network Modules
>
> ANSIBLE VERSION
> ansible --version
> ansible 2.3.2.0
> config file = /etc/ansible/ansible.cfg
> configured module search path = Default w/o overrides
> python version = 2.7.5 (default, Nov 6 2016, 00:28:07) [GCC 4.8.5 20150623
> (Red Hat 4.8.5-11)]
> `
> OS / ENVIRONMENT
> Centos7
> Avocent Server ACS6000
> Juniper EX2200
>
> SUMMARY
> Could someone please guide on how do I use ansible to login from my CentOS
> machine to an Avocent server and then navigate to different network devices
> that are connected serially on each port and run playbooks on it. Both
> CentOS and Avocent server is on the same network. I am able to ssh to the
> avocent device, but how do I access the network devices from it.
>
> Manual steps to access:
>
>1. Login to avocent server via ssh through putty.
>2. Go to cli mode. by typing cli command
>3. Go to a particular folder which gives the port list of all the
>connected devices. The port number corresponds to each device connected
>serially to it
>
> Also, here is the playbook to check ssh connectivity:
>
>-
>
>hosts: avocent
>gather_facts: no
>connection: local
>
>tasks:
>-
>
>   name: Check SSH CONNECTIVITY
>   tags: push
>   wait_for: host={{ansible_host}} port=22 timeout=5
>   -
>
>   name: print results
>   debug: var=result
>
> ``
> ACTUAL RESULTS
> ok: [avocentfirst] => {
> "changed": false,
> "elapsed": 0,
> "invocation": {
> "module_args": {
> "active_connection_states": [
> "ESTABLISHED",
> "SYN_SENT",
> "SYN_RECV",
> "FIN_WAIT1",
> "FIN_WAIT2",
> "TIME_WAIT"
> ],
> "connect_timeout": 5,
> "delay": 0,
> "exclude_hosts": null,
> "host": "xx.xx.xx.xx",
> "path": null,
> "port": 22,
> "search_regex": null,
> "sleep": 1,
> "state": "started",
> "timeout": 5
> }
> },
> "path": null,
> "port": 22,
> "search_regex": null,
> "state": "started"
> }
>
> Below is the failure message when I try to acess the network device:
> Failure message:
>
> "msg": "unable to connect to xx.xx.xx.x..: ConnectError(host: xx.xx.xx.xx, 
> msg: Unexpected session close\
>
>
> On Monday, September 18, 2017 at 1:13:18 PM UTC-5, Mini wrote:
>>
>> Hi, I am trying to work on a scenario in which I want to access Cisco and
>> Juniper network devices and run my ansible network modules like get facts,
>> get config, push config commands on them through ansible. The network
>> devices are connected via console ports to an Avocent AS6000 server. So
>> from a CentOS machine, i want to login to the Avocent Server and then
>> access the network device using ansible. I am not sure how to go about it.
>> Can anyone please guide me. I am new to this and sorry if i have posted in
>> the wrong forum.
>> Please note: I am able to run playbooks directly through management port
>> of the Network devices. This serial console route is a second way to access
>> the devices and need to write playbooks in case the management IP goes down
>> or is inaccessible.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/0df41419-c5f7-47b7-9b08-2e35ca91bca5%40googlegroups.
> com
> 

Re: [ansible-project] Is the CISCO--- IOS_STATIC_ROUTE module working ok for you?

2017-09-18 Thread Ganesh Nalawade
It seems Python `ipaddress`  library required for `ios_static_module` is
not installed in your environment.
Can you please install it and retry.

Also, I think the error message should be properly handled in
`ios_static_module` in case of prerequisite library is not
installed.

Can you please raise an issue here https://github.com/ansible/ansible/issues
with required details.

Regards,
Ganesh


On Tue, Sep 19, 2017 at 6:07 AM, MikeM  wrote:

> Hi All,
>
> Having major problems with this module. Can't get it to work + the Ansible
> Docs link appears incomplete on the main site.
> ie..things like...no reference to using it. ie. "Provider"
>
> http://docs.ansible.com/ansible/latest/ios_static_route_module.html
>
>
> ##ERRORS ##
>
> TASK [Configure Default Next Hop] **
> 
> 
> ***
> An exception occurred during task execution. To see the full traceback,
> use -vvv. The error was: ImportError: No module named ipaddress
> fatal: [10.99.4.118]: FAILED! => {"changed": false, "failed": true,
> "module_stderr": "Traceback (most recent call last):\n  File
> \"/tmp/ansible_KSy5yC/ansible_module_ios_static_route.py\", line 105, in
> \nfrom ipaddress import ip_network\nImportError: No module
> named ipaddress\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 0}
>
>
>
> ##-PLAYBOOK USED-##
>
> 
> ###
> Config used-- all Inventory files, group_vars, vault etc. working fine
> with other - IOS playbooks - ie ios_config, ios_command
> 
> ###
>
> ---
> - hosts: labkit
>   gather_facts: no
>   connection: local
>
>   tasks:
>
>   - name: define provider
> set_fact:
>   provider:
> host: "{{ inventory_hostname }}"
> username: "{{ ansible_user }}"
> password: "{{ ansible_ssh_pass }}"
> authorize: yes
> auth_pass: "{{ ansible_ssh_pass }}"
> timeout: 30
>
> #--
>
>   - name: Configure Test Route
> ios_static_route:
>   provider: "{{ provider }}"
>   prefix: 8.8.8.0
>   mask: 255.255.255.0
>   next_hop: "{{exit_int}}"
>
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/987b994a-f0c3-4303-a817-0a2c0f927ea4%40googlegroups.
> com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sGgMO7SNKSTirSCuUQVjHJBYD%2BB0EjEgzk%2B189N_WjNvg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Cisco NXOS : Parsing SNMP trap hosts from command output

2017-07-19 Thread Ganesh Nalawade
If I understand this correctly, you want to run 2nd task (snmp update)
based on the output of 1st task (get current snmp hosts).

One way to do this is to use 'register' keyword to store the output of 1st
task and use 'when' conditional to run the second task.

  - name: get current snmp hosts
register: command_output
ios_command:
  commands: "show snmp host"
  provider: "{{ ios_provider }}"
*register: result*

  - name: snmp update
ios_config:
  src: "./configs/snmp.conf"
  provider: "{{ ios_provider }}"
  match: none
*when: "' in result.stdout[0]"*

On Wed, Jul 19, 2017 at 6:10 PM, 'Gavin McKee' via Ansible Project <
ansible-project@googlegroups.com> wrote:

> Hi Guys,
>
> Can someone advise on the following?
>
> I need to update (standardize) the SNMP trap receivers throughout the
> network.  Given that i'm running Cisco NX OS on the 3500 platform I can't
> delete the old SNMP trap receiver configuration without specifying the
> hosts.  So I need to run a command and then parse the hosts from it.  *I'd
> like to then use the hosts in the returned output to delete the trap
> receivers before adding the new correct receivers.*
>
> ---
>   - name: Update the SNMP information on the network
> hosts: lab
> gather_facts: no
> connection: local
>
> vars:
>   trapdests: []
>   ios_provider:
> username: "{{ user }}"
> password: "{{ password }}"
> host: "{{ inventory_hostname }}"
>
> tasks:
>   - name: get current snmp hosts
> register: command_output
> ios_command:
>   commands: "show snmp host"
>   provider: "{{ ios_provider }}"
>
>   - name: snmp update
> ios_config:
>   src: "./configs/snmp.conf"
>   provider: "{{ ios_provider }}"
>   match: none
> before: "default snmp-server"
>
>   - debug: msg="{{command_output.stdout_lines}}"
>
>
> Here is my output to this stage
>
>
> < PLAY [Update the SNMP information on the network] >
>  ---
> \   ^__^
>  \  (oo)\___
> (__)\   )\/\
> ||w |
> || ||
>
>  ___
> < TASK [test nxos snmp] >
>  ---
> \   ^__^
>  \  (oo)\___
> (__)\   )\/\
> ||w |
> || ||
>
>  [WARNING]: argument host has been deprecated and will be removed in a
> future version
>
> changed: [lab-xxx-xxx-x]
> changed: [10.70.253.249]
>  ___
> < TASK [get current snmp hosts] >
>  ---
> \   ^__^
>  \  (oo)\___
> (__)\   )\/\
> ||w |
> || ||
>
> ok: [10.70.253.249]
> ok: [lab--xxx-x]
>  
> < TASK [snmp update] >
>  
> \   ^__^
>  \  (oo)\___
> (__)\   )\/\
> ||w |
> || ||
>
> changed: [10.70.253.249]
> changed: [lab-xxx-xxx-1x]
>  __
> < TASK [debug] >
>  --
> \   ^__^
>  \  (oo)\___
> (__)\   )\/\
> ||w |
> || ||
>
> ok: [10.70.253.249] => {
> "msg": [
> [
> "Source interface: mgmt0-
> --",
> "HostPort Version  Level  Type
> SecName ",
> "---
> ",
> "10.15.24.118162  v2c  noauth trap
> x   ",
> "Use VRF: management",
> "---
> ",
> "10.30.130.131   162  v2c  noauth trap
> ",
> "Use VRF: management",
> "---
> ",
> "10.50.74.49 162  v2c  noauth trap
> x   ",
> "Use VRF: management",
> "---
> ",
> "10.50.74.50 162  v2c  noauth trap
> ",
> "Use VRF: management",
> "---
> ",
> "1.1.1.1 162  v2c  noauth trap
> TESTING ",
> "---
> "
> ]
> ]
> }
> ok: [lab-db9-eng-acc01x] => {
> "msg": [
> [
> "--

Re: [ansible-project] Problems updating Junos configuration with new modules/versions

2017-06-28 Thread Ganesh Nalawade
As per logs, value of `src` parameter is null
"src": null

It seems there is an issue in your playbook.
Can you please make below change in the playbook and retry.

junos_config:
  provider: "{{ junos_creds }}"
  src: "{{ junos_conf }}"
  update: override
  comment: Test pushed by ansible


Regards,
Ganesh

On Wed, Jun 28, 2017 at 2:24 AM, 'Siegfried' via Ansible Project <
ansible-project@googlegroups.com> wrote:

> Hi,
>
> I had been using the Juniper.junos modules from Ansible Galaxy
> successfully for a while now, but had been asked to update my python
> environment to corporate standards through Conda, which included newer
> versions of most modules. Ever since the update, I have been unable to use
> either the native junos_config module, nor the old junos_install_config.
> The junos_install_config now complains about the following, using that the
> exact same configuration files as before:
>
> /private/etc/ansible/roles/Juniper.junos/library/junos_install_config:198:
> SyntaxWarning: import * only allowed at module level
>   def _load_via_netconf(module):
>
> {"msg": "Error: Module unable to decode valid JSON on stdin.  Unable to
> figure out what parameters were passed", "failed": true}
>
> Because of that error, I decided that I might as well update the playbooks
> to use the new native modules instead. However, when I try to push the
> configuration, he're the output I get:
> TASK [Pushing config ... please wait] **
> 
> 
> 
> fatal: [switch]: FAILED! => {"changed": false, "failed": true, "msg": "one
> of candidate or rollback must be specified"}
>
> I looked a bit at the code to find what was candidate variable and as I
> expected, it seems to point to what src is. I've also validated through
> debug that the path is valid, so I really have no idea where to look
> afterwards.
>
> Here's the playbook:
> - name: Apply configuration
>   hosts: all
>   connection: local
>   gather_facts: no
>   vars:
> junos_creds:
>   username: "{{ ansible_ssh_user }}"
>   host: "{{ ansible_ssh_host }}"
>   port: "{{ netconf_port }}"
>   tasks:
> - name: Pushing config ... please wait
>   when: config_changed is defined
>   junos_config: >
>   provider: "{{ junos_creds }}"
>   src: {{ junos_conf }}
>   update: override
>   comment: Test pushed by ansible
>
>
> Here's the detailed debug:
>
>  29707 1498596207.19598: ANSIBALLZ: Using lock for junos_config
>  29707 1498596207.19683: ANSIBALLZ: Acquiring lock
>  29707 1498596207.19731: ANSIBALLZ: Lock acquired: 4405365776
>  29707 1498596207.19772: ANSIBALLZ: Creating module
>  29707 1498596207.33891: ANSIBALLZ: Writing module
>  29707 1498596207.33985: ANSIBALLZ: Renaming module
>  29707 1498596207.34068: ANSIBALLZ: Done creating module
>  29707 1498596207.34157: _low_level_execute_command(): starting
>  29707 1498596207.34187: _low_level_execute_command(): executing: /bin/sh
> -c 'echo ~ && sleep 0'
>  29707 1498596207.34226: in local.exec_command()
>  29707 1498596207.34252: opening command with Popen()
>  29707 1498596207.34696: done running command with Popen()
>  29707 1498596207.34801: getting output with communicate()
>  29707 1498596207.35497: done communicating
>  29707 1498596207.35543: done with local.exec_command()
>  29707 1498596207.35586: _low_level_execute_command() done: rc=0,
> stdout=/Users/user
> , stderr=
>  29707 1498596207.35624: _low_level_execute_command(): starting
>  29707 1498596207.35659: _low_level_execute_command(): executing: /bin/sh
> -c '( umask 77 && mkdir -p "` echo /Users/user/.ansible/tmp/
> ansible-tmp-1498596207.34-16034423383708 `" && echo
> ansible-tmp-1498596207.34-16034423383708="` echo /Users/user/.ansible/tmp/
> ansible-tmp-1498596207.34-16034423383708 `" ) && sleep 0'
>  29707 1498596207.35716: in local.exec_command()
>  29707 1498596207.35778: opening command with Popen()
>  29707 1498596207.36368: done running command with Popen()
>  29707 1498596207.36466: getting output with communicate()
>  29707 1498596207.38038: done communicating
>  29707 1498596207.38113: done with local.exec_command()
>  29707 1498596207.38160: _low_level_execute_command() done: rc=0,
> stdout=ansible-tmp-1498596207.34-16034423383708=/Users/user/
> .ansible/tmp/ansible-tmp-1498596207.34-16034423383708
> , stderr=
>  29707 1498596207.38197: transferring module to remote
> /Users/user/.ansible/tmp/ansible-tmp-1498596207.34-
> 16034423383708/junos_config.py
>  29707 1498596207.38477: done transferring module to remote
>  29707 1498596207.38530: _low_level_execute_command(): starting
>  29707 1498596207.38557: _low_level_execute_command(): executing: /bin/sh
> -c 'chmod u+x 
> /Users/user/.ansible/tmp/ansible-tmp-1498596207.34-16034423383708/
> /Users/user/.ansible/tmp/ansible-tmp-149

Re: [ansible-project] Ansible 2.3.0 Connecting to Cisco IOS router

2017-06-22 Thread Ganesh Nalawade
You need to mention connection type local for network devices.

---
- hosts: lab
  connection: local

The credentials to connect to remote network device can be mentioned either
in playbook within a provider
 or in host
inventory  file.


Regards,
Ganesh


On Thu, Jun 22, 2017 at 12:25 PM, Kai Stian Olstad <
ansible-project+l...@olstad.com> wrote:

> On 20.06.2017 01:26, Patrick Matheny wrote:
>
>> I'm very new to Ansible.  I have a small lab running and I'm trying to
>> evaluate the use of Ansible for making network changes.  I have a
>> workstations running CentOS Linux release 7.3.1611 and Ansible 2.3.0 as a
>> fresh install.  I'm using a cisco 819 router running Cisco IOS Software,
>> C800 Software (C800-UNIVERSALK9-M), Version 15.3(3)M.3. I can SSH from the
>> workstation to the router from the work station and via putty on a windows
>> 10 machine  but when I try a connection test I get the following:
>>
>> [pat@new-host-8 ~]$ansible all -m ping
>> 192.168.1.142 | UNREACHABLE! => {
>> "changed": false,
>> "msg": "Failed to connect to the host via ssh: Connection closed\r\n",
>> "unreachable": true
>> }
>>
>
> To run ansible on remote host the host need to support Python.
> When using the ping module Ansible creates a little Python script that is
> copied to the remote and then runs the python script on the remote host.
> But network equipment typically doesn't support Python.
>
> Ansible has support for Cisco, the iso_* modules.
> These modules are running on the Ansible control machine and do a ssh to
> the Cisco and runs the appropriate commands on the cli.
>
> --
> Kai Stian Olstad
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/ansible-project/1d2e654d608818eae65d0ae0d3ae8f76%40olstad.com.
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sGjJuDGDi_csMFMz%3DSt5ibe%2BsxpndQrcaz_m2thKmL0cQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Analysing large XML objects

2017-05-30 Thread Ganesh Nalawade
Here are some sample examples of applying conditional check for values in
xml hierarchy.

https://github.com/ansible/ansible/blob/devel/test/integration/targets/junos_command/tests/netconf_xml/equal.yaml
https://github.com/ansible/ansible/blob/devel/test/integration/targets/junos_command/tests/netconf_xml/greaterthan.yaml

Regards,
Ganesh





On Tue, May 30, 2017 at 12:10 PM, Dick Visser  wrote:

> I've used https://github.com/cmprescott/ansible-xml with some success,
> but that module has its issues.
> I do come across more and more cases where I need to manipulate XML,
> so when it works its a clean option.
>
> Dick
>
> On 30 May 2017 at 01:41, Pshem Kowalczyk  wrote:
> > Hi,
> >
> > I have to analyse relatively large XML objects (Juniper configs). I'd
> like
> > to check for presence of certain trees, values and attributes. I could
> write
> > a lookup plugin but that feels like a relatively complicated way to
> solve a
> > simple problem. Even just loading it as a var would make it easier, but I
> > don't think there is a "clean" ansible way of doing it. How one deals
> with
> > XML in ansible?
> >
> > kind regards
> > Pshem
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to ansible-project+unsubscr...@googlegroups.com.
> > To post to this group, send email to ansible-project@googlegroups.com.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/ansible-project/
> CAEaZiRXcnauZMFf368DH1hoNERO3-RRFesNNZVjCG4%3DtRSSPJQ%40mail.gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> Dick Visser
> Sr. System & Network Engineer
> GÉANT
>
> Want to join us? We're hiring: https://www.geant.org/jobs
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/CAL8fbwPupjqDvuKvOidNH24%
> 2BiTEdpUJob6zR2nwwRxxxwQcyGA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sHyocoKOZH7C4Ow9X%2B_VJ8WmPr%3DSNyGi0O4k-G9QckY8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: How to use regex to match a response using the expect module

2017-03-01 Thread Ganesh Nalawade
Hi David,

Changing the yml file as below at least loads the file. As per docs the key
under responses is python regex so I think it should work.

- name: Access member 0
  expect:
command: 'request session member 0'
responses:
  ^---\sJUNOS.+\n(warning.+\n){5}\{((backup)|(linecard)):((1)|(2))\}:
start shell user root


However, I am trying to understand the need to use 'expect' module to run
junos operational command.
Can't it be run using 'junos_command' module? Does running this command
prompts for an interactive input?

Regards,
Ganesh

On Tue, Feb 28, 2017 at 6:29 PM, David Williams 
wrote:

> Thank you Matt, I have looked at the modules but I'm trying to drop down
> into the linux shell and change some file permissions within the directory
> structure.  It doesn't look like the module can do that.  Thanks for trying
> though!  Any help is always appreciated.
>
>
> On Tuesday, February 28, 2017 at 12:22:13 AM UTC-6, Matt Clay wrote:
>>
>> David,
>>
>> I know this isn't what you asked, but since it looks like you're working
>> with JUNOS I thought I'd check to see if you've already looked at Ansible's
>> JUNOS support:
>>
>> https://docs.ansible.com/ansible/list_of_network_modules.html#junos
>>
>>  - Matt
>>
>> On Monday, February 27, 2017 at 3:57:16 PM UTC-8, David Williams wrote:
>>>
>>> I am stumped...I have been trying to use the expect module and format
>>> the expected response as a regex that can match multiple responses.   I see
>>> posts all over where people are trying to match the response exactly and
>>> have to escape the regex special characters.  It seems nobody writes regex
>>> to match multiple responses.  Is this not possible?
>>>
>>> *Playbook*
>>>
>>> - name: Clear Permissions on /var/etc/pam.conf
>>>   hosts: juniper_ex4200
>>>   tasks:
>>> - name: Access member 0
>>>   expect:
>>> command: 'request session member 0'
>>> responses: "^---\sJUNOS.+\n(warning.+\n){
>>> 5}\{((backup)|(linecard)):((1)|(2))\}": "start shell user root"
>>>
>>>
>>> *Error*
>>>
>>> ERROR! Syntax Error while loading YAML.
>>>
>>>
>>> The error appears to have been in '/home/dwilliams/ex4200_permis
>>> sions_clear/ex4200_permissions_clear': line 8, column 25, but may
>>> be elsewhere in the file depending on the exact syntax problem.
>>>
>>> The offending line appears to be:
>>>
>>> command: 'request session member 0'
>>> responses: "^---\sJUNOS.+\n(warning.+\n){
>>> 5}\{((backup)|(linecard)):((1)|(2))\}"
>>> ^ here
>>> This one looks easy to fix.  It seems that there is a value started
>>> with a quote, and the YAML parser is expecting to see the line ended
>>> with the same kind of quote.  For instance:
>>>
>>> when: "ok" in result.stdout
>>>
>>> Could be written as:
>>>
>>>when: '"ok" in result.stdout'
>>>
>>> Or equivalently:
>>>
>>>when: "'ok' in result.stdout"
>>>
>>> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/8953d535-057d-48ea-8908-157fd4cb2cdb%40googlegroups.
> com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B6y2sFyXTfJxg0jRrB6FjnUHSLWGxUpHcUxoLXdwAcHug6_5A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.