I have a local file and I need to upload into a remote FTP (not SFTP) server with login.
Please, how could I do that?
Thanks in advance!
Depending on your use case, infrastructure, capabilities of the remote FTP server, etc., there might be several options.
If you like to use plain File Transfer Protocol (FTP) over TCP/21
A Custom Module like ftp
- Transfers files and directories from or to FTP servers
The shell
module – Execute shell commands on targets with curl
- name: Transfer file to FTP server
shell:
cmd: "curl --silent --user {{ ansible_user }}:{{ ansible_password }} ftp://ftp.example.com -T {{ fileToTransfer }}"
register: result
If the FTP server software has additionally HTTP server capabilities implemented
The module uri
- Interacts with webservices with parameter method: PUT
- name: Upload content
local_action:
module: uri
url: "http://ftp.example.oom"
method: PUT
url_username: "{{ ansible_user }}"
url_password: "{{ ansible_password }}"
body: "{{ lookup('file', fileToTransfer) }}"
register: result
... not sure if this would work, haven't tested such setup yet and there is still information missing
Other Q&A
curl
but from stdin
?Further Documentation