From 91b37a910ec29e6c2a10c94656972a986cbf116d Mon Sep 17 00:00:00 2001 From: Guillaume Dott Date: Wed, 5 Oct 2022 14:55:42 +0200 Subject: [PATCH] Replace yum with apt for Debian support --- roles/keycloak/defaults/main.yml | 2 +- roles/keycloak/tasks/fastpackages.yml | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/roles/keycloak/defaults/main.yml b/roles/keycloak/defaults/main.yml index 7bb3bb8..9cb5002 100644 --- a/roles/keycloak/defaults/main.yml +++ b/roles/keycloak/defaults/main.yml @@ -8,7 +8,7 @@ keycloak_installdir: "{{ keycloak_dest }}/keycloak-{{ keycloak_version }}" keycloak_offline_install: False ### Install location and service settings -keycloak_jvm_package: java-1.8.0-openjdk-headless +keycloak_jvm_package: openjdk-17-jdk-headless keycloak_java_home: keycloak_dest: /opt/keycloak keycloak_jboss_home: "{{ keycloak_installdir }}" diff --git a/roles/keycloak/tasks/fastpackages.yml b/roles/keycloak/tasks/fastpackages.yml index 78bc556..e068834 100644 --- a/roles/keycloak/tasks/fastpackages.yml +++ b/roles/keycloak/tasks/fastpackages.yml @@ -2,21 +2,21 @@ - name: Check packages to be installed block: - name: "Check if packages are already installed" - ansible.builtin.command: "rpm -q {{ packages_list | join(' ') }}" + ansible.builtin.command: "dpkg -s {{ packages_list | join(' ') }}" args: warn: no - register: rpm_info - changed_when: rpm_info.failed + register: dpkg_info + changed_when: dpkg_info.failed rescue: - - name: "Add missing packages to the yum install list" + - name: "Add missing packages to the apt install list" ansible.builtin.set_fact: - packages_to_install: "{{ packages_to_install | default([]) + rpm_info.stdout_lines | map('regex_findall', 'package (.+) is not installed$') | flatten }}" + packages_to_install: "{{ packages_to_install | default([]) + dpkg_info.stdout_lines | map('regex_findall', 'package (.+) is not installed and no information is available$') | flatten }}" when: rpm_info.failed -- name: "Install packages: {{ packages_to_install }}" +- name: Install packages become: yes - ansible.builtin.yum: + ansible.builtin.apt: name: "{{ packages_to_install }}" state: present - when: packages_to_install | default([]) | length > 0 \ No newline at end of file + when: packages_to_install | default([]) | length > 0