Fix: Update lf-recommended-tools ansible role 36/72636/4
authorAnil Belur <abelur@linuxfoundation.org>
Sun, 11 Feb 2024 02:18:40 +0000 (12:18 +1000)
committerAnil Belur <abelur@linuxfoundation.org>
Sun, 11 Feb 2024 04:06:14 +0000 (14:06 +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.

Fix up the ansible lint errors and warnings.

Rule Violation Summary:
count tag                   profile rule associated tags
1 command-instead-of-module basic   command-shell, idiom
1 no-free-form              basic   syntax, risk
1 name[missing]             basic   idiom
1 yaml[truthy]              basic   formatting, yaml

Change-Id: I35b22a5911cee7070571e7e3650ababd8de22738
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
.yamllint
molecule/default/molecule.yml
molecule/default/prepare.yml
tasks/main.yml
tox.ini

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 95f3484..ece185b 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 26b99d3..4adadfe 100644 (file)
@@ -5,33 +5,34 @@
 
   tasks:
     - name: Update APT cache
-      apt:
+      ansible.builtin.package:
         update_cache: yes
       when: ansible_distribution == 'Ubuntu'
       become: true
 
-    - rpm_key:
+    - name: Install GPG certs
+      ansible.builtin.rpm_key:
         state: present
         key: https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8
       when: ansible_os_family == 'RedHat'
       become: true
 
     - name: Install EPEL repository
-      yum:
+      ansible.builtin.yum:
         name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm
         state: present
       when: ansible_os_family == 'RedHat'
       become: true
 
     - name: Install yum-plugin-versionlock
-      yum:
+      ansible.builtin.yum:
         name:
           - yum-plugin-versionlock
       when: ansible_os_family == 'RedHat'
       become: true
 
     - name: Install mock
-      yum:
+      ansible.builtin.yum:
         name:
           - mock-2.17-1.el7
         state: present
       become: true
 
     - name: Lock mock-core-configs version$
-      command: yum versionlock mock
+      ansible.builtin.command: yum versionlock mock
       when:
         - ansible_os_family == 'RedHat' and ansible_distribution_major_version == "7"
       become: true
 
     - name: Install mock-core-configs from remote repo
-      yum:
+      ansible.builtin.yum:
         name: https://rpmfind.net/linux/epel/testing/7/aarch64/Packages/m/mock-core-configs-31.6-1.el7.noarch.rpm
         state: present
       when:
index 3fc6e64..225be90 100644 (file)
@@ -1,20 +1,21 @@
 ---
 - name: Load operating-system specific variables
-  include_vars: "{{ item }}"
+  ansible.builtin.include_vars: "{{ item }}"
   with_first_found:
     - "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yaml"
     - "{{ ansible_distribution }}.yaml"
     - "{{ ansible_os_family }}.yaml"
 
 # Required for direct install of parallel package from linuxsoft.cern.ch
-- rpm_key:
+- name: Install RPM GPG certs
+  ansible.builtin.rpm_key:
     state: present
     key: https://linuxsoft.cern.ch/cern/centos/7/os/x86_64/RPM-GPG-KEY-cern
   when: ansible_os_family == 'RedHat'
   become: true
 
 - name: Install LF Recommended Tools on RedHat
-  yum:
+  ansible.builtin.yum:
     name: "{{ lf_recommended_tools_packages }}"
     state: present
   when: ansible_os_family == 'RedHat'
 
 - name: Install LF Recommended Tools on Debian
   # Note: apt module requires state: 'fixed' not in dnf or yum modules
-  apt:
+  ansible.builtin.package:
     name: "{{ lf_recommended_tools_packages }}"
     state: fixed
   when: ansible_os_family == 'Debian'
   become: true
 
 - name: Install fedora-packager
-  yum: name=fedora-packager state=present
+  ansible.builtin.yum:
+    name:
+      - fedora-packager
+    state: present
   when: ansible_os_family == 'RedHat'
   become: true
 
 - name: Install PlantUML
+  become: true
   block:
     - name: Create /opt/plantuml install directory
-      file:
+      ansible.builtin.file:
         path: /opt/plantuml
         state: directory
         mode: 0755
     - name: Fetch PlantUML
-      get_url:
+      ansible.builtin.get_url:
         url: https://sourceforge.net/projects/plantuml/files/plantuml.jar/download
-        validate_certs: no
+        validate_certs: false
         dest: /opt/plantuml/plantuml.jar
         mode: 0644
       register: result
       retries: 3
       delay: 30
     - name: Install PlantUML executable script
-      copy:
+      ansible.builtin.copy:
         content: |
           #!/bin/sh
           exec java -jar /opt/plantuml/plantuml.jar "$@"
         dest: /usr/local/bin/plantuml
         mode: 0755
-  become: true
 
 - name: Add NodeSource repository/NodeJS
   vars:
     nodejs_version: "16.x"
   block:
     - name: Add NodeSource repository/NodeJS under RedHat/CentOS
+      become: true
       when: ansible_facts['os_family'] == 'RedHat'
       block:
         - name: Set up the Nodesource RPM directory.
-          set_fact:
+          ansible.builtin.set_fact:
             nodejs_rhel_rpm_dir: "pub_{{ nodejs_version }}"
 
         - name: Import Nodesource RPM key
-          rpm_key:
+          ansible.builtin.rpm_key:
             key:
               https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL
             state: present
 
         - name: Add Nodesource repositories for Node.js (CentOS 7+).
-          yum:
+          ansible.builtin.yum:
             name:
               "https://rpm.nodesource.com/{{ nodejs_rhel_rpm_dir }}/el/\
               {{ ansible_distribution_major_version }}/\
           register: node_repo
 
         - name: Update package cache if repo was added.
-          yum: update_cache=yes
+          ansible.builtin.yum: update_cache=yes
           when: node_repo is changed
           tags: ["skip_ansible_lint"]
 
         - name: Ensure Node.js AppStream module is disabled (CentOS 8+).
-          ansible.builtin.command: yum module disable -y nodejs
+          ansible.builtin.command: yum module disable -y nodejs  # noqa command-instead-of-module
           register: module_disable
           changed_when: "'Nothing to do.' not in module_disable.stdout"
           when: ansible_distribution_major_version | int >= 8
 
         - name: Ensure Node.js and npm are installed.
-          yum:
+          ansible.builtin.yum:
             name: "nodejs-{{ nodejs_version | regex_replace('x', '') }}*"
             state: present
-      become: true
 
     - name: Add NodeSource repository/NodeJS under Ubuntu
+      become: true
       when: ansible_facts['distribution'] == 'Ubuntu'
       block:
         - name: Import the NodeSource GPG key into apt
-          apt_key:
+          ansible.builtin.apt_key:
             url: "https://keyserver.ubuntu.com/pks/lookup?\
                   op=get&fingerprint=on&search=0x1655A0AB68576280"
             id: "68576280"
             state: present
 
         - name: Add NodeSource deb repository
-          apt_repository:
+          ansible.builtin.apt_repository:
             repo: "deb https://deb.nodesource.com/node_{{ nodejs_version }} \
                    {{ ansible_distribution_release }} main"
             state: present
 
         - name: Add NodeSource deb-src repository
-          apt_repository:
+          ansible.builtin.apt_repository:
             repo: "deb-src \
                    https://deb.nodesource.com/node_{{ nodejs_version }} \
                    {{ ansible_distribution_release }} main"
             state: present
 
         - name: Install Node.js
-          apt:
+          ansible.builtin.package:
             pkg:
               - nodejs
             state: present
             update_cache: true
-      become: true
diff --git a/tox.ini b/tox.ini
index 777d967..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,8 +20,10 @@ allowlist_externals =
     ./molecule.sh
 
 [testenv:pre-commit]
+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 \
@@ -44,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