From a7bec86571bf614785083a18582872fdf97eef85 Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Fri, 5 Jul 2024 11:54:54 -0400 Subject: [PATCH] ansible: Install log4j from upstream release on SLES12SP5 Change-Id: I4faf1897162e8c400d828a515dddf24e7f49a2ab Signed-off-by: Kienan Stewart --- .../roles/lttng-ust/tasks/setup-Suse.yml | 76 +++++++++++++++++++ .../ansible/roles/lttng-ust/vars/SLES-12.yml | 3 + 2 files changed, 79 insertions(+) diff --git a/automation/ansible/roles/lttng-ust/tasks/setup-Suse.yml b/automation/ansible/roles/lttng-ust/tasks/setup-Suse.yml index dd0d189..b8f6378 100644 --- a/automation/ansible/roles/lttng-ust/tasks/setup-Suse.yml +++ b/automation/ansible/roles/lttng-ust/tasks/setup-Suse.yml @@ -1,3 +1,79 @@ --- - name: Ensure lttng-ust build dependencies are installed. zypper: "name={{ lttng_ust_packages }} state=installed update_cache=yes" + +# log4j2 is required for testing all the java agents, but is not available +# on SLES12SP5 via packages. +- name: Manually install log4j2 + when: lttng_ust_manual_log4j2_installation|default(false) + block: + - name: Check if download required + ansible.builtin.command: + argv: ['test', '-L', '/usr/share/java/log4j-core.jar', '-a', + '-e', '/usr/share/java/log4j-core.jar', '-a', + '-L', '/usr/share/java/log4j-api.jar', '-a', + '-e', '/usr/share/java/log4j-api.jar', '-a', + '-f', "/usr/share/java/apache-log4j-{{lttng_ust_log4j2_version}}-bin/log4j-api-{{lttng_ust_log4j2_version}}.jar", '-a', + '-f', "/usr/share/java/apache-log4j-{{lttng_ust_log4j2_version}}-bin/log4j-core-{{lttng_ust_log4j2_version}}.jar" + ] + ignore_errors: true + register: log4j2_download_required + - when: "log4j2_download_required.rc != 0" + block: + - ansible.builtin.tempfile: + state: file + register: log4j2_asc_tempfile + - ansible.builtin.get_url: + url: "https://archive.apache.org/dist/logging/log4j/{{lttng_ust_log4j2_version}}/apache-log4j-{{lttng_ust_log4j2_version}}-bin.tar.gz.asc" + dest: "{{log4j2_asc_tempfile.path}}" + force: true + - ansible.builtin.tempfile: + state: file + register: log4j2_tempfile + - name: Download log4j2 binary release + ansible.builtin.get_url: + checksum: "sha256:https://archive.apache.org/dist/logging/log4j/{{lttng_ust_log4j2_version}}/apache-log4j-{{lttng_ust_log4j2_version}}-bin.tar.gz.sha256" + url: "https://archive.apache.org/dist/logging/log4j/{{lttng_ust_log4j2_version}}/apache-log4j-{{lttng_ust_log4j2_version}}-bin.tar.gz" + dest: "{{log4j2_tempfile.path}}" + force: true + - ansible.builtin.tempfile: + state: file + register: log4j2_keys_tempfile + - ansible.builtin.get_url: + url: "https://downloads.apache.org/logging/KEYS" + dest: "{{log4j2_keys_tempfile.path}}" + force: true + - name: Import Apache developer keys + ansible.builtin.command: + argv: ['gpg', '--import', "{{log4j2_keys_tempfile.path}}"] + # gpg returns non-zero exit codes if only some of the keys + # fail to import. + ignore_errors: true + - name: Verify PGP signature + ansible.builtin.command: + argv: ['gpg', '--verify', "{{log4j2_asc_tempfile.path}}", "{{log4j2_tempfile.path}}"] + - name: Unpack + ansible.builtin.unarchive: + remote_src: true + src: "{{log4j2_tempfile.path}}" + dest: "/usr/share/java" + include: + - "apache-log4j-{{lttng_ust_log4j2_version}}-bin/log4j-api-{{lttng_ust_log4j2_version}}.jar" + - "apache-log4j-{{lttng_ust_log4j2_version}}-bin/log4j-core-{{lttng_ust_log4j2_version}}.jar" + - name: Setup symlinks + ansible.builtin.file: + state: link + src: "/usr/share/java/apache-log4j-{{lttng_ust_log4j2_version}}-bin/log4j-{{item}}-{{lttng_ust_log4j2_version}}.jar" + dest: '/usr/share/java/log4j-{{item}}.jar' + with_items: + - api + - core + # block: + # - ansible.builtin.file: + # state: link + # src: "/usr/share/java/log4j-api-{{lttng_ust_log4j2_version}}.jar" + # dest: '/usr/share/java/log4j-api.jar' + # - ansible.builtin.file: + # state: link + # src: "/usr/share/java/log4j-core-{{lttng_ust_log4j2_version}}.jar" + # dest: '/usr/share/java/log4j-core.jar' diff --git a/automation/ansible/roles/lttng-ust/vars/SLES-12.yml b/automation/ansible/roles/lttng-ust/vars/SLES-12.yml index 2088840..42c166c 100644 --- a/automation/ansible/roles/lttng-ust/vars/SLES-12.yml +++ b/automation/ansible/roles/lttng-ust/vars/SLES-12.yml @@ -1,4 +1,7 @@ --- +lttng_ust_log4j2_version: "2.17.1" +lttng_ust_manual_log4j2_installation: true + lttng_ust_packages: - libnuma-devel - libuuid-devel -- 2.34.1