mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-06-13 11:35:28 +00:00
kopia: Add kopia_repository module (#11752)
* Add kopia module util
* fix pipeline suggestions
* add kopia repository module
* apply code review changes
* remove kopia_runner instance unit test
* update botmeta with kopia
* refactor docs and redundant state
* add kopia_info module and fix kopia_repository check mode support
- Add kopia_info module for read-only repository information gathering
(kopia repository status, kopia repository throttle get) following
the pacemaker_info pattern with ModuleHelper and info_module fragment
- Add _fmt_throttle to _kopia.py and register throttle format in
kopia_runner; remove throttle_operation get option from
kopia_repository per Ansible best practices (info ops belong in
_info modules)
- Add throttle suboption dict to kopia_repository with all seven
kopia repository throttle set flags
- Fix check_mode: support from full to actually full by implementing
_predict_value() in kopia_repository; previously check_mode_skip
caused changed to always be false in check mode
- Add check mode test cases to test_kopia_repository.yaml covering
created and disconnected states for both connected and disconnected
initial conditions
- Add BOTMETA.yml entry and full test fixture for kopia_info
* apply code review suggestions
(cherry picked from commit d4031f36e4)
Co-authored-by: munchtoast <45038532+munchtoast@users.noreply.github.com>
73 lines
2.3 KiB
YAML
73 lines
2.3 KiB
YAML
# Copyright (c) 2026, Dexter Le <dextersydney2001@gmail.com>
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
---
|
|
anchors:
|
|
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
|
|
|
|
test_cases:
|
|
- id: info_connected
|
|
input:
|
|
config: /etc/kopia/root.config
|
|
output:
|
|
changed: false
|
|
repository_status: |-
|
|
Connected to repository: s3:/my-bucket/
|
|
Config file: /etc/kopia/root.config
|
|
throttle: |-
|
|
upload-bytes-per-second: 0
|
|
download-bytes-per-second: 0
|
|
mocks:
|
|
run_command:
|
|
- command: [/testbin/kopia, repository, status, --config-file=/etc/kopia/root.config]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: |-
|
|
Connected to repository: s3:/my-bucket/
|
|
Config file: /etc/kopia/root.config
|
|
err: ''
|
|
- command: [/testbin/kopia, repository, throttle, get, --config-file=/etc/kopia/root.config]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: |-
|
|
upload-bytes-per-second: 0
|
|
download-bytes-per-second: 0
|
|
err: ''
|
|
|
|
- id: info_not_connected
|
|
input:
|
|
config: /etc/kopia/root.config
|
|
output:
|
|
failed: true
|
|
msg: "kopia repository status failed with error (rc=1): repository not connected"
|
|
mocks:
|
|
run_command:
|
|
- command: [/testbin/kopia, repository, status, --config-file=/etc/kopia/root.config]
|
|
environ: *env-def
|
|
rc: 1
|
|
out: ''
|
|
err: 'repository not connected'
|
|
|
|
- id: info_no_config
|
|
input: {}
|
|
output:
|
|
changed: false
|
|
repository_status: "Connected to repository: filesystem:/mnt/backup/kopia"
|
|
throttle: |-
|
|
upload-bytes-per-second: 1048576
|
|
download-bytes-per-second: 5242880
|
|
mocks:
|
|
run_command:
|
|
- command: [/testbin/kopia, repository, status]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: "Connected to repository: filesystem:/mnt/backup/kopia"
|
|
err: ''
|
|
- command: [/testbin/kopia, repository, throttle, get]
|
|
environ: *env-def
|
|
rc: 0
|
|
out: |-
|
|
upload-bytes-per-second: 1048576
|
|
download-bytes-per-second: 5242880
|
|
err: ''
|