From 46e45319baea03d111121eec11af43ef414b06b1 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Thu, 19 Oct 2023 17:00:01 +0100 Subject: [PATCH 01/12] use mirsg pre-commit meta hook and run linters on all files --- .pre-commit-config.yaml | 34 +++------------------------------ molecule/resources/converge.yml | 2 +- tasks/main.yml | 4 ++-- 3 files changed, 6 insertions(+), 34 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 56705e9..dd13233 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,33 +1,5 @@ repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + - repo: https://github.com/UCL-MIRSG/.github + rev: v0.21.0 hooks: - - id: check-added-large-files - - id: check-case-conflict - - id: check-docstring-first - - id: check-executables-have-shebangs - - id: check-merge-conflict - - id: check-yaml - - id: end-of-file-fixer - - id: fix-byte-order-marker - - id: mixed-line-ending - args: [--fix=lf] - - id: trailing-whitespace - - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.5.1 - hooks: - - id: forbid-tabs - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v2.7.1 - hooks: - - id: prettier - exclude: ".yml$" - - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.23.0 - hooks: - - id: check-github-workflows - - repo: https://github.com/ansible-community/ansible-lint.git - rev: v6.16.2 - hooks: - - id: ansible-lint - args: ["-p", "."] + - id: mirsg-hooks diff --git a/molecule/resources/converge.yml b/molecule/resources/converge.yml index 545b0d8..3d2b5c8 100644 --- a/molecule/resources/converge.yml +++ b/molecule/resources/converge.yml @@ -6,7 +6,7 @@ pre_tasks: - name: Wait for systemd to complete initialization. - ansible.builtin.command: systemctl is-system-running + ansible.builtin.command: systemctl is-system-running # noqa: command-instead-of-module register: systemctl_status until: > 'running' in systemctl_status.stdout or diff --git a/tasks/main.yml b/tasks/main.yml index 4cd508b..e24fd0c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: ensure Java version {{ java.package }} is installed +- name: Ensure correct Java version is installed - {{ java.package }} ansible.builtin.package: name: "{{ java.package }}" state: installed @@ -8,5 +8,5 @@ ansible.builtin.template: src: "java_home.sh.j2" dest: "{{ java.profile_d }}/java_home.sh" - mode: 0644 + mode: "0644" when: java.home is defined and java.home != '' From 27a6be4fbe67f83c499ce4c07837dee19ab816a2 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 20 Oct 2023 09:15:44 +0100 Subject: [PATCH 02/12] Use the mirsg linting and molecule-test actions --- .github/workflows/checks.yml | 41 ++++++++-------------------------- .github/workflows/molecule.yml | 25 ++++----------------- 2 files changed, 13 insertions(+), 53 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index dcc6714..e057905 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -1,40 +1,17 @@ ---- -name: Pre-commit checks +name: Linting + on: - pull_request: push: branches: - - main + - main + - "renovate/**" + pull_request: jobs: - build: + linting: runs-on: ubuntu-latest steps: - - name: Checkout source - uses: actions/checkout@v3 - - - name: Set up python - uses: actions/setup-python@v4 - with: - python-version: 3.9 - - - name: Set PY - run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV - - - name: Cache pre-commit install - uses: actions/cache@v3 + - uses: UCL-MIRSG/.github/actions/linting@v0.22.0 with: - path: | - ${{ env.pythonLocation }} - ~/.cache/pre-commit - key: | - pre-commit-${{ env.PY }}-${{ hashFiles('.pre-commit-config.yaml') }} - - - name: Install dependencies - run: pip install pre-commit - - - name: Install pre-commit hooks - run: pre-commit install - - - name: Run pre-commit - run: pre-commit run --all-files --color always + ansible-roles-config: ./playbooks/roles/requirements.yml + pre-commit-config: ./.pre-commit-config.yaml diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml index 23f01bd..b404943 100644 --- a/.github/workflows/molecule.yml +++ b/.github/workflows/molecule.yml @@ -1,4 +1,4 @@ -name: "mirsg.tomcat" +name: Molecule Test on: pull_request: push: @@ -14,28 +14,11 @@ jobs: molecule_scenario: - centos7 - rocky8 - env: PY_COLORS: 1 ANSIBLE_FORCE_COLOR: 1 - steps: - - name: Check out code - uses: actions/checkout@v3 - - - name: Set up Python 3.9 - uses: actions/setup-python@v2 + - name: Run `molecule test` + uses: UCL-MIRSG/.github/actions/molecule-test@v0.22.0 with: - python-version: 3.9 - - - name: Install test dependencies - run: | - sudo apt-get update && sudo apt-get -y install rsync - python3 -m pip install --upgrade pip - python3 -m pip install ansible ansible-lint molecule molecule-plugins[docker] docker requests==2.29.0 - - - name: Run role tests - run: >- - molecule --version && - ansible --version && - molecule --debug test -s ${{ matrix.molecule_scenario }} + scenario: ${{ matrix.molecule_scenario }} From 892f4102da91724285b075337c803645dfabb7d7 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 20 Oct 2023 09:16:15 +0100 Subject: [PATCH 03/12] make renovate json config hidden file --- renovate.json => .renovaterc.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename renovate.json => .renovaterc.json (100%) diff --git a/renovate.json b/.renovaterc.json similarity index 100% rename from renovate.json rename to .renovaterc.json From 32c050e9c48ab769f9e8a619801c85801b076768 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 20 Oct 2023 09:58:37 +0100 Subject: [PATCH 04/12] Use mirsg renovate config --- .renovaterc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.renovaterc.json b/.renovaterc.json index 170904e..663f302 100644 --- a/.renovaterc.json +++ b/.renovaterc.json @@ -1,4 +1,4 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["config:base", ":enablePreCommit"] + "extends": ["github>UCL-MIRSG/.github//renovate/default-config.json"] } From c3d0239e194e3ad2f8ed1361a9787f8588deda99 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 20 Oct 2023 10:42:41 +0100 Subject: [PATCH 05/12] remove empty handlers directory --- handlers/main.yml | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 handlers/main.yml diff --git a/handlers/main.yml b/handlers/main.yml deleted file mode 100644 index 5889afa..0000000 --- a/handlers/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# handlers file for ../ansible-role-install-java From b309ebc48bc938eba61c63a522d04d2f9809ffe2 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 20 Oct 2023 10:47:14 +0100 Subject: [PATCH 06/12] use flat names for variables rather than nested --- README.md | 27 +++++++++------------------ defaults/main.yml | 10 ++++------ tasks/main.yml | 8 ++++---- templates/java_home.sh.j2 | 2 +- 4 files changed, 18 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index cc1610a..2676796 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,16 @@ -Ansible Role: mirsg.java -========= +# Ansible Role: mirsg.java A role for install and configuring Java. -Role Variables --------------- +## Role Variables -`java` - A dictionary containing: +`java_profile_d`: Defaults to "/etc/profile.d". -`profile_d`: Defaults to "/etc/profile.d". +`java_home`: Defaults to "/usr/lib/jvm/jre" -`home`: Defaults to "/usr/lib/jvm/jre" +`java_package`: Defaults to "java-1.8.0-openjdk-devel" -`package`: Defaults to "java-1.8.0-openjdk-devel" - -`keystore_path`: Defaults to "/usr/lib/jvm/jre/lib/security/cacerts/" - -Example Playbook ----------------- +## Example Playbook Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: @@ -25,16 +18,14 @@ passed in as parameters) is always nice for users too: ```yaml - hosts: servers roles: - - { role: mirsg.java } + - { role: mirsg.java } ``` -License -------- +## License BSD -Author Information ------------------- +## Author Information This role was created by the [Medical Imaging Research Software Group](https://www.ucl.ac.uk/advanced-research-computing/expertise/research-software-development/medical-imaging-research-software-group) diff --git a/defaults/main.yml b/defaults/main.yml index 7ee0e8a..f8014c6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,7 +1,5 @@ --- -# defaults file for ../ansible-role-install-java -java: - profile_d: "/etc/profile.d" - home: "/usr/lib/jvm/jre" - package: "java-1.8.0-openjdk-devel" - keystore_path: "/usr/lib/jvm/jre/lib/security/cacerts/" +java_profile_d: "/etc/profile.d" +java_home: "/usr/lib/jvm/jre" +java_package: "java-1.8.0-openjdk-devel" +java_keystore_path: "/usr/lib/jvm/jre/lib/security/cacerts/" diff --git a/tasks/main.yml b/tasks/main.yml index e24fd0c..e6b4ef4 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,12 +1,12 @@ --- -- name: Ensure correct Java version is installed - {{ java.package }} +- name: Ensure correct Java version is installed - {{ java_package }} ansible.builtin.package: - name: "{{ java.package }}" + name: "{{ java_package }}" state: installed - name: Set JAVA_HOME through shell script ansible.builtin.template: src: "java_home.sh.j2" - dest: "{{ java.profile_d }}/java_home.sh" + dest: "{{ java_profile_d }}/java_home.sh" mode: "0644" - when: java.home is defined and java.home != '' + when: java_home is defined and java_home != '' diff --git a/templates/java_home.sh.j2 b/templates/java_home.sh.j2 index ab5bbdb..571fab8 100644 --- a/templates/java_home.sh.j2 +++ b/templates/java_home.sh.j2 @@ -1 +1 @@ -export JAVA_HOME="{{ java.home }}" +export JAVA_HOME="{{ java_home }}" From e1735994e965addd416b57c6c535ef0036eb26f1 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 20 Oct 2023 10:51:46 +0100 Subject: [PATCH 07/12] Use latest version of mirsg actions --- .github/workflows/checks.yml | 2 +- .github/workflows/molecule.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index e057905..226045a 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -11,7 +11,7 @@ jobs: linting: runs-on: ubuntu-latest steps: - - uses: UCL-MIRSG/.github/actions/linting@v0.22.0 + - uses: UCL-MIRSG/.github/actions/linting@v0.23.0 with: ansible-roles-config: ./playbooks/roles/requirements.yml pre-commit-config: ./.pre-commit-config.yaml diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml index b404943..1d0f25d 100644 --- a/.github/workflows/molecule.yml +++ b/.github/workflows/molecule.yml @@ -19,6 +19,6 @@ jobs: ANSIBLE_FORCE_COLOR: 1 steps: - name: Run `molecule test` - uses: UCL-MIRSG/.github/actions/molecule-test@v0.22.0 + uses: UCL-MIRSG/.github/actions/molecule-test@v0.23.0 with: scenario: ${{ matrix.molecule_scenario }} From 34e2dc3962b0aee55c4c473cb89634bee72b457a Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 20 Oct 2023 10:59:37 +0100 Subject: [PATCH 08/12] remove ansible requirements path from linting action --- .github/workflows/checks.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 226045a..9c6e28f 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -13,5 +13,4 @@ jobs: steps: - uses: UCL-MIRSG/.github/actions/linting@v0.23.0 with: - ansible-roles-config: ./playbooks/roles/requirements.yml pre-commit-config: ./.pre-commit-config.yaml From 1add8628cfd5d692fac5ba7274068fdecda8c3ee Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 20 Oct 2023 11:37:55 +0100 Subject: [PATCH 09/12] run pre-commit on all files --- meta/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meta/main.yml b/meta/main.yml index caf5f44..d70b150 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -41,7 +41,8 @@ galaxy_info: # - 7 # - 99.99 - galaxy_tags: [] + galaxy_tags: + [] # List tags for your role here, one per line. A tag is a keyword that describes # and categorizes the role. Users find roles by searching for tags. Be sure to # remove the '[]' above, if you add tags to this list. From cf8ec760029e55e10871af0b168192b31078f251 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 20 Oct 2023 11:38:15 +0100 Subject: [PATCH 10/12] Add workflow to add opened issues to mirsg project board --- .github/workflows/add-issue-to-project.yml | 15 +++++++++++++++ .github/workflows/checks.yml | 2 +- .github/workflows/molecule.yml | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/add-issue-to-project.yml diff --git a/.github/workflows/add-issue-to-project.yml b/.github/workflows/add-issue-to-project.yml new file mode 100644 index 0000000..e04a570 --- /dev/null +++ b/.github/workflows/add-issue-to-project.yml @@ -0,0 +1,15 @@ +name: Add issue to project + +on: + issues: + types: + - opened + +jobs: + add-issue-to-project: + runs-on: ubuntu-latest + steps: + - uses: UCL-MIRSG/.github/actions/add-to-project@v0.24.0 + with: + app_id: ${{ secrets.APP_ID }} + app_pem: ${{ secrets.APP_PEM }} diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 9c6e28f..f73d762 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -11,6 +11,6 @@ jobs: linting: runs-on: ubuntu-latest steps: - - uses: UCL-MIRSG/.github/actions/linting@v0.23.0 + - uses: UCL-MIRSG/.github/actions/linting@v0.24.0 with: pre-commit-config: ./.pre-commit-config.yaml diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml index 1d0f25d..9f467e5 100644 --- a/.github/workflows/molecule.yml +++ b/.github/workflows/molecule.yml @@ -19,6 +19,6 @@ jobs: ANSIBLE_FORCE_COLOR: 1 steps: - name: Run `molecule test` - uses: UCL-MIRSG/.github/actions/molecule-test@v0.23.0 + uses: UCL-MIRSG/.github/actions/molecule-test@v0.24.0 with: scenario: ${{ matrix.molecule_scenario }} From dfa4223f8c2d7f6911df70491516d28f29a008c7 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 20 Oct 2023 12:01:31 +0100 Subject: [PATCH 11/12] Fix add-issue-to-projcet action inputs Co-authored-by: Patrick Roddy --- .github/workflows/add-issue-to-project.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/add-issue-to-project.yml b/.github/workflows/add-issue-to-project.yml index e04a570..c0b7583 100644 --- a/.github/workflows/add-issue-to-project.yml +++ b/.github/workflows/add-issue-to-project.yml @@ -11,5 +11,5 @@ jobs: steps: - uses: UCL-MIRSG/.github/actions/add-to-project@v0.24.0 with: - app_id: ${{ secrets.APP_ID }} - app_pem: ${{ secrets.APP_PEM }} + app-id: ${{ secrets.APP_ID }} + app-pem: ${{ secrets.APP_PEM }} From 1fb4bca5a60aca9dbd77a2adcfcf4f6230fcb9d5 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 20 Oct 2023 12:02:35 +0100 Subject: [PATCH 12/12] Fix failed_when statement for role pre-tasks --- molecule/resources/converge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/molecule/resources/converge.yml b/molecule/resources/converge.yml index 3d2b5c8..8fd6e94 100644 --- a/molecule/resources/converge.yml +++ b/molecule/resources/converge.yml @@ -15,7 +15,7 @@ delay: 5 when: ansible_service_mgr == 'systemd' changed_when: false - failed_when: systemctl_status.rc > 1 + failed_when: systemctl_status.rc > 0 roles: - role: mirsg.java