Hello,

I have a playbook here which seems to do what it needs to do but hangs 
It actually copies the file using ftp  but cannot find a way to exit out of 
the program

---
- name: backup of juniper using expect
  hosts: juniper
  connection: local
  tasks:
   - name: copy running config to ftp server
     expect:
      command: ssh [email protected]
      responses:
        Password: xxxxx#
        admin@POD1_SRX210>: file copy /config/juniper.conf.49.gz 
ftp://ansible:[email protected]/juniper.conf.49.gz
        ftp://ansible:[email protected]/juniper.co100% of 1024  B   84 
kBps\nadmin@POD1_SRX210>: exit

OUTPUT


ansible@ansible-new:/etc/ansible$ ansible-playbook -i hosts 
backup-juniper-expect.yml  -vvv
ansible-playbook 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = 
[u'/home/ansible/.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-playbook
  python version = 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 
20160609]
Using /etc/ansible/ansible.cfg as config file
Parsed /etc/ansible/hosts inventory source with ini plugin
PLAYBOOK: backup-juniper-expect.yml 
********************************************
1 plays in backup-juniper-expect.yml
PLAY [backup of juniper using expect] 
******************************************
TASK [Gathering Facts] 
*********************************************************
Using module file 
/usr/lib/python2.7/dist-packages/ansible/modules/system/setup.py
<10.201.250.41> ESTABLISH LOCAL CONNECTION FOR USER: ansible
<10.201.250.41> EXEC /bin/sh -c 'echo ~ && sleep 0'
<10.201.250.41> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo 
/home/ansible/.ansible/tmp/ansible-tmp-1521801893.62-242955740702676 `" && 
echo ansible-tmp-1521801893.62-242955740702676="` echo 
/home/ansible/.ansible/tmp/ansible-tmp-1521801893.62-242955740702676 `" ) 
&& sleep 0'
<10.201.250.41> PUT /tmp/tmpc6YMbQ TO 
/home/ansible/.ansible/tmp/ansible-tmp-1521801893.62-242955740702676/setup.py
<10.201.250.41> EXEC /bin/sh -c 'chmod u+x 
/home/ansible/.ansible/tmp/ansible-tmp-1521801893.62-242955740702676/ 
/home/ansible/.ansible/tmp/ansible-tmp-1521801893.62-242955740702676/setup.py 
&& sleep 0'
<10.201.250.41> EXEC /bin/sh -c '/usr/bin/python 
/home/ansible/.ansible/tmp/ansible-tmp-1521801893.62-242955740702676/setup.py; 
rm -rf 
"/home/ansible/.ansible/tmp/ansible-tmp-1521801893.62-242955740702676/" > 
/dev/null 2>&1 && sleep 0'
ok: [10.201.250.41]
META: ran handlers
TASK [copy running config to ftp server] 
***************************************
task path: /etc/ansible/backup-juniper-expect.yml:7
Using module file 
/usr/lib/python2.7/dist-packages/ansible/modules/commands/expect.py
<10.201.250.41> ESTABLISH LOCAL CONNECTION FOR USER: ansible
<10.201.250.41> EXEC /bin/sh -c 'echo ~ && sleep 0'
<10.201.250.41> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo 
/home/ansible/.ansible/tmp/ansible-tmp-1521801893.94-111637507774765 `" && 
echo ansible-tmp-1521801893.94-111637507774765="` echo 
/home/ansible/.ansible/tmp/ansible-tmp-1521801893.94-111637507774765 `" ) 
&& sleep 0'
<10.201.250.41> PUT /tmp/tmpamRP0L TO 
/home/ansible/.ansible/tmp/ansible-tmp-1521801893.94-111637507774765/expect.py
<10.201.250.41> EXEC /bin/sh -c 'chmod u+x 
/home/ansible/.ansible/tmp/ansible-tmp-1521801893.94-111637507774765/ 
/home/ansible/.ansible/tmp/ansible-tmp-1521801893.94-111637507774765/expect.py 
&& sleep 0'
<10.201.250.41> EXEC /bin/sh -c '/usr/bin/python 
/home/ansible/.ansible/tmp/ansible-tmp-1521801893.94-111637507774765/expect.py; 
rm -rf 
"/home/ansible/.ansible/tmp/ansible-tmp-1521801893.94-111637507774765/" > 
/dev/null 2>&1 && sleep 0'
^CProcess WorkerProcess-2:
Traceback (most recent call last):
  File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in 
_bootstrap
    self.run()
  File 
"/usr/lib/python2.7/dist-packages/ansible/executor/process/worker.py", line 
118, in run
    self._rslt_q
  File 
"/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 
130, in run
    res = self._execute()
  File 
"/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 
528, in _execute
    result = self._handler.run(task_vars=variables)
  File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/normal.py", 
line 45, in run
    results = merge_hash(results, self._execute_module(tmp=tmp, 
task_vars=task_vars, wrap_async=wrap_async))
  File 
"/usr/lib/python2.7/dist-packages/ansible/plugins/action/__init__.py", line 
740, in _execute_module
    res = self._low_level_execute_command(cmd, sudoable=sudoable, 
in_data=in_data)
  File 
"/usr/lib/python2.7/dist-packages/ansible/plugins/action/__init__.py", line 
889, in _low_level_execute_command
    rc, stdout, stderr = self._connection.exec_command(cmd, 
in_data=in_data, sudoable=sudoable)
  File 
"/usr/lib/python2.7/dist-packages/ansible/plugins/connection/local.py", 
line 133, in exec_command
    stdout, stderr = p.communicate(in_data)
  File "/usr/lib/python2.7/subprocess.py", line 800, in communicate
    return self._communicate(input)
  File "/usr/lib/python2.7/subprocess.py", line 1417, in _communicate
    stdout, stderr = self._communicate_with_poll(input)
  File "/usr/lib/python2.7/subprocess.py", line 1471, in 
_communicate_with_poll
    ready = poller.poll()
KeyboardInterrupt
 [ERROR]: User interrupted execution

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a2c95db6-38fe-4575-9701-e0a0a26e3765%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to