From 3264479ab51b4089898fcc655d5b97fea967c646 Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Tue, 13 Feb 2024 11:10:50 +0100 Subject: [PATCH] feat(role): update bareos_fd version to v1.1.1 --- galaxy.yml | 2 +- roles/bareos_fd/meta/main.yml | 4 +- roles/bareos_fd/requirements.yml | 1 + roles/bareos_fd/tasks/main.yml | 6 +++ roles/bareos_fd/tasks/plugins.yml | 14 +++++-- roles/bareos_fd/templates/myself.conf.j2 | 18 ++------- roles/bareos_fd/vars/Archlinux.yml | 9 +++++ roles/bareos_fd/vars/CentOS_7.yml | 1 + roles/bareos_fd/vars/Debian.yml | 25 ++++++++++++ roles/bareos_fd/vars/RedHat.yml | 26 ++++++++++++ roles/bareos_fd/vars/RedHat_7.yml | 27 +++++++++++++ roles/bareos_fd/vars/Suse.yml | 23 +++++++++++ roles/bareos_fd/vars/main.yml | 51 ++++-------------------- 13 files changed, 142 insertions(+), 65 deletions(-) create mode 100644 roles/bareos_fd/vars/Archlinux.yml create mode 120000 roles/bareos_fd/vars/CentOS_7.yml create mode 100644 roles/bareos_fd/vars/Debian.yml create mode 100644 roles/bareos_fd/vars/RedHat.yml create mode 100644 roles/bareos_fd/vars/RedHat_7.yml create mode 100644 roles/bareos_fd/vars/Suse.yml diff --git a/galaxy.yml b/galaxy.yml index dccf563..7ae7fc4 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,7 +1,7 @@ --- namespace: adfinis name: bareos -version: 1.0.0 +version: 1.0.5 readme: README.md authors: - Adfinis diff --git a/roles/bareos_fd/meta/main.yml b/roles/bareos_fd/meta/main.yml index 195d18e..ac5058b 100644 --- a/roles/bareos_fd/meta/main.yml +++ b/roles/bareos_fd/meta/main.yml @@ -4,7 +4,7 @@ galaxy_info: role_name: bareos_fd description: Install and configure [Bareos](https://www.bareos.com/) File Daemon. license: Apache-2.0 - company: none + company: Adfinis min_ansible_version: "2.12" platforms: @@ -20,8 +20,8 @@ galaxy_info: - "9" - name: Fedora versions: - - "37" - "38" + - "39" - name: opensuse versions: - all diff --git a/roles/bareos_fd/requirements.yml b/roles/bareos_fd/requirements.yml index bb33858..0ee4cb4 100644 --- a/roles/bareos_fd/requirements.yml +++ b/roles/bareos_fd/requirements.yml @@ -5,3 +5,4 @@ roles: collections: - name: community.crypto + - name: community.general diff --git a/roles/bareos_fd/tasks/main.yml b/roles/bareos_fd/tasks/main.yml index 020dce3..93b9423 100644 --- a/roles/bareos_fd/tasks/main.yml +++ b/roles/bareos_fd/tasks/main.yml @@ -1,6 +1,12 @@ --- # tasks file for bareos_fd +- 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" + - name: Import assert.yml ansible.builtin.import_tasks: file: assert.yml diff --git a/roles/bareos_fd/tasks/plugins.yml b/roles/bareos_fd/tasks/plugins.yml index 472f72a..7f05f79 100644 --- a/roles/bareos_fd/tasks/plugins.yml +++ b/roles/bareos_fd/tasks/plugins.yml @@ -1,12 +1,18 @@ --- -- name: plugins | Get Bareos plugin package names +- name: plugins | Get data ansible.builtin.set_fact: - _plugin_packages: - "{{ bareos_fd_plugin_list | selectattr('name', 'match', item) | map(attribute='package_name') }}" + _plugin_data: >- + {{ _plugin_data + (bareos_fd_plugin_list | selectattr('name', 'equalto', item) | list) }} loop: "{{ bareos_fd_plugins }}" + vars: + _plugin_data: [] # empty list to append to - name: plugins | Install Bareos plugin packages ansible.builtin.package: - name: "{{ _plugin_packages }}" + name: "{{ item.packages }}" state: present + loop: "{{ _plugin_data }}" + notify: + - Check configuration + - Restart bareos-filedaemon diff --git a/roles/bareos_fd/templates/myself.conf.j2 b/roles/bareos_fd/templates/myself.conf.j2 index 98bf9ca..f53bbea 100644 --- a/roles/bareos_fd/templates/myself.conf.j2 +++ b/roles/bareos_fd/templates/myself.conf.j2 @@ -24,21 +24,11 @@ Client { {% endif %} {# - bareos_fd_plugins is defined on host/group level, - while bareos_fd_plugin_list is a role var, with all available plugins +# `bareos_fd_plugins` is a list defined on host/group level, +# while `bareos_fd_plugin_name` and `bareos_fd_plugin_dir` are role vars #} {% 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 %} + Plugin Names = "{{ bareos_fd_plugin_name }}" + Plugin Directory = "{{ bareos_fd_plugin_dir }}" {% endif %} } diff --git a/roles/bareos_fd/vars/Archlinux.yml b/roles/bareos_fd/vars/Archlinux.yml new file mode 100644 index 0000000..3d4653c --- /dev/null +++ b/roles/bareos_fd/vars/Archlinux.yml @@ -0,0 +1,9 @@ +--- + +bareos_fd_encryption_packages: + - python-cryptography + +bareos_fd_service: bareos-fd + +bareos_fd_debug_packages: + - bareos-devel diff --git a/roles/bareos_fd/vars/CentOS_7.yml b/roles/bareos_fd/vars/CentOS_7.yml new file mode 120000 index 0000000..105e630 --- /dev/null +++ b/roles/bareos_fd/vars/CentOS_7.yml @@ -0,0 +1 @@ +RedHat_7.yml \ No newline at end of file diff --git a/roles/bareos_fd/vars/Debian.yml b/roles/bareos_fd/vars/Debian.yml new file mode 100644 index 0000000..f9bece5 --- /dev/null +++ b/roles/bareos_fd/vars/Debian.yml @@ -0,0 +1,25 @@ +--- + +bareos_fd_debug_packages: + - bareos-dbg + - gdb + +bareos_fd_plugin_dir: "/usr/lib/bareos/plugins" +bareos_fd_plugin_name: python3 +bareos_fd_plugin_list: + - name: mariabackup + packages: + - bareos-filedaemon-mariabackup-python-plugin + + - name: mysql + packages: + - python3-mysqldb + + - name: postgresql + packages: + - bareos-filedaemon-postgresql-python-plugin + + - name: ldap + packages: + - python3-ldap + - bareos-filedaemon-ldap-python-plugin diff --git a/roles/bareos_fd/vars/RedHat.yml b/roles/bareos_fd/vars/RedHat.yml new file mode 100644 index 0000000..ff0a2e1 --- /dev/null +++ b/roles/bareos_fd/vars/RedHat.yml @@ -0,0 +1,26 @@ +--- + +bareos_fd_debug_packages: + - bareos-filedaemon-debuginfo + - gdb + +bareos_fd_plugin_dir: "/usr/lib64/bareos/plugins" +bareos_fd_plugin_name: python3 +bareos_fd_plugin_list: + - name: mariabackup + packages: + - bareos-filedaemon-mariabackup-python-plugin + + # TODO RHEL offers no python-mysqlclient package per default. + # Check if PyMySQL is working with the plugin + - name: mysql + packages: + - python3-PyMySQL + + - name: postgresql + packages: + - bareos-filedaemon-postgresql-python-plugin + + - name: ldap + packages: + - bareos-filedaemon-ldap-python-plugin diff --git a/roles/bareos_fd/vars/RedHat_7.yml b/roles/bareos_fd/vars/RedHat_7.yml new file mode 100644 index 0000000..f584714 --- /dev/null +++ b/roles/bareos_fd/vars/RedHat_7.yml @@ -0,0 +1,27 @@ +--- + +bareos_fd_encryption_packages: + - python2-cryptography + +bareos_fd_debug_packages: + - bareos-debuginfo + - gdb + +bareos_fd_plugin_dir: "/usr/lib64/bareos/plugins" +bareos_fd_plugin_name: python +bareos_fd_plugin_list: + - name: mariabackup + packages: + - bareos-filedaemon-mariabackup-python-plugin + + - name: mysql + packages: + - MySQL-python + + - name: postgresql + packages: + - bareos-filedaemon-postgresql-python-plugin + + - name: ldap + packages: + - bareos-filedaemon-ldap-python-plugin diff --git a/roles/bareos_fd/vars/Suse.yml b/roles/bareos_fd/vars/Suse.yml new file mode 100644 index 0000000..6486726 --- /dev/null +++ b/roles/bareos_fd/vars/Suse.yml @@ -0,0 +1,23 @@ +--- + +bareos_fd_debug_packages: + - gdb + +bareos_fd_plugin_dir: "/usr/lib64/bareos/plugins" +bareos_fd_plugin_name: python3 +bareos_fd_plugin_list: + - name: mariabackup + packages: + - bareos-filedaemon-mariabackup-python-plugin + + - name: mysql + packages: + - python3-mysqlclient + + - name: postgresql + packages: + - bareos-filedaemon-postgresql-python-plugin + + - name: ldap + packages: + - bareos-filedaemon-ldap-python-plugin diff --git a/roles/bareos_fd/vars/main.yml b/roles/bareos_fd/vars/main.yml index 3c55bb4..74ade9d 100644 --- a/roles/bareos_fd/vars/main.yml +++ b/roles/bareos_fd/vars/main.yml @@ -1,49 +1,12 @@ --- # vars file for bareos_fd -# A map to define the packages to install for encryption. -_bareos_fd_encryption_packages: - default: - - python3-cryptography - Archlinux: - - python-cryptography - RedHat-7: - - python2-cryptography -bareos_fd_encryption_packages: "{{ _bareos_fd_encryption_packages[ansible_os_family ~ '-' ~ ansible_distribution_major_version] | default(_bareos_fd_encryption_packages[ansible_os_family]) | default(_bareos_fd_encryption_packages['default']) }}" +bareos_fd_encryption_packages: + - python3-cryptography -# A map to define the service name to manage. -_bareos_fd_service: - default: bareos-filedaemon - Archlinux: bareos-fd -bareos_fd_service: "{{ _bareos_fd_service[ansible_os_family] | default(_bareos_fd_service['default']) }}" +bareos_fd_service: bareos-filedaemon +bareos_fd_plugin_name: python3 -# A map to define the packages to install for debugging. -_bareos_fd_debug_packages: - default: - - bareos-filedaemon-debuginfo - - gdb - Archlinux: - - bareos-devel - Debian: - - bareos-dbg - - gdb - RedHat-7: - - 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 +# define the following stuff on Distro level (vars/). If a Distro is not there, it's not supported. +# bareos_fd_plugin_list: every distro might have different package names and dependencies +# bareos_fd_plugin_dir: /usr/lib on Debian, /usr/lib64 on "others"