Skip to content

Commit

Permalink
Merge pull request #1 from adf-patrickha/feat_fd_plugins
Browse files Browse the repository at this point in the history
feat: support Bareos plugins for Filedaemon (FD)
  • Loading branch information
adf-patrickha authored Jan 29, 2024
2 parents 42fc3f5 + a96c1f2 commit 961b6e4
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 13 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ This example is taken from [`molecule/default/converge.yml`](https://github.com/
- "!saved"
- name: "disabled-message"
enabled: no
bareos_fd_plugins:
- mariabackup
```
The machine needs to be prepared. In CI this is done using [`molecule/default/prepare.yml`](https://github.com/adfinis/ansible-role-bareos_fd/blob/master/molecule/default/prepare.yml):
Expand Down
4 changes: 4 additions & 0 deletions meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,7 @@ argument_specs:
type: "str"
default: ""
description: "The master public key to use."
bareos_fd_plugins:
type: "list"
default: []
description: "Bareos plugins to install on the FD"
2 changes: 2 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,5 @@
- "!saved"
- name: "disabled-message"
enabled: no
bareos_fd_plugins:
- mariabackup
33 changes: 20 additions & 13 deletions tasks/assert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,87 +5,87 @@
that:
- bareos_fd_backup_configurations is defined
- bareos_fd_backup_configurations is boolean
quiet: yes
quiet: true

- name: assert | Test bareos_fd_hostname
ansible.builtin.assert:
that:
- bareos_fd_hostname is defined
- bareos_fd_hostname is string
- bareos_fd_hostname is not none
quiet: yes
quiet: true

- name: assert | Test bareos_fd_max_job_bandwidth
ansible.builtin.assert:
that:
- bareos_fd_max_job_bandwidth is defined
- bareos_fd_max_job_bandwidth is string
- bareos_fd_max_job_bandwidth is not none
quiet: yes
quiet: true

- name: assert | Test bareos_fd_message
ansible.builtin.assert:
that:
- bareos_fd_message is defined
- bareos_fd_message is string
- bareos_fd_message is not none
quiet: yes
quiet: true

- name: assert | Test bareos_fd_tls_enable
ansible.builtin.assert:
that:
- bareos_fd_tls_enable is defined
- bareos_fd_tls_enable is boolean
quiet: yes
quiet: true

- name: assert | Test bareos_fd_tls_verify_peer
ansible.builtin.assert:
that:
- bareos_fd_tls_verify_peer is defined
- bareos_fd_tls_verify_peer is boolean
quiet: yes
quiet: true

- name: assert | Test bareos_fd_heartbeat_interval
ansible.builtin.assert:
that:
- bareos_fd_heartbeat_interval is defined
- bareos_fd_heartbeat_interval is number
quiet: yes
quiet: true

- name: assert | Test bareos_fd_maximum_concurrent_jobs
ansible.builtin.assert:
that:
- bareos_fd_maximum_concurrent_jobs is defined
- bareos_fd_maximum_concurrent_jobs is number
quiet: yes
quiet: true

- name: assert | Test bareos_fd_directors
ansible.builtin.assert:
that:
- bareos_fd_directors is defined
- bareos_fd_directors is iterable
quiet: yes
quiet: true

- name: assert | Test bareos_fd_messages
ansible.builtin.assert:
that:
- bareos_fd_messages is defined
- bareos_fd_messages is iterable
quiet: yes
quiet: true

- name: assert | Test bareos_fd_encryption_enabled
ansible.builtin.assert:
that:
- bareos_fd_encryption_enabled is defined
- bareos_fd_encryption_enabled is boolean
quiet: yes
quiet: true

- name: assert | Test bareos_fd_encryption_private_key
ansible.builtin.assert:
that:
- bareos_fd_encryption_private_key is defined
- bareos_fd_encryption_private_key is string
quiet: yes
quiet: true
when:
- bareos_fd_encryption_enabled

Expand All @@ -95,6 +95,13 @@
- bareos_fd_encryption_master_public_key is defined
- bareos_fd_encryption_master_public_key is string
- bareos_fd_encryption_master_public_key != ""
quiet: yes
quiet: true
when:
- bareos_fd_encryption_enabled

- name: assert | Test bareos_fd_plugins
ansible.builtin.assert:
that:
- bareos_fd_plugins is defined
- bareos_fd_plugins is iterable
quiet: true
7 changes: 7 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@
when:
- bareos_fd_encryption_enabled

- name: Import plugin tasklist
ansible.builtin.import_tasks:
file: plugins.yml
when:
- bareos_fd_plugins is defined
- bareos_fd_plugins is iterable

- name: Start bareos-filedaemon
ansible.builtin.service:
name: "{{ bareos_fd_service }}"
Expand Down
12 changes: 12 additions & 0 deletions tasks/plugins.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---

- name: plugins | Get Bareos plugin package names
ansible.builtin.set_fact:
_plugin_packages:
"{{ bareos_fd_plugin_list | selectattr('name', 'match', item) | map(attribute='package_name') }}"
loop: "{{ bareos_fd_plugins }}"

- name: plugins | Install Bareos plugin packages
ansible.builtin.package:
name: "{{ _plugin_packages }}"
state: present
19 changes: 19 additions & 0 deletions templates/myself.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,23 @@ Client {
PKI Master Key = "/etc/bareos/master.pub.key"
PKI Cipher = aes128
{% endif %}

{#
bareos_fd_plugins is defined on host/group level,
while bareos_fd_plugin_list is a role var, with all available plugins
#}
{% if bareos_fd_plugins is defined %}
{% for plugin in bareos_fd_plugins %}
{% for item in bareos_fd_plugin_list if item.name == plugin %}

{% if item.plugin_dir is defined %}
Plugin Directory = "{{ item.plugin_dir }}"
{% endif %}
{% if item.plugin_names is defined %}
Plugin Names = "{{ item.plugin_names }}"
{% endif %}

{% endfor %}
{% endfor %}
{% endif %}
}
16 changes: 16 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,19 @@ _bareos_fd_debug_packages:
- bareos-debuginfo
- gdb
bareos_fd_debug_packages: "{{ _bareos_fd_debug_packages[ansible_os_family ~ '-' ~ ansible_distribution_major_version] | default(_bareos_fd_debug_packages[ansible_os_family]) | default(_bareos_fd_debug_packages['default']) }}"

# A list of Bareos FD plugins and their packages
bareos_fd_plugin_list:
- name: mariabackup
package_name: bareos-filedaemon-mariabackup-python-plugin
plugin_dir: "/usr/lib64/bareos/plugins"
plugin_names: python3
- name: mysql
plugin_dir: "/usr/lib64/bareos/plugins"
plugin_names: python3
- name: postgresql
package_name: bareos-filedaemon-postgresql-python-plugin
plugin_dir: "/usr/lib64/bareos/plugins"
plugin_names: python3
- name: ldap
package_name: bareos-filedaemon-ldap-python-plugin

0 comments on commit 961b6e4

Please sign in to comment.