Re: [ansible-project] expect module hangs

2018-03-07 Thread 'Daley Okuwa' via Ansible Project
Hi,

A big thanks you it worked

Very Much appreciated 

On Wednesday, March 7, 2018 at 12:34:11 PM UTC, Kai Stian Olstad wrote:

> On 07.03.2018 12:40, 'Daley Okuwa' via Ansible Project wrote: 
> > Hi, 
> > 
> > I have just done this manually on the switch and it worked 
> > 
> > User Access Verification 
> > Username: admin 
> > Password: 
> > POD2_C3560#copy running-config ftp: 
> > Address or name of remote host []? 10.241.11.237 
> > Destination filename [pod2_c3560-confg]? 
> > Writing pod2_c3560-confg !! 
> > 8063 bytes copied in 1.108 secs (7277 bytes/sec) 
> > POD2_C3560# 
>
> I think you forgot the exit at the end, so I included it. 
>
>- name: run show command via Telnet using the expect module 
>  expect: 
>command: telnet 10.101.250.12 
>responses: 
>  Username: admin 
>  Password: x 
>  POD2_C3560#: 
>- copy running-config ftp 
>- exit 
>  Address or name of remote host \[\]\?: 10.241.11.237 
>  Destination filename \[.*\]\?: '' 
>
>
> The '' is the same as just pressing enter. 
> I have escaped []? with backslash since they are character with meaning 
> in regex. 
> Since the prompt POD2_C3560# comes up two times this is a list with the 
> responses. 
>
>
>
> -- 
> 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/msgid/ansible-project/ae4e9cc1-2a89-40ad-b3f0-d25347cf1513%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] expect module hangs

2018-03-07 Thread Kai Stian Olstad

On 07.03.2018 12:40, 'Daley Okuwa' via Ansible Project wrote:

Hi,

I have just done this manually on the switch and it worked

User Access Verification
Username: admin
Password:
POD2_C3560#copy running-config ftp:
Address or name of remote host []? 10.241.11.237
Destination filename [pod2_c3560-confg]?
Writing pod2_c3560-confg !!
8063 bytes copied in 1.108 secs (7277 bytes/sec)
POD2_C3560#


I think you forgot the exit at the end, so I included it.

  - name: run show command via Telnet using the expect module
expect:
  command: telnet 10.101.250.12
  responses:
Username: admin
Password: x
POD2_C3560#:
  - copy running-config ftp
  - exit
Address or name of remote host \[\]\?: 10.241.11.237
Destination filename \[.*\]\?: ''


The '' is the same as just pressing enter.
I have escaped []? with backslash since they are character with meaning 
in regex.
Since the prompt POD2_C3560# comes up two times this is a list with the 
responses.




--
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/msgid/ansible-project/0acd2a8471c6fdc8bba9b7d66dd5aff6%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] expect module hangs

2018-03-07 Thread 'Daley Okuwa' via Ansible Project
Hi,

I have just done this manually on the switch and it worked

User Access Verification
Username: admin
Password:
POD2_C3560#copy running-config ftp:
Address or name of remote host []? 10.241.11.237
Destination filename [pod2_c3560-confg]?
Writing pod2_c3560-confg !!
8063 bytes copied in 1.108 secs (7277 bytes/sec)
POD2_C3560#

Thanks




On Tuesday, March 6, 2018 at 7:19:42 PM UTC, Kai Stian Olstad wrote:

> On Tuesday, 6 March 2018 18.15.12 CET 'Daley Okuwa' via Ansible Project 
> wrote: 
> > Hello 
> > 
> > I have a config to copy config to a tftp server 
> > but with the expect module 
> > it just hangs no error 
> > it logs it successful with telnet( I can see it in the logs) but does 
> not 
> > copy ( I have tested it manually with ftp) 
> > please tell me where I am going wrong 
> > 
> > --- 
> > - hosts: cisco 
> >   connection: local 
> >   gather_facts: yes 
> >   ignore_errors: yes 
> >   tasks: 
> > - name: run show command via Telnet using the expect module 
> >   expect: 
> >command: telnet 10.101.250.12 
> >responses: 
> >  Username: admin 
> >  Password: x 
> >  POD2_C3560#: 
> >command: copy running-config ftp 
> >responses: 
> >Address or name of remote host []?: 10.241.11.237 
> >Destination filename [pod2_c3560-confg]?: pod2_c3560-confg 
> >command: exit 
>
> It looks like you are trying with levels of responses, that is not 
> supported. 
> prompt bellow is also called question as in the documentation. 
>
> - expect: 
> command: tel... 
> responses: 
>   prompt-1: answer-1 
>   prompt-2: answer-2 
>   prompt-3: 
> - answer-3 
> - answer-4 
>   prompt-4: 
> - anser-5 
>
> When an prompt appears more than once you need a list of answers like 
> prompt-3 about, the first time it sees prompt-3 expect will respond with 
> answer-3, the nest time it sees prompt-3 it will respond with answer-4. 
> The prompt/question is regex, so all regex special character like ()[]? 
> need to be escaped if you have those character in that in the prompt. 
>
> It you don't get it working with this you need to provide the complete 
> output when you do this manually. 
>
> -- 
> 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/msgid/ansible-project/e5c05f45-a04f-4012-a784-7210c5588b12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] expect module hangs

2018-03-07 Thread Kai Stian Olstad

On 07.03.2018 11:26, 'Daley Okuwa' via Ansible Project wrote:

thanks

when I run this I also get error message after amending the yaml script

---
- hosts: cisco
  connection: local
  gather_facts: yes
  ignore_errors: yes
  tasks:
- name: run show command via Telnet using the expect module
  expect:
   command: telnet 10.101.250.12
   responses:
 Username: admin
 Password: xx
   command: copy running-config ftp
 Address or name of remote host:
   -  10.241.11.237
 Destination filename pod2_c3560-confg:
   -  pod2_c3560-confg
 command: exit



You can only have one command: in expect.

If command is a prompt its not correctly indented.
And one prompt can only be listed once, the different responses is a 
list to that prompt.


If you would like more help you _need_ to provide the complete output 
when you do this task manually, without it this is futile.


--
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/msgid/ansible-project/34a5dd72a432c7ac1d891689eddb68cf%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] expect module hangs

2018-03-07 Thread 'Daley Okuwa' via Ansible Project
thanks

when I run this I also get error message after amending the yaml script

---
- hosts: cisco
  connection: local
  gather_facts: yes
  ignore_errors: yes
  tasks:
- name: run show command via Telnet using the expect module
  expect:
   command: telnet 10.101.250.12
   responses:
 Username: admin
 Password: xx
   command: copy running-config ftp
 Address or name of remote host:
   -  10.241.11.237
 Destination filename pod2_c3560-confg:
   -  pod2_c3560-confg
 command: exit


Error message
ERROR! Syntax Error while loading YAML.

The error appears to have been in '/etc/ansible/backup-cisconew12-ine 14, 
column 40, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
   command: copy running-config ftp
 Address or name of remote host:
   ^ here
exception type: 
exception: mapping values are not allowed in this context
  in "", line 14, column 40




On Tuesday, March 6, 2018 at 7:19:42 PM UTC, Kai Stian Olstad wrote:

> On Tuesday, 6 March 2018 18.15.12 CET 'Daley Okuwa' via Ansible Project 
> wrote: 
> > Hello 
> > 
> > I have a config to copy config to a tftp server 
> > but with the expect module 
> > it just hangs no error 
> > it logs it successful with telnet( I can see it in the logs) but does 
> not 
> > copy ( I have tested it manually with ftp) 
> > please tell me where I am going wrong 
> > 
> > --- 
> > - hosts: cisco 
> >   connection: local 
> >   gather_facts: yes 
> >   ignore_errors: yes 
> >   tasks: 
> > - name: run show command via Telnet using the expect module 
> >   expect: 
> >command: telnet 10.101.250.12 
> >responses: 
> >  Username: admin 
> >  Password: x 
> >  POD2_C3560#: 
> >command: copy running-config ftp 
> >responses: 
> >Address or name of remote host []?: 10.241.11.237 
> >Destination filename [pod2_c3560-confg]?: pod2_c3560-confg 
> >command: exit 
>
> It looks like you are trying with levels of responses, that is not 
> supported. 
> prompt bellow is also called question as in the documentation. 
>
> - expect: 
> command: tel... 
> responses: 
>   prompt-1: answer-1 
>   prompt-2: answer-2 
>   prompt-3: 
> - answer-3 
> - answer-4 
>   prompt-4: 
> - anser-5 
>
> When an prompt appears more than once you need a list of answers like 
> prompt-3 about, the first time it sees prompt-3 expect will respond with 
> answer-3, the nest time it sees prompt-3 it will respond with answer-4. 
> The prompt/question is regex, so all regex special character like ()[]? 
> need to be escaped if you have those character in that in the prompt. 
>
> It you don't get it working with this you need to provide the complete 
> output when you do this manually. 
>
> -- 
> 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/msgid/ansible-project/00960e7b-7081-4853-afed-dc5e5d64c220%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] expect module hangs

2018-03-06 Thread Kai Stian Olstad
On Tuesday, 6 March 2018 18.15.12 CET 'Daley Okuwa' via Ansible Project wrote:
> Hello
> 
> I have a config to copy config to a tftp server
> but with the expect module 
> it just hangs no error 
> it logs it successful with telnet( I can see it in the logs) but does not 
> copy ( I have tested it manually with ftp)
> please tell me where I am going wrong 
> 
> ---
> - hosts: cisco
>   connection: local
>   gather_facts: yes
>   ignore_errors: yes
>   tasks:
> - name: run show command via Telnet using the expect module
>   expect:
>command: telnet 10.101.250.12
>responses:
>  Username: admin
>  Password: x
>  POD2_C3560#:
>command: copy running-config ftp
>responses:
>Address or name of remote host []?: 10.241.11.237
>Destination filename [pod2_c3560-confg]?: pod2_c3560-confg
>command: exit

It looks like you are trying with levels of responses, that is not supported.
prompt bellow is also called question as in the documentation.

- expect:
command: tel...
responses:
  prompt-1: answer-1
  prompt-2: answer-2
  prompt-3: 
- answer-3
- answer-4
  prompt-4:
- anser-5

When an prompt appears more than once you need a list of answers like prompt-3 
about, the first time it sees prompt-3 expect will respond with answer-3, the 
nest time it sees prompt-3 it will respond with answer-4. 
The prompt/question is regex, so all regex special character like ()[]? need to 
be escaped if you have those character in that in the prompt.

It you don't get it working with this you need to provide the complete output 
when you do this manually.

-- 
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/msgid/ansible-project/5744260.oNvP4A7pRp%40x1.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] expect module hangs

2018-03-06 Thread Brian Coca
Probably due to an unexpected output? Also you might want to try the
telnet module to communicate directly.



-- 
--
Brian Coca

-- 
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/CACVha7fsCznA7ebcJGGyeMwuRxaTSS-vNKk%3DMm30u2p8xTFQfg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] expect module hangs

2018-03-06 Thread 'Daley Okuwa' via Ansible Project
Hello

I have a config to copy config to a tftp server
but with the expect module 
it just hangs no error 
it logs it successful with telnet( I can see it in the logs) but does not 
copy ( I have tested it manually with ftp)
please tell me where I am going wrong 

---
- hosts: cisco
  connection: local
  gather_facts: yes
  ignore_errors: yes
  tasks:
- name: run show command via Telnet using the expect module
  expect:
   command: telnet 10.101.250.12
   responses:
 Username: admin
 Password: x
 POD2_C3560#:
   command: copy running-config ftp
   responses:
   Address or name of remote host []?: 10.241.11.237
   Destination filename [pod2_c3560-confg]?: pod2_c3560-confg
   command: exit

-- 
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/158b4c59-7d44-4114-aac2-1aed851c92d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.