Skip to content

Commit

Permalink
Merge pull request #6 from adfinis/bump_bareos_dir
Browse files Browse the repository at this point in the history
feat(role): update bareos_dir version to v1.1.0
  • Loading branch information
adf-patrickha authored Feb 16, 2024
2 parents 5ea54c5 + f2840fd commit 00738eb
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 44 deletions.
6 changes: 4 additions & 2 deletions roles/bareos_dir/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ This example is taken from [`molecule/default/converge.yml`](https://github.com/
maximum_concurrent_jobs: 3
- name: "disabled-storage"
enabled: false
bareos_dir_plugins:
- director-python
```
The machine needs to be prepared. In CI this is done using [`molecule/default/prepare.yml`](https://github.com/adfinis/ansible-role-bareos_dir/blob/master/molecule/default/prepare.yml):
Expand Down Expand Up @@ -384,9 +386,9 @@ This role has been tested on these [container images](https://hub.docker.com/u/r
|container|tags|
|---------|----|
|[Debian](https://hub.docker.com/r/robertdebock/debian)|bookworm, bullseye, buster|
|[Debian](https://hub.docker.com/r/robertdebock/debian)|buster, bullseye, bookworm|
|[EL](https://hub.docker.com/r/robertdebock/enterpriselinux)|7, 8, 9|
|[Fedora](https://hub.docker.com/r/robertdebock/fedora/)|37, 38|
|[Fedora](https://hub.docker.com/r/robertdebock/fedora/)|38,39|
|[opensuse](https://hub.docker.com/r/robertdebock/opensuse)|all|
|[Ubuntu](https://hub.docker.com/r/robertdebock/ubuntu)|jammy, focal|
Expand Down
8 changes: 6 additions & 2 deletions roles/bareos_dir/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ argument_specs:
options:
bareos_dir_backup_configurations:
type: "bool"
default: no
default: false
description: "Backup the configuration files."
bareos_dir_hostname:
type: "str"
Expand Down Expand Up @@ -85,5 +85,9 @@ argument_specs:
description: "A list of storages to configure."
bareos_dir_install_debug_packages:
type: "bool"
default: no
default: false
description: "Install debug packages. This requires the debug repositories to be enabled."
bareos_dir_plugins:
type: "list"
default: []
description: "A list of Bareos Director plugins"
3 changes: 3 additions & 0 deletions roles/bareos_dir/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ roles:
# The `core_dependencies` and `postfix` roles provide mailing capabilities for the `bareos_role`: "dir".
# - name: robertdebock.core_dependencies
# - name: robertdebock.postfix

# use bconsole to be able to run better tests for Bareos Director
- name: adfinis.bareos_console
47 changes: 27 additions & 20 deletions roles/bareos_dir/tasks/assert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,141 +5,148 @@
that:
- bareos_dir_backup_configurations is defined
- bareos_dir_backup_configurations is boolean
quiet: yes
quiet: true

- name: assert | Test bareos_dir_hostname
ansible.builtin.assert:
that:
- bareos_dir_hostname is defined
- bareos_dir_hostname is string
- bareos_dir_hostname != ""
quiet: yes
quiet: true

- name: assert | Test bareos_dir_password
ansible.builtin.assert:
that:
- bareos_dir_password is defined
- bareos_dir_password is string
- bareos_dir_password != ""
quiet: yes
quiet: true

- name: assert | Test bareos_dir_queryfile
ansible.builtin.assert:
that:
- bareos_dir_queryfile is defined
- bareos_dir_queryfile is string
- bareos_dir_queryfile != ""
quiet: yes
quiet: true

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

- name: assert | Test bareos_dir_message
ansible.builtin.assert:
that:
- bareos_dir_message is defined
- bareos_dir_message is string
- bareos_dir_message != ""
quiet: yes
quiet: true

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

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

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

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

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

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

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

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

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

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

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

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

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

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

- name: assert | Test bareos_dir_plugins
ansible.builtin.assert:
that:
- bareos_dir_plugins is defined
- bareos_dir_plugins is iterable
quiet: true
20 changes: 17 additions & 3 deletions roles/bareos_dir/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
---
# tasks file for bareos_dir

- name: Include OS-specific vars
ansible.builtin.include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_facts.distribution }}_{{ ansible_facts.distribution_major_version }}.yml"
- "{{ ansible_facts.os_family }}.yml"
- main.yml # use main.yml if no match was found

- name: Import assert.yml
ansible.builtin.import_tasks:
file: assert.yml
run_once: yes
run_once: true
delegate_to: localhost

- name: Prevent db installation (apt)
Expand Down Expand Up @@ -35,7 +42,7 @@
cmd: "{{ item }}"
creates: "/var/log/bareos/{{ item | basename }}.log"
become_user: postgres
become: yes
become: true
register: bareos_setup_database
loop: "{{ bareos_dir_install_scripts }}"
loop_control:
Expand Down Expand Up @@ -227,8 +234,15 @@
- Check configuration
- Reload bareos-dir

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

- name: Start bareos-dir
ansible.builtin.service:
name: bareos-dir
state: started
enabled: yes
enabled: true
18 changes: 18 additions & 0 deletions roles/bareos_dir/tasks/plugins.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---

- name: plugins | Get data
ansible.builtin.set_fact:
_plugin_data: >-
{{ _plugin_data + (bareos_dir_plugin_list | selectattr('name', 'equalto', item) | list) }}
loop: "{{ bareos_dir_plugins }}"
vars:
_plugin_data: [] # empty list to append to

- name: plugins | Install Bareos plugin packages
ansible.builtin.package:
name: "{{ item.packages }}"
state: present
loop: "{{ _plugin_data }}"
notify:
- Check configuration
- Reload bareos-dir
4 changes: 4 additions & 0 deletions roles/bareos_dir/templates/bareos-dir.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ Director {
{% if bareos_dir_tls_verify_peer %}
TLS Verify Peer = Yes
{% endif %}
{% if bareos_dir_plugins is defined %}
Plugin Names = "{{ bareos_dir_plugin_name }}"
Plugin Directory = "{{ bareos_dir_plugin_dir }}"
{% endif %}
}
3 changes: 3 additions & 0 deletions roles/bareos_dir/templates/job.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
{% if item.maximum_concurrent_jobs is defined %}
Maximum Concurrent Jobs = {{ item.maximum_concurrent_jobs }}
{% endif %}
{% if item.plugin_options is defined %}
Dir Plugin Options = {{ item.plugin_options }}
{% endif %}
}
{% else %}
# This file is not enabled.
Expand Down
1 change: 1 addition & 0 deletions roles/bareos_dir/vars/CentOS_7.yml
10 changes: 10 additions & 0 deletions roles/bareos_dir/vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---

bareos_dir_requirements:
- procps

bareos_dir_debug_packages:
- bareos-dbg
- gdb

bareos_dir_plugin_dir: "/usr/lib/bareos/plugins"
7 changes: 7 additions & 0 deletions roles/bareos_dir/vars/RedHat_7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---

bareos_dir_debug_packages:
- bareos-debuginfo
- gdb

bareos_dir_plugin_name: python3
30 changes: 13 additions & 17 deletions roles/bareos_dir/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
---
# vars file for bareos_dir

# The requirements for bareos-dir.
_bareos_dir_requirements:
default: []
Debian:
- procps
bareos_dir_requirements: "{{ _bareos_dir_requirements[ansible_os_family] | default(_bareos_dir_requirements['default']) }}"
bareos_dir_requirements: []

# The packages to install.
bareos_dir_packages:
Expand All @@ -20,14 +15,15 @@ bareos_dir_install_scripts:
- /usr/lib/bareos/scripts/make_bareos_tables
- /usr/lib/bareos/scripts/grant_bareos_privileges

_bareos_dir_debug_packages:
default:
- "bareos-director-debuginfo"
- gdb
Debian:
- "bareos-dbg"
- gdb
RedHat-7:
- "bareos-debuginfo"
- gdb
bareos_dir_debug_packages: "{{ _bareos_dir_debug_packages[ansible_os_family ~ '-' ~ ansible_distribution_major_version] | default(_bareos_dir_debug_packages[ansible_os_family] | default(_bareos_dir_debug_packages['default'])) }}"

bareos_dir_debug_packages:
- bareos-director-debuginfo
- gdb

bareos_dir_plugin_name: python3
bareos_dir_plugin_dir: "/usr/lib64/bareos/plugins"

bareos_dir_plugin_list:
- name: director-python
packages:
- bareos-director-python3-plugin

0 comments on commit 00738eb

Please sign in to comment.