title: Ansible play to upload ftp file using lftp
body: <p>I setup ftp server using ansible and verified it's working by manually doing lftp from my localhost</p>
  
  <p>I uploaded a file using put and was able to find the file in ftp server, when i do ls.</p>
  
  <p>I wrote a play to upload file to ftp server and it returned success always. However, i can't find the file that I uploaded using my play. Then i edited my play to display result register and found a warning. See below</p>
  
  <pre><code>---
  - name: test ftp upload
    hosts: localhost
    tasks:
      - name: install lftp
        yum:
          name: lftp
      - name: upload file
        shell: &gt;
          lftp ansible1.example.com&lt;&lt;EOF
          cd pub
          put /etc/hosts
          bye
          EOF
        register: result
  
      - name: display result
        debug:
          var: result
  </code></pre>
  
  <p>Below is the output I got after running the play</p>
  
  <pre><code>PLAY [test ftp upload] ****************************************************************************************************************************************************************
  
  TASK [Gathering Facts] ****************************************************************************************************************************************************************
  ok: [localhost]
  
  TASK [install lftp] *******************************************************************************************************************************************************************
  ok: [localhost]
  
  TASK [upload file] ********************************************************************************************************************************************************************
  changed: [localhost]
  
  TASK [display result] *****************************************************************************************************************************************************************
  ok: [localhost] =&gt; {
      "result": {
          "changed": true,
          "cmd": "lftp ansible1.example.com&lt;&lt;EOF cd pub put /etc/hosts bye EOF\n",
          "delta": "0:00:00.010150",
          "end": "2020-04-04 09:15:26.305530",
          "failed": false,
          "rc": 0,
          "start": "2020-04-04 09:15:26.295380",
          "stderr": "/bin/sh: warning: here-document at line 0 delimited by end-of-file (wanted `EOF')",
          "stderr_lines": [
              "/bin/sh: warning: here-document at line 0 delimited by end-of-file (wanted `EOF')"
          ],
          "stdout": "",
          "stdout_lines": []
      }
  }
  
  PLAY RECAP ****************************************************************************************************************************************************************************
  localhost                  : ok=4    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
  </code></pre>
  
  <p>I am not able to understand the warning w.r.t EOF part and if it's the reason for the file upload not happening. Because, I use the below shell script (which is basically the same steps from the play) to upload file and it works perfect.</p>
  
  <pre><code>lftp ansible1.example.com&lt;&lt;EOF
  cd pub
  put /etc/hosts
  bye
  EOF
  </code></pre>