Hi I have a task which requires ftp a file from remote box to ansible controlled machine.I am using expect based FTP,so want the ansible to fail if file does not exist on the remote box.Following is my code. I am using a register variable.But i dont see the debug displaying the register contents.
- name: copy files remote
shell: |
set timeout 1000
spawn ftp {{ buildIP }}
expect ":"
send "{{ build_user }}\n"
expect "ssword:"
send "{{ build_password }}\n"
expect "ftp>"
send "get {{ build_path }} /root/Desktop/Sanity/{{ TID }}/{{ Image_dir }}/{{ build_filename }}\n"
expect "ftp>"
send "quit\n"
set multiPrompt {[#$]}
expect -re $multiPrompt
exit 0
args:
executable: /usr/bin/expect
register: shell_output
tags: copy_source_code
- debug:
var: shell_output.stdout_lines