community.general.kopia_repository module – Manage Kopia repository

Note

This module is part of the community.general collection (version 13.1.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.kopia_repository.

New in community.general 13.1.0

Synopsis

  • Manage a Kopia repository using the Kopia CLI.

  • Supports creating, connecting, disconnecting, syncing, and throttling repositories.

Parameters

Parameter

Comments

backend

dictionary

Backend storage configuration for the repository.

Required if state=created, state=connected, or state=synced.

access_key

string

Access key ID for the backend.

Required if backend.provider=b2 or backend.provider=s3.

bucket

string

Bucket name for the backend.

Required if backend.provider=b2, backend.provider=gcs, or backend.provider=s3.

container

string

Azure Blob Storage container name.

Required if backend.provider=azure.

credentials_file

path

Path to a JSON credentials file for authentication.

Optional if backend.provider=gcs or backend.provider=gdrive.

endpoint

string

S3-compatible endpoint URL.

Optional if backend.provider=s3; defaults to s3.amazonaws.com.

folder_id

string

Google Drive folder ID to use as the backend root.

Required if backend.provider=gdrive.

host

string

SFTP server hostname.

Required if backend.provider=sftp.

keyfile

path

Path to the SSH private key file for SFTP authentication.

Optional if backend.provider=sftp.

known_hosts

path

Path to a known_hosts file for SFTP host key verification.

Optional if backend.provider=sftp.

path

path

Local file system path or remote path for the backend.

Required if backend.provider=filesystem, backend.provider=rclone, or backend.provider=sftp.

port

integer

SFTP server port.

Optional if backend.provider=sftp; defaults to 22.

prefix

string

Object key prefix within the backend storage.

Optional if backend.provider=azure, backend.provider=b2, backend.provider=gcs, or backend.provider=s3.

provider

string / required

Backend storage provider.

Use server to connect to a Kopia repository server instead of directly to storage.

Choices:

  • "azure"

  • "b2"

  • "filesystem"

  • "gcs"

  • "gdrive"

  • "rclone"

  • "s3"

  • "sftp"

  • "webdav"

  • "server"

region

string

S3 bucket region.

Optional if backend.provider=s3.

sas_token

string

Azure Shared Access Signature token for authentication.

Optional alternative to backend.storage_key when backend.provider=azure.

secret_access_key

string

Secret access key for the backend.

Required if backend.provider=b2 or backend.provider=s3.

session_token

string

Session token for temporary AWS credentials.

Optional if backend.provider=s3.

storage_account

string

Azure storage account name.

Required if backend.provider=azure.

storage_domain

string

Azure storage domain override.

Optional if backend.provider=azure.

storage_key

string

Azure storage account key used to authenticate.

Optional if backend.provider=azure; omit when using managed identity or SAS tokens.

url

string

WebDAV server URL.

Required if backend.provider=webdav.

username

string

SFTP username for authentication.

Required if backend.provider=sftp.

webdav_password

string

Password for WebDAV authentication.

Optional if backend.provider=webdav.

webdav_username

string

Username for WebDAV authentication.

Optional if backend.provider=webdav.

config

path

Path to the Kopia config file for this repository connection.

Defaults to the Kopia default config path when not set.

fingerprint_tls

string

TLS certificate fingerprint of the Kopia server.

Required if state=connected and backend.provider=server.

password

string

Repository password used to encrypt and decrypt repository contents.

state

string

Desired state of the Kopia repository.

Choices:

  • "connected": Connects to an existing repository or Kopia server.

  • "created" (default): Creates a new repository at the given backend.

  • "disconnected": Disconnects from the current repository.

  • "synced": Synchronizes the current repository to another backend location.

  • "throttled": Sets throttle limits on the current repository.

throttle

dictionary

Throttle limits for the repository connection.

Only used when state=throttled.

concurrent_reads

integer

Maximum number of concurrent read operations.

concurrent_writes

integer

Maximum number of concurrent write operations.

download_bytes_per_second

integer

Maximum download speed in bytes per second. Set to 0 to disable the limit.

list_requests_per_second

float

Maximum number of list requests per second.

read_requests_per_second

float

Maximum number of read requests per second.

upload_bytes_per_second

integer

Maximum upload speed in bytes per second. Set to 0 to disable the limit.

write_requests_per_second

float

Maximum number of write requests per second.

url

string

URL of the Kopia server to connect to.

Required if state=connected and backend.provider=server.

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: full

Returns details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Examples

- name: Create a Kopia repository with S3 backend
  community.general.kopia_repository:
    state: created
    password: secret
    config: /etc/kopia/root.config
    backend:
      provider: s3
      bucket: my-bucket
      access_key: myaccesskey
      secret_access_key: mysecretaccesskey

- name: Create a Kopia repository on the local filesystem
  community.general.kopia_repository:
    state: created
    password: secret
    backend:
      provider: filesystem
      path: /mnt/backup/kopia

- name: Connect to a Kopia repository server
  community.general.kopia_repository:
    state: connected
    password: secret
    config: /etc/kopia/root.config
    url: https://kopia.example.com:51515
    fingerprint_tls: AA:BB:CC:DD:EE:FF
    backend:
      provider: server

- name: Connect directly to an Azure backend
  community.general.kopia_repository:
    state: connected
    password: secret
    backend:
      provider: azure
      container: my-container
      storage_account: mystorageaccount
      storage_key: mystoragekey

- name: Disconnect the Kopia repository
  community.general.kopia_repository:
    state: disconnected
    config: /etc/kopia/root.config

- name: Sync Kopia repository to an S3 location
  community.general.kopia_repository:
    state: synced
    password: secret
    config: /etc/kopia/root.config
    backend:
      provider: s3
      bucket: my-synced-bucket
      access_key: myaccesskey
      secret_access_key: mysecretaccesskey

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

kopia_repository

string

Output from the Kopia repository command.

Returned: always

Sample: "Connected to repository: s3:/my-bucket/\nConfig file: /etc/kopia/root.config\n..."

Authors

  • Dexter Le (@munchtoast)