Fix: Update java-install ansible role 35/72635/7
authorAnil Belur <abelur@linuxfoundation.org>
Sun, 11 Feb 2024 02:20:35 +0000 (12:20 +1000)
committerAnil Belur <abelur@linuxfoundation.org>
Mon, 12 Feb 2024 03:31:26 +0000 (13:31 +1000)
Update molecule test formats and update the role to build with
latest version of ansible. Fix ansible lint errors and warnings.

Update tox and pre-commit dependencies to build with latest versions
of ansible and molecule.

Change-Id: I448505ad7259a238ad8f5e5e65a210fe587fb96f
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
.github/workflows/gerrit-verify.yaml
.yamllint
meta/main.yml
molecule/default/molecule.yml
tasks/Debian.yml
tasks/RedHat.yml
tasks/main.yml
tox.ini

index 72aa927..fdf4d76 100644 (file)
@@ -124,7 +124,7 @@ jobs:
         env:
           PY_COLORS: "1"
           ANSIBLE_FORCE_COLOR: "1"
-          MOLECULE_DISTRO: ${{ matrix.distro }}
+          MOLECULE_PLATFORM_NAME: ${{ matrix.distro }}
 
   vote:
     if: ${{ always() }}
index 7626c6e..894450c 100644 (file)
--- a/.yamllint
+++ b/.yamllint
@@ -9,9 +9,7 @@ rules:
     max-spaces-inside: 1
     level: error
   line-length: disable
-  # NOTE(retr0h): Templates no longer fail this lint rule.
-  #               Uncomment if running old Molecule templates.
-  # truthy: disable
+  truthy: disable
 
 ignore: |
   .tox/
index e4940e0..3b80d2f 100644 (file)
@@ -16,12 +16,13 @@ galaxy_info:
       versions:
         - 7
         - 8
+        - 9
 
     - name: Ubuntu
       versions:
-        - xenial
         - bionic
         - focal
+        - jammy
 
   galaxy_tags:
     - java
index a5bbab2..bce15f1 100644 (file)
@@ -3,10 +3,6 @@ dependency:
   name: galaxy
 driver:
   name: docker
-lint: |
-  set -e
-  yamllint .
-  ansible-lint tasks/*.yml
 platforms:
   - name: centos7
     image: centos:7
index 094c606..2986cbd 100644 (file)
@@ -1,6 +1,6 @@
 ---
 - name: Install ppa pre-requsites
-  apt:
+  ansible.builtin.package:
     name:
       - gnupg2
     state: present
@@ -8,7 +8,7 @@
   become: true
 
 - name: Setup openjdk-r/ppa
-  apt_repository:
+  ansible.builtin.apt_repository:
     repo: 'ppa:openjdk-r/ppa'
   become: true
   register: task_result
@@ -17,7 +17,7 @@
   delay: 10
 
 - name: Install OpenJDK 1.8.0, 11 and 12
-  apt:
+  ansible.builtin.package:
     name:
       - openjdk-8-jdk
       - openjdk-11-jdk
     state: present
     update_cache: 'yes'
   become: true
+  when:
+    - ansible_os_family == 'Debian' and ansible_facts['distribution_major_version'] is version('20.04', '<=')
 
 - name: Install OpenJDK 17
-  apt:
+  ansible.builtin.package:
     name:
       - openjdk-17-jdk
     state: present
       ansible_distribution_version == "18.04"
 
 - name: Set Java path for OpenJDK 11 (non-arm)
-  set_fact:
+  ansible.builtin.set_fact:
     java_path: /usr/lib/jvm/java-1.11.0-openjdk-amd64
   when:
     - ansible_architecture != "aarch64"
 
 - name: Set Java path for OpenJDK 11 (arm)
-  set_fact:
+  ansible.builtin.set_fact:
     java_path: /usr/lib/jvm/java-1.11.0-openjdk-arm64
   when:
     - ansible_architecture == "aarch64"
index af901a6..96c1433 100644 (file)
@@ -1,11 +1,14 @@
 ---
 - name: Install Epel Repo
-  package: name=epel-release state=present
+  ansible.builtin.yum:
+    name:
+      - epel-release
+    state: present
   when: ansible_os_family == "RedHat"
   become: true
 
 - name: Install OpenJDK 1.8.0, 11
-  yum:
+  ansible.builtin.yum:
     name:
       - java-1.8.0-openjdk-devel
       - java-11-openjdk-devel
@@ -13,7 +16,7 @@
   become: true
 
 - name: Install OpenJDK 17, latest
-  yum:
+  ansible.builtin.yum:
     name:
       - java-17-openjdk-devel
       - java-latest-openjdk-devel
@@ -22,7 +25,7 @@
   become: true
 
 - name: Install OpenJDK 21, latest
-  yum:
+  ansible.builtin.yum:
     name:
       - java-21-openjdk-devel
       - java-latest-openjdk-devel
@@ -31,5 +34,5 @@
   become: true
 
 - name: Set Java path for OpenJDK 11
-  set_fact:
+  ansible.builtin.set_fact:
     java_path: /usr/lib/jvm/java-11-openjdk
index 2f39063..228a16c 100644 (file)
@@ -1,45 +1,46 @@
 ---
-- include_tasks: '{{ item }}'
+- name: Install JDK for {{ ansible_os_family }}
+  ansible.builtin.include_tasks: '{{ item }}'
   with_first_found:
     - '{{ ansible_os_family }}-{{ ansible_architecture }}.yml'
     - '{{ ansible_distribution }}.yml'
     - '{{ ansible_os_family }}.yml'
 
 - name: Set default Java
+  become: true
   block:
     - name: Set java alternatives
-      alternatives:
+      community.general.alternatives:
         name: java
         link: /usr/bin/java
         path: '{{ java_path }}/bin/java'
     - name: Set javac alternatives
-      alternatives:
+      community.general.alternatives:
         name: javac
         link: /usr/bin/javac
         path: '{{ java_path }}/bin/javac'
     - name: Set jar alternatives
-      alternatives:
+      community.general.alternatives:
         name: jar
         link: /usr/bin/jar
         path: '{{ java_path }}/bin/jar'
     - name: Set jarsigner alternatives
-      alternatives:
+      community.general.alternatives:
         name: jarsigner
         link: /usr/bin/jarsigner
         path: '{{ java_path }}/bin/jarsigner'
     - name: Set javadoc alternatives
-      alternatives:
+      community.general.alternatives:
         name: javadoc
         link: /usr/bin/javadoc
         path: '{{ java_path }}/bin/javadoc'
     - name: Set javap alternatives
-      alternatives:
+      community.general.alternatives:
         name: javap
         link: /usr/bin/javap
         path: '{{ java_path }}/bin/javap'
     - name: Set java_sdk_openjdk alternatives
-      alternatives:
+      community.general.alternatives:
         name: java_sdk_openjdk
         link: /usr/lib/jvm/java-openjdk
         path: '{{ java_path }}/bin/java'
-  become: true
diff --git a/tox.ini b/tox.ini
index d0929c3..5ad109a 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -2,20 +2,17 @@
 minversion = 1.6
 envlist =
     molecule,
-    pre-commit
+    pre-commit,
+    lint
 skipsdist=true
 
 [testenv:molecule]
 basepython = python3
 deps =
-    ansible~=2.9.6
-    ansible-lint~=4.2.0
-    detox~=0.18
+    ansible
     docker
-    yamllint
-    molecule~=3.0.8
-    molecule[docker]
-    pytest~=5.4.0
+    molecule
+    molecule-docker
 passenv = *
 commands =
     ./molecule.sh
@@ -23,9 +20,10 @@ allowlist_externals =
     ./molecule.sh
 
 [testenv:pre-commit]
-basepython = python3
+allowlist_externals =
+    /bin/sh
 deps = pre-commit
-allowlist_externals = /bin/sh
+passenv = HOME
 commands =
     pre-commit run --all-files --show-diff-on-failure
     /bin/sh -c 'if ! git config --get user.name > /dev/null; then \
@@ -45,3 +43,15 @@ commands =
     /bin/sh -c "if [ -f .git/REMOVE_USEREMAIL ]; then \
         git config --global --unset user.email; \
         rm -f .git/REMOVE_USEREMAIL; fi"
+
+[testenv:lint]
+basepython = python310
+deps =
+    ansible-lint
+    yamllint
+commands =
+    /bin/bash -c "ansible-lint tasks/*.yml"
+    yamllint .
+allowlist_externals =
+    /bin/bash
+    yamllint