ansible-infra/ansible_collections/debops/debops/roles/boxbackup/tasks/configure_clients.yml
Stefan Bethke 2aed20393f
Some checks failed
/ Ansible Lint (push) Failing after 5m45s
/ Ansible Lint (pull_request) Failing after 4m59s
Vendor Galaxy Roles and Collections
2026-02-06 22:07:16 +01:00

87 lines
3.3 KiB
YAML

---
# Copyright (C) 2014-2019 Maciej Delmanowski <drybjed@gmail.com>
# Copyright (C) 2015-2019 DebOps <https://debops.org/>
# SPDX-License-Identifier: GPL-3.0-only
- name: Install Box Backup client package
ansible.builtin.package:
name: 'boxbackup-client'
state: 'present'
register: boxbackup__register_client_packages
until: boxbackup__register_client_packages is succeeded
- name: Set backup softlimit size for client hosts
ansible.builtin.set_fact:
boxbackup_softlimit: '{{ (ansible_mounts | sum(attribute="size_total") / 1024 / 1024
+ boxbackup_softlimit_padding) | int }}'
when: (boxbackup_softlimit is undefined or not boxbackup_softlimit)
- name: Set backup hardlimit size for client hosts
ansible.builtin.set_fact:
boxbackup_hardlimit: '{{ (boxbackup_softlimit | float * boxbackup_hardlimit_multiplier | float) | int }}'
when: (boxbackup_hardlimit is undefined or not boxbackup_hardlimit)
- name: Create accounts for client hosts
ansible.builtin.command: bbstoreaccounts create {{ boxbackup_account }} {{ boxbackup_discnum }}
{{ boxbackup_softlimit }}M {{ boxbackup_hardlimit }}M
args:
creates: '{{ boxbackup_storage }}/backup/{{ boxbackup_account }}/info.rfw'
delegate_to: '{{ boxbackup_server }}'
- name: Make sure that boxbackup client directories exists
ansible.builtin.file:
path: '{{ item }}'
state: 'directory'
owner: 'root'
group: 'root'
mode: '0700'
with_items: [ '/etc/boxbackup', '/etc/boxbackup/bbackupd', '/etc/boxbackup/servers/{{ boxbackup_server }}' ]
- name: Check if encryption key exists on Ansible Controller
ansible.builtin.stat:
path: '{{ secret + "/storage/boxbackup/clients/" + ansible_fqdn + "/" + boxbackup_account + "-FileEncKeys.raw" }}'
register: boxbackup_register_enckeys
delegate_to: 'localhost'
become: False
- name: Download BoxBackup encryption key from archive
ansible.builtin.copy:
src: '{{ secret + "/storage/boxbackup/clients/" + ansible_fqdn + "/" + boxbackup_account + "-FileEncKeys.raw" }}'
dest: '/etc/boxbackup/bbackupd/{{ boxbackup_account }}-FileEncKeys.raw'
owner: 'root'
group: 'root'
mode: '0600'
when: boxbackup_register_enckeys.stat.exists
notify: [ 'Restart boxbackup-client' ]
- name: Create encryption key on client hosts
ansible.builtin.command: openssl rand -out /etc/boxbackup/bbackupd/{{ boxbackup_account }}-FileEncKeys.raw
{{ boxbackup_encrypt_bits }}
args:
creates: '/etc/boxbackup/bbackupd/{{ boxbackup_account }}-FileEncKeys.raw'
notify:
- Restart boxbackup-client
- name: Archive client encryption key
ansible.builtin.fetch:
src: '/etc/boxbackup/bbackupd/{{ boxbackup_account }}-FileEncKeys.raw'
dest: '{{ secret }}/storage/boxbackup/clients/{{ ansible_fqdn }}/{{ boxbackup_account }}-FileEncKeys.raw'
flat: 'yes'
- name: Install notification script on client hosts
ansible.builtin.template:
src: 'etc/boxbackup/bbackupd/NotifySysadmin.sh.j2'
dest: '/etc/boxbackup/bbackupd/NotifySysadmin.sh'
owner: 'root'
group: 'root'
mode: '0700'
- name: Configure client hosts
ansible.builtin.template:
src: 'etc/boxbackup/bbackupd.conf.j2'
dest: '/etc/boxbackup/bbackupd.conf'
owner: 'root'
group: 'root'
mode: '0600'
notify:
- Restart boxbackup-client