Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support Bareos plugins for Filedaemon (FD) #1

Merged
merged 12 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading