From 662bd7e09d181a54edb1e38394fbc1b5202e9e5b Mon Sep 17 00:00:00 2001 From: Romain Pelisse Date: Fri, 19 Apr 2024 17:40:57 +0200 Subject: [PATCH] validation: add check for jdbc drivers --- molecule/install_options/verify.yml | 1 + playbooks/playbook.yml | 14 ++------------ playbooks/validate.yml | 2 ++ playbooks/vars/vars.yml | 12 ++++++++++++ roles/wildfly_validation/tasks/main.yml | 9 +++++++++ 5 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 playbooks/vars/vars.yml diff --git a/molecule/install_options/verify.yml b/molecule/install_options/verify.yml index 407b73ac..4f6078e1 100644 --- a/molecule/install_options/verify.yml +++ b/molecule/install_options/verify.yml @@ -5,6 +5,7 @@ wildfly_user: mware wildfly_group: sysgroup wildfly_java_package_name: java-17-openjdk-headless + wildfly_validation_skip_jdbc_drivers_check: false - name: Validation hosts: all diff --git a/playbooks/playbook.yml b/playbooks/playbook.yml index 7924048d..610f6373 100644 --- a/playbooks/playbook.yml +++ b/playbooks/playbook.yml @@ -1,18 +1,8 @@ --- - name: Ensure Wildfly is install and running as a service hosts: all - vars: -# app deployment can be handled throught the following list -# warning: using the yaml_config makes its mandatory to deploy -# through this list -# wildfly_apps: -# - { path: /path/to/war, unmanaged: true } - wildfly_systemd_wait_for_port: true - postgres_driver_version: 9.4.1212 - mariadb_driver_version: 3.2.0 - jdbc_drivers: - - { version: "{{ postgres_driver_version }}", name: 'org.postgresql', jar_file: "postgresql-{{ postgres_driver_version }}.jar", url: "https://repo.maven.apache.org/maven2/org/postgresql/postgresql/{{ postgres_driver_version }}/postgresql-{{ postgres_driver_version }}.jar" } - - { version: "{{ mariadb_driver_version }}", name: 'org.mariadb', jar_file: "mariadb-java-client-{{ mariadb_driver_version }}.jar", url: "https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/{{ mariadb_driver_version }}/mariadb-java-client-{{ mariadb_driver_version }}.jar" } + vars_files: + - vars/vars.yml roles: - wildfly_install - wildfly_systemd diff --git a/playbooks/validate.yml b/playbooks/validate.yml index 982685b0..cdbe08fa 100644 --- a/playbooks/validate.yml +++ b/playbooks/validate.yml @@ -2,5 +2,7 @@ - name: Verify hosts: all gather_facts: false + vars_files: + - vars/vars.yml roles: - middleware_automation.wildfly.wildfly_validation diff --git a/playbooks/vars/vars.yml b/playbooks/vars/vars.yml new file mode 100644 index 00000000..d87c4f57 --- /dev/null +++ b/playbooks/vars/vars.yml @@ -0,0 +1,12 @@ +--- +# app deployment can be handled throught the following list +# warning: using the yaml_config makes its mandatory to deploy +# through this list +# wildfly_apps: +# - { path: /path/to/war, unmanaged: true } +wildfly_systemd_wait_for_port: true +postgres_driver_version: 9.4.1212 +mariadb_driver_version: 3.2.0 +jdbc_drivers: + - { version: "{{ postgres_driver_version }}", name: 'org.postgresql', jar_file: "postgresql-{{ postgres_driver_version }}.jar", url: "https://repo.maven.apache.org/maven2/org/postgresql/postgresql/{{ postgres_driver_version }}/postgresql-{{ postgres_driver_version }}.jar" } + - { version: "{{ mariadb_driver_version }}", name: 'org.mariadb', jar_file: "mariadb-java-client-{{ mariadb_driver_version }}.jar", url: "https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/{{ mariadb_driver_version }}/mariadb-java-client-{{ mariadb_driver_version }}.jar" } diff --git a/roles/wildfly_validation/tasks/main.yml b/roles/wildfly_validation/tasks/main.yml index daa9e3cd..6a08ab70 100644 --- a/roles/wildfly_validation/tasks/main.yml +++ b/roles/wildfly_validation/tasks/main.yml @@ -117,3 +117,12 @@ loop: "{{ wildfly_validation_queries }}" when: - not wildfly_validation_skip_config_check is defined + +- name: "Verify JDBC drivers deployment (if any)" + ansible.builtin.include_tasks: verify_with_cli_queries.yml + vars: + validation_query: "/core-service=module-loading:list-resource-loader-paths(module={{ item.name }})" + loop: "{{ jdbc_drivers }}" + when: + - not wildfly_validation_skip_jdbc_drivers_check is defined + - jdbc_drivers is defined and jdbc_drivers | length > 0