From c92445a509f9631361d2ea2dfe7220056d833661 Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Fri, 2 Feb 2024 18:07:33 +0100 Subject: [PATCH 01/19] chore(vars): separate vars by distro Refs: https://adfinis.github.io/ansible-guide/roles_collections.html#variables --- tasks/main.yml | 6 ++++++ vars/Debian.yml | 28 ++++++++++++++++++++++++++++ vars/RedHat.yml | 28 ++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 vars/Debian.yml create mode 100644 vars/RedHat.yml diff --git a/tasks/main.yml b/tasks/main.yml index 020dce3..93b9423 100644 --- a/tasks/main.yml +++ b/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/vars/Debian.yml b/vars/Debian.yml new file mode 100644 index 0000000..d0cd86d --- /dev/null +++ b/vars/Debian.yml @@ -0,0 +1,28 @@ +--- + +bareos_fd_encryption_packages: + - python3-cryptography + +bareos_fd_debug_packages: + - bareos-dbg + - gdb + +bareos_fd_plugin_dir: "/usr/lib/bareos/plugins" +bareos_fd_plugin_default_name: python3 +bareos_fd_plugin_list: + - name: mariabackup + packages: + - bareos-filedaemon-mariabackup-python-plugin + - mariadb-backup + + - name: mysql + packages: + - mariadb-client + + - name: posgresql + packages: + - bareos-filedaemon-postgresql-python-plugin + + - name: ldap + packages: + - bareos-filedaemon-ldap-python-plugin diff --git a/vars/RedHat.yml b/vars/RedHat.yml new file mode 100644 index 0000000..ad937bb --- /dev/null +++ b/vars/RedHat.yml @@ -0,0 +1,28 @@ +--- + +bareos_fd_encryption_packages: + - python3-cryptography + +bareos_fd_debug_packages: + - bareos-filedaemon-debuginfo + - gdb + +bareos_fd_plugin_dir: "/usr/lib64/bareos/plugins" +bareos_fd_plugin_default_name: python3 +bareos_fd_plugin_list: + - name: mariabackup + packages: + - bareos-filedaemon-mariabackup-python-plugin + - mariadb-backup + + - name: mysql + packages: + - mariadb-client + + - name: posgresql + packages: + - bareos-filedaemon-postgresql-python-plugin + + - name: ldap + packages: + - bareos-filedaemon-ldap-python-plugin From 0bd9961d01ffee18e70652e6cc09abd8d5a128da Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Mon, 5 Feb 2024 09:35:09 +0100 Subject: [PATCH 02/19] chore: separate vars, update plugin tasks --- tasks/plugins.yml | 25 +++++++++++++++++-------- vars/Archlinux.yml | 9 +++++++++ vars/RedHat_7.yml | 10 ++++++++++ 3 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 vars/Archlinux.yml create mode 100644 vars/RedHat_7.yml diff --git a/tasks/plugins.yml b/tasks/plugins.yml index 472f72a..d22cd26 100644 --- a/tasks/plugins.yml +++ b/tasks/plugins.yml @@ -1,12 +1,21 @@ --- -- name: plugins | Get Bareos plugin package names +- name: plugins | Get list of packages to install ansible.builtin.set_fact: - _plugin_packages: - "{{ bareos_fd_plugin_list | selectattr('name', 'match', item) | map(attribute='package_name') }}" - loop: "{{ bareos_fd_plugins }}" + _packages: + "{{ bareos_fd_plugin_list | selectattr('name', 'equalto', item) | list }}" -- name: plugins | Install Bareos plugin packages - ansible.builtin.package: - name: "{{ _plugin_packages }}" - state: present +- name: Print var + ansible.builtin.debug: + msg: "_packages: {{ _packages }}" + +#- 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 diff --git a/vars/Archlinux.yml b/vars/Archlinux.yml new file mode 100644 index 0000000..3d4653c --- /dev/null +++ b/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/vars/RedHat_7.yml b/vars/RedHat_7.yml new file mode 100644 index 0000000..57b7006 --- /dev/null +++ b/vars/RedHat_7.yml @@ -0,0 +1,10 @@ +--- + +bareos_fd_encryption_packages: + - python2-cryptography + +bareos_fd_debug_packages: + - bareos-debuginfo + - gdb + +bareos_fd_service: bareos-filedaemon From a94c50c49fa6fca1a8fed13a02fa077cba1bd7a3 Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Mon, 5 Feb 2024 09:46:05 +0100 Subject: [PATCH 03/19] chore(lint): ansible-lint --- tasks/plugins.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tasks/plugins.yml b/tasks/plugins.yml index d22cd26..d50ef7a 100644 --- a/tasks/plugins.yml +++ b/tasks/plugins.yml @@ -5,17 +5,17 @@ _packages: "{{ bareos_fd_plugin_list | selectattr('name', 'equalto', item) | list }}" -- name: Print var +- name: plugins | Print var ansible.builtin.debug: msg: "_packages: {{ _packages }}" -#- 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 | 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 +# - name: plugins | Install Bareos plugin packages +# ansible.builtin.package: +# name: "{{ _plugin_packages }}" +# state: present From 6bb46b51adc86a7396caeb909d35573b3dd6e85a Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Mon, 5 Feb 2024 09:52:45 +0100 Subject: [PATCH 04/19] fix: missing loop in plugins.yml --- tasks/plugins.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/plugins.yml b/tasks/plugins.yml index d50ef7a..6f2f9e8 100644 --- a/tasks/plugins.yml +++ b/tasks/plugins.yml @@ -4,6 +4,7 @@ ansible.builtin.set_fact: _packages: "{{ bareos_fd_plugin_list | selectattr('name', 'equalto', item) | list }}" + loop: "{{ bareos_fd_plugins }}" - name: plugins | Print var ansible.builtin.debug: From 3375dfc27dbebc81d51d9a4bf7b7d5ecc99f74cf Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Mon, 5 Feb 2024 13:12:53 +0100 Subject: [PATCH 05/19] chore(vars): separate vars by Distro, add Suse, update plugin tasks --- tasks/plugins.yml | 19 ++++++--------- templates/myself.conf.j2 | 9 +++++-- vars/Debian.yml | 6 ++--- vars/RedHat.yml | 7 ++---- vars/RedHat_7.yml | 19 ++++++++++++++- vars/Suse.yml | 24 +++++++++++++++++++ vars/main.yml | 51 ++++++---------------------------------- 7 files changed, 67 insertions(+), 68 deletions(-) create mode 100644 vars/Suse.yml diff --git a/tasks/plugins.yml b/tasks/plugins.yml index 6f2f9e8..9e2ff63 100644 --- a/tasks/plugins.yml +++ b/tasks/plugins.yml @@ -1,8 +1,8 @@ --- -- name: plugins | Get list of packages to install +- name: plugins | Get data ansible.builtin.set_fact: - _packages: + _plugin_data: "{{ bareos_fd_plugin_list | selectattr('name', 'equalto', item) | list }}" loop: "{{ bareos_fd_plugins }}" @@ -10,13 +10,8 @@ ansible.builtin.debug: msg: "_packages: {{ _packages }}" -# - 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 +- name: plugins | Install Bareos plugin packages + ansible.builtin.package: + name: "{{ item.packages }}" + state: present + loop: _plugin_data diff --git a/templates/myself.conf.j2 b/templates/myself.conf.j2 index 98bf9ca..1b4860a 100644 --- a/templates/myself.conf.j2 +++ b/templates/myself.conf.j2 @@ -31,11 +31,16 @@ Client { {% for plugin in bareos_fd_plugins %} {% for item in bareos_fd_plugin_list if item.name == plugin %} -{% if item.plugin_dir is defined %} +{% if item.plugin_dir is defined %} ## if plugin_dir is defined on plugin level Plugin Directory = "{{ item.plugin_dir }}" +{% else %} ## use bareos_fd_plugin_dir instead + Plugin Directory = "{{ bareos_fd_plugin_dir }}" {% endif %} -{% if item.plugin_names is defined %} + +{% if item.plugin_names is defined %} ## if plugin_names is defined on plugin level Plugin Names = "{{ item.plugin_names }}" +{% else %} ## use bareos_fd_plugin_default_name instead + Plugin Names = "{{ bareos_fd_plugin_default_name }}" {% endif %} {% endfor %} diff --git a/vars/Debian.yml b/vars/Debian.yml index d0cd86d..9f04069 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -1,8 +1,5 @@ --- -bareos_fd_encryption_packages: - - python3-cryptography - bareos_fd_debug_packages: - bareos-dbg - gdb @@ -18,8 +15,9 @@ bareos_fd_plugin_list: - name: mysql packages: - mariadb-client + - python3-mysqldb - - name: posgresql + - name: postgresql packages: - bareos-filedaemon-postgresql-python-plugin diff --git a/vars/RedHat.yml b/vars/RedHat.yml index ad937bb..5769d2c 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -1,8 +1,5 @@ --- -bareos_fd_encryption_packages: - - python3-cryptography - bareos_fd_debug_packages: - bareos-filedaemon-debuginfo - gdb @@ -13,11 +10,11 @@ bareos_fd_plugin_list: - name: mariabackup packages: - bareos-filedaemon-mariabackup-python-plugin - - mariadb-backup + - mariaDB-backup - name: mysql packages: - - mariadb-client + - python3-mysqlclient - name: posgresql packages: diff --git a/vars/RedHat_7.yml b/vars/RedHat_7.yml index 57b7006..2166ab5 100644 --- a/vars/RedHat_7.yml +++ b/vars/RedHat_7.yml @@ -7,4 +7,21 @@ bareos_fd_debug_packages: - bareos-debuginfo - gdb -bareos_fd_service: bareos-filedaemon +bareos_fd_plugin_default_name: python2 +bareos_fd_plugin_list: + - name: mariabackup + packages: + - bareos-filedaemon-mariabackup-python-plugin + - MariaDB-backup + + - name: mysql + packages: + - python2-mysqlclient + + - name: postgresql + packages: + - bareos-filedaemon-postgresql-python-plugin + + - name: ldap + packages: + - bareos-filedaemon-ldap-python-plugin diff --git a/vars/Suse.yml b/vars/Suse.yml new file mode 100644 index 0000000..175c9fe --- /dev/null +++ b/vars/Suse.yml @@ -0,0 +1,24 @@ +--- + +bareos_fd_debug_packages: + - gdb + +bareos_fd_plugin_dir: "/usr/lib64/bareos/plugins" +bareos_fd_plugin_default_name: python3 +bareos_fd_plugin_list: + - name: mariabackup + packages: + - bareos-filedaemon-mariabackup-python-plugin + - MariaDB-backup + + - name: mysql + packages: + - python3-mysqlclient + + - name: postgresql + packages: + - bareos-filedaemon-postgresql-python-plugin + + - name: ldap + packages: + - bareos-filedaemon-ldap-python-plugin diff --git a/vars/main.yml b/vars/main.yml index 3c55bb4..e1a4ef1 100644 --- a/vars/main.yml +++ b/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_default_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" From fd1809494589c340bf1899662bebe65935830739 Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Mon, 5 Feb 2024 13:24:22 +0100 Subject: [PATCH 06/19] fix(vars): rpl _packages with _plugin_data --- tasks/plugins.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/plugins.yml b/tasks/plugins.yml index 9e2ff63..5d8d5e8 100644 --- a/tasks/plugins.yml +++ b/tasks/plugins.yml @@ -8,7 +8,7 @@ - name: plugins | Print var ansible.builtin.debug: - msg: "_packages: {{ _packages }}" + msg: "Plugin data: {{ _plugin_data }}" - name: plugins | Install Bareos plugin packages ansible.builtin.package: From 6728f5064e3325e146ee56d8f3f53faa04a44a8d Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Mon, 5 Feb 2024 13:51:38 +0100 Subject: [PATCH 07/19] fix: fix loop for _plugin_data --- tasks/plugins.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/plugins.yml b/tasks/plugins.yml index 5d8d5e8..9882ea2 100644 --- a/tasks/plugins.yml +++ b/tasks/plugins.yml @@ -14,4 +14,4 @@ ansible.builtin.package: name: "{{ item.packages }}" state: present - loop: _plugin_data + loop: "{{ _plugin_data }}" From 277efc2eb63f399bffe51acd8692db8233494e13 Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Fri, 9 Feb 2024 11:52:02 +0100 Subject: [PATCH 08/19] chore(lint): yaml newline on 2nd line --- molecule/default/collections.yml | 1 + molecule/default/molecule.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/molecule/default/collections.yml b/molecule/default/collections.yml index b869f41..020687f 100644 --- a/molecule/default/collections.yml +++ b/molecule/default/collections.yml @@ -1,4 +1,5 @@ --- + collections: - name: community.docker - name: community.general diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index e918d24..0440f3a 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -2,6 +2,7 @@ # # Ansible managed # + dependency: name: galaxy options: From d40770bc6145b19b5c435e3f64396c6bcdfa23a9 Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Fri, 9 Feb 2024 11:54:43 +0100 Subject: [PATCH 09/19] feat(molecule): add basic test case for FD plugins --- molecule/default/converge.yml | 3 +++ molecule/default/verify.yml | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 0efb2fc..43019a3 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -118,3 +118,6 @@ enabled: no bareos_fd_plugins: - mariabackup + - mysql + - ldap + - postgresql diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index 4f4d6d8..6854b50 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -1,8 +1,8 @@ --- - name: Verify hosts: all - become: yes - gather_facts: no + become: true + gather_facts: true tasks: - name: Check if port 9102 is listening @@ -16,3 +16,18 @@ register: bareos_fd_test_config failed_when: - bareos_fd_test_config.stdout_lines is search("There are configuration warnings") + + # have to be specified in converge.yml: `bareos_fd_plugins` + - name: Check if plugin packages were installed + ansible.builtin.package: + name: + - bareos-filedaemon-mariabackup-python-plugin + - bareos-filedaemon-postgresql-python-plugin + - bareos-filedaemon-ldap-python-plugin + state: present + check_mode: true + diff: true + register: _result + failed_when: _result.changed + when: + - ansible_facts.os_family != "Archlinux" # not supported for FD Plugins From a398358a4d0c82eb7f6600a57ad34df707ed9e3d Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Fri, 9 Feb 2024 11:58:11 +0100 Subject: [PATCH 10/19] chore!(molecule): update requirements for molecule also add missing ansible collection requirement for community.general --- requirements.txt | 7 ++++--- requirements.yml | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index dba7154..76ee97c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ # Pinning ansible-compat version due to [bug](https://github.com/ansible-community/molecule/issues/3903) -ansible-compat == 3.0.2 -molecule == 5.* -molecule-plugins[docker] == 23.* +ansible-compat == 4.* +molecule == 6.* +molecule-plugins == 23.* +docker == 7.* ansible-lint == 6.* paramiko == 3.* diff --git a/requirements.yml b/requirements.yml index bb33858..0ee4cb4 100644 --- a/requirements.yml +++ b/requirements.yml @@ -5,3 +5,4 @@ roles: collections: - name: community.crypto + - name: community.general From c9b86ad9747a3a6f4e856fb1edbea4f67c65623c Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Fri, 9 Feb 2024 12:00:09 +0100 Subject: [PATCH 11/19] chore(vars): rm unnecessary dependencies for plugins --- vars/Debian.yml | 2 -- vars/RedHat.yml | 3 +-- vars/RedHat_7.yml | 1 - vars/Suse.yml | 1 - 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/vars/Debian.yml b/vars/Debian.yml index 9f04069..f4b59e7 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -10,11 +10,9 @@ bareos_fd_plugin_list: - name: mariabackup packages: - bareos-filedaemon-mariabackup-python-plugin - - mariadb-backup - name: mysql packages: - - mariadb-client - python3-mysqldb - name: postgresql diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 5769d2c..d08f2ee 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -10,13 +10,12 @@ bareos_fd_plugin_list: - name: mariabackup packages: - bareos-filedaemon-mariabackup-python-plugin - - mariaDB-backup - name: mysql packages: - python3-mysqlclient - - name: posgresql + - name: postgresql packages: - bareos-filedaemon-postgresql-python-plugin diff --git a/vars/RedHat_7.yml b/vars/RedHat_7.yml index 2166ab5..4ede9fe 100644 --- a/vars/RedHat_7.yml +++ b/vars/RedHat_7.yml @@ -12,7 +12,6 @@ bareos_fd_plugin_list: - name: mariabackup packages: - bareos-filedaemon-mariabackup-python-plugin - - MariaDB-backup - name: mysql packages: diff --git a/vars/Suse.yml b/vars/Suse.yml index 175c9fe..be7a05a 100644 --- a/vars/Suse.yml +++ b/vars/Suse.yml @@ -9,7 +9,6 @@ bareos_fd_plugin_list: - name: mariabackup packages: - bareos-filedaemon-mariabackup-python-plugin - - MariaDB-backup - name: mysql packages: From ca341442b85d142cc5483a4624d12a2574f0c6d7 Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Fri, 9 Feb 2024 12:01:14 +0100 Subject: [PATCH 12/19] fix(plugins): fix installation tasks for packages --- tasks/plugins.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tasks/plugins.yml b/tasks/plugins.yml index 9882ea2..2e8688e 100644 --- a/tasks/plugins.yml +++ b/tasks/plugins.yml @@ -2,13 +2,11 @@ - name: plugins | Get data ansible.builtin.set_fact: - _plugin_data: - "{{ bareos_fd_plugin_list | selectattr('name', 'equalto', item) | list }}" + _plugin_data: >- + {{ _plugin_data + (bareos_fd_plugin_list | selectattr('name', 'equalto', item) | list) }} loop: "{{ bareos_fd_plugins }}" - -- name: plugins | Print var - ansible.builtin.debug: - msg: "Plugin data: {{ _plugin_data }}" + vars: + _plugin_data: [] # empty list to append to - name: plugins | Install Bareos plugin packages ansible.builtin.package: From 733e61e13b67541ed82e858b93cf71d74adab593 Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Mon, 12 Feb 2024 10:58:08 +0100 Subject: [PATCH 13/19] chore: update RedHat vars, add notifier to plugin task --- tasks/plugins.yml | 3 +++ vars/RedHat.yml | 4 +++- vars/RedHat_7.yml | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tasks/plugins.yml b/tasks/plugins.yml index 2e8688e..7f05f79 100644 --- a/tasks/plugins.yml +++ b/tasks/plugins.yml @@ -13,3 +13,6 @@ name: "{{ item.packages }}" state: present loop: "{{ _plugin_data }}" + notify: + - Check configuration + - Restart bareos-filedaemon diff --git a/vars/RedHat.yml b/vars/RedHat.yml index d08f2ee..97eee65 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -11,9 +11,11 @@ bareos_fd_plugin_list: 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-mysqlclient + - python3-PyMySQL - name: postgresql packages: diff --git a/vars/RedHat_7.yml b/vars/RedHat_7.yml index 4ede9fe..1358125 100644 --- a/vars/RedHat_7.yml +++ b/vars/RedHat_7.yml @@ -7,7 +7,7 @@ bareos_fd_debug_packages: - bareos-debuginfo - gdb -bareos_fd_plugin_default_name: python2 +bareos_fd_plugin_default_name: python bareos_fd_plugin_list: - name: mariabackup packages: @@ -15,7 +15,7 @@ bareos_fd_plugin_list: - name: mysql packages: - - python2-mysqlclient + - MySQL-python - name: postgresql packages: From e2750d89a18c08f95bc8464b5a5dcbf2e50ce01f Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Mon, 12 Feb 2024 12:36:41 +0100 Subject: [PATCH 14/19] fix(ci): workaround for broken LDAP plugin package Debian * chore(lint): replace yes/no with true/false in molecule --- molecule/default/converge.yml | 28 +++++++++++++++------------- molecule/default/prepare.yml | 6 +++--- molecule/default/verify.yml | 4 +++- vars/Debian.yml | 1 + 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 43019a3..435a7ab 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -1,14 +1,14 @@ --- - name: Converge hosts: all - become: yes - gather_facts: yes + become: true + gather_facts: true roles: - role: ansible-role-bareos_fd - bareos_fd_backup_configurations: yes - bareos_fd_install_debug_packages: yes - bareos_fd_encryption_enabled: yes + bareos_fd_backup_configurations: true + bareos_fd_install_debug_packages: true + bareos_fd_encryption_enabled: true bareos_fd_encryption_private_key: | -----BEGIN RSA PRIVATE KEY----- MIIJKAIBAAKCAgEAvFS5DDxBm2Hgf6LM2QnU3eKTw6PHpCBESjuqoKDnwnjL9wXH @@ -88,13 +88,13 @@ bareos_fd_directors: - name: "bareos-dir" password: "secretpassword" - monitor: no - connection_from_client_to_director: yes - connection_from_director_to_client: no - tls_enable: yes - tls_verify_peer: no + monitor: false + connection_from_client_to_director: true + connection_from_director_to_client: false + tls_enable: true + tls_verify_peer: false - name: "disabled-director" - enabled: no + enabled: false bareos_fd_messages: - name: "Standard" director: @@ -115,9 +115,11 @@ - "!skipped" - "!saved" - name: "disabled-message" - enabled: no + enabled: false bareos_fd_plugins: - mariabackup - mysql - - ldap - postgresql + # TODO disabled as package `bareos-filedaemon-ldap-python-plugin` + # has broken dependencies on Debian (python-ldap instead of python3-ldap) + # - ldap diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml index c980188..8af8b33 100644 --- a/molecule/default/prepare.yml +++ b/molecule/default/prepare.yml @@ -1,10 +1,10 @@ --- - name: Prepare hosts: all - become: yes - gather_facts: no + become: true + gather_facts: true roles: - role: robertdebock.bootstrap - role: adfinis.bareos_repository - bareos_repository_enable_tracebacks: yes + bareos_repository_enable_tracebacks: true diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index 6854b50..e0719ac 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -23,7 +23,9 @@ name: - bareos-filedaemon-mariabackup-python-plugin - bareos-filedaemon-postgresql-python-plugin - - bareos-filedaemon-ldap-python-plugin + # TODO disabled as package `bareos-filedaemon-ldap-python-plugin` + # has broken dependencies on Debian (python-ldap instead of python3-ldap) + # - bareos-filedaemon-ldap-python-plugin state: present check_mode: true diff: true diff --git a/vars/Debian.yml b/vars/Debian.yml index f4b59e7..459ce77 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -21,4 +21,5 @@ bareos_fd_plugin_list: - name: ldap packages: + - python3-ldap - bareos-filedaemon-ldap-python-plugin From 3ccad11ad4a8cb8433a5e0d7f96773d63f8fd8ab Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Mon, 12 Feb 2024 12:46:37 +0100 Subject: [PATCH 15/19] fix(vars): add symlink for CentOS_7 to RedHat_7 --- vars/CentOS_7.yml | 1 + 1 file changed, 1 insertion(+) create mode 120000 vars/CentOS_7.yml diff --git a/vars/CentOS_7.yml b/vars/CentOS_7.yml new file mode 120000 index 0000000..105e630 --- /dev/null +++ b/vars/CentOS_7.yml @@ -0,0 +1 @@ +RedHat_7.yml \ No newline at end of file From 295105b901799854581ba6f4e86b82fdb33c7c07 Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Mon, 12 Feb 2024 13:01:05 +0100 Subject: [PATCH 16/19] fix(ci): rm gather_facts from prepare.yml --- molecule/default/prepare.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml index 8af8b33..4d0a5dd 100644 --- a/molecule/default/prepare.yml +++ b/molecule/default/prepare.yml @@ -2,7 +2,7 @@ - name: Prepare hosts: all become: true - gather_facts: true + gather_facts: false roles: - role: robertdebock.bootstrap From b2d765be5713b0a34abd778b60f9636f15389728 Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Mon, 12 Feb 2024 13:15:54 +0100 Subject: [PATCH 17/19] fix(vars): missing bareos_fd_plugin_dir RedHat_7 --- vars/RedHat_7.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/vars/RedHat_7.yml b/vars/RedHat_7.yml index 1358125..4fdc169 100644 --- a/vars/RedHat_7.yml +++ b/vars/RedHat_7.yml @@ -7,6 +7,7 @@ bareos_fd_debug_packages: - bareos-debuginfo - gdb +bareos_fd_plugin_dir: "/usr/lib64/bareos/plugins" bareos_fd_plugin_default_name: python bareos_fd_plugin_list: - name: mariabackup From 26ecaeadd47f370dc01ca3dd80e23bc61a8db02c Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Mon, 12 Feb 2024 14:18:18 +0100 Subject: [PATCH 18/19] chore: simplify plugin setup, update myself template instead of doing a convoluted loop to compare the lists between host_vars and the role vars, just use the vars once, as all plugins use the same values anyway. only the FileSet on the Director's side has to differ per plugin. Refs: https://docs.bareos.org/TasksAndConcepts/Plugins.html#file-daemon-plugins --- templates/myself.conf.j2 | 8 ++++---- vars/Debian.yml | 2 +- vars/RedHat.yml | 2 +- vars/RedHat_7.yml | 2 +- vars/Suse.yml | 2 +- vars/main.yml | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/templates/myself.conf.j2 b/templates/myself.conf.j2 index 1b4860a..3579d14 100644 --- a/templates/myself.conf.j2 +++ b/templates/myself.conf.j2 @@ -31,15 +31,15 @@ Client { {% for plugin in bareos_fd_plugins %} {% for item in bareos_fd_plugin_list if item.name == plugin %} -{% if item.plugin_dir is defined %} ## if plugin_dir is defined on plugin level +{% if item.plugin_dir is defined %} {# if plugin_dir is defined on plugin level #} Plugin Directory = "{{ item.plugin_dir }}" -{% else %} ## use bareos_fd_plugin_dir instead +{% else %} {# use bareos_fd_plugin_dir instead #} Plugin Directory = "{{ bareos_fd_plugin_dir }}" {% endif %} -{% if item.plugin_names is defined %} ## if plugin_names is defined on plugin level +{% if item.plugin_names is defined %} {# if plugin_names is defined on plugin level #} Plugin Names = "{{ item.plugin_names }}" -{% else %} ## use bareos_fd_plugin_default_name instead +{% else %} {# use bareos_fd_plugin_default_name instead #} Plugin Names = "{{ bareos_fd_plugin_default_name }}" {% endif %} diff --git a/vars/Debian.yml b/vars/Debian.yml index 459ce77..f9bece5 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -5,7 +5,7 @@ bareos_fd_debug_packages: - gdb bareos_fd_plugin_dir: "/usr/lib/bareos/plugins" -bareos_fd_plugin_default_name: python3 +bareos_fd_plugin_name: python3 bareos_fd_plugin_list: - name: mariabackup packages: diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 97eee65..ff0a2e1 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -5,7 +5,7 @@ bareos_fd_debug_packages: - gdb bareos_fd_plugin_dir: "/usr/lib64/bareos/plugins" -bareos_fd_plugin_default_name: python3 +bareos_fd_plugin_name: python3 bareos_fd_plugin_list: - name: mariabackup packages: diff --git a/vars/RedHat_7.yml b/vars/RedHat_7.yml index 4fdc169..f584714 100644 --- a/vars/RedHat_7.yml +++ b/vars/RedHat_7.yml @@ -8,7 +8,7 @@ bareos_fd_debug_packages: - gdb bareos_fd_plugin_dir: "/usr/lib64/bareos/plugins" -bareos_fd_plugin_default_name: python +bareos_fd_plugin_name: python bareos_fd_plugin_list: - name: mariabackup packages: diff --git a/vars/Suse.yml b/vars/Suse.yml index be7a05a..6486726 100644 --- a/vars/Suse.yml +++ b/vars/Suse.yml @@ -4,7 +4,7 @@ bareos_fd_debug_packages: - gdb bareos_fd_plugin_dir: "/usr/lib64/bareos/plugins" -bareos_fd_plugin_default_name: python3 +bareos_fd_plugin_name: python3 bareos_fd_plugin_list: - name: mariabackup packages: diff --git a/vars/main.yml b/vars/main.yml index e1a4ef1..74ade9d 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -5,7 +5,7 @@ bareos_fd_encryption_packages: - python3-cryptography bareos_fd_service: bareos-filedaemon -bareos_fd_plugin_default_name: python3 +bareos_fd_plugin_name: python3 # 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 From b1ed1cf69a91eabb7a1c610b2179ca35c4464c2c Mon Sep 17 00:00:00 2001 From: Patrick Hasler Date: Mon, 12 Feb 2024 14:34:39 +0100 Subject: [PATCH 19/19] fix: update myself.conf.j2 template --- templates/myself.conf.j2 | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/templates/myself.conf.j2 b/templates/myself.conf.j2 index 3579d14..f53bbea 100644 --- a/templates/myself.conf.j2 +++ b/templates/myself.conf.j2 @@ -24,26 +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 %} {# if plugin_dir is defined on plugin level #} - Plugin Directory = "{{ item.plugin_dir }}" -{% else %} {# use bareos_fd_plugin_dir instead #} + Plugin Names = "{{ bareos_fd_plugin_name }}" Plugin Directory = "{{ bareos_fd_plugin_dir }}" {% endif %} - -{% if item.plugin_names is defined %} {# if plugin_names is defined on plugin level #} - Plugin Names = "{{ item.plugin_names }}" -{% else %} {# use bareos_fd_plugin_default_name instead #} - Plugin Names = "{{ bareos_fd_plugin_default_name }}" -{% endif %} - -{% endfor %} -{% endfor %} -{% endif %} }