Skip to content

SFTP SFTP: Client

Summary

This module contains actions for listing directories on & uploading/downloading files to/from an SFTP server.

Actions

sftp.client.

delete_file

Delete a file on an SFTP server.

Input
  • sftp_server: an SFTPServer dictionary

  • name: the name of the directory item to delete

  • working_directory: optional remote directory from which to run the command (defaults to the login directory)

Output

Nothing is outputted by this action.

Example
1
2
3
4
- sftp.client.delete_file:
    name: example_file.json
  load:
    sftp_server: sftp_server

sftp.client.

delete_files

Delete multiple files on an SFTP server.

Input
  • sftp_server: an SFTPServer dictionary

  • names: a list containing the name of each directory item to delete

  • working_directory: optional remote directory from which to run the command (defaults to the login directory)

Output

Nothing is outputted by this action.

Example
1
2
3
4
5
6
- sftp.client.delete_files:
    names:
      - json_file.json
      - text_file.txt
  load:
    sftp_server: sftp_server

sftp.client.

download_file

Download a file from an SFTP server.

Input
  • sftp_server: an SFTPServer dictionary

  • source: the remote path of the file to download

  • destination: the name of the local file to create

Output

Nothing is outputted by this action.

Example
1
2
3
4
5
- sftp.client.download_file:
    source: remote_directory/remote_file.txt
    destination: local_file.txt
  load:
    sftp_server: sftp_server

sftp.client.

list_directory

List items in a directory

Input
  • sftp_server: an SFTPServer dictionary

  • path: optional path to list items from (defaults to current working directory .)

  • working_directory: optional remote directory from which to run the command (defaults to the login directory)

Output

A list of DirectoryItem dictionaries.

Example
1
2
3
4
- sftp.client.list_directory:
  load:
    sftp_server: sftp_server
  save: directory_listing

sftp.client.

output_directory_table

Display directory items in a table.

The table will have the following columns:

  • Name
  • Is Directory
  • Size (bytes)
  • Last Modified
Input
  • directory_items: a single or list of DirectoryItem dictionaries to display in a table
Output

Nothing is outputted by this action.

Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
- sftp.client.search_directory:
    expression: .*\.json
  load:
    sftp_server: sftp_server
  save: json_files

- sftp.client.output_directory_table:
    text: JSON Files
  load:
    directory_items: json_files

sftp.client.

search_directory

Search a directory for items using a regular expression.

Input
  • sftp_server: an SFTPServer dictionary

  • expression: regular expression to use in the search

  • path: optional path to list files in (defaults to current working directory .)

  • working_directory: optional remote directory from which to run the command (defaults to the login directory)

Output

A list of DirectoryItem dictionaries.

Example
1
2
3
4
5
- sftp.client.search_directory:
    expression: .*\.json
  load:
    sftp_server: sftp_server
  save: json_files

sftp.client.

upload_file

Upload a file to the SFTP server.

Input
  • sftp_server: an SFTPServer dictionary

  • source: the name of the local file to upload

  • destination: the destination path on the SFTP server (including the file name)

Output

Nothing is outputted by this action.

Example
1
2
3
4
5
- sftp.client.upload_file:
    source: playbook_file.txt
    destination: playbook_file.txt
  load:
    sftp_server: sftp_server