From 569ca7d91cde3e1c1f351ff67a6be4db669b509b Mon Sep 17 00:00:00 2001 From: Daniel Matthews Date: Thu, 18 Jul 2024 14:54:05 +0100 Subject: [PATCH] Fix molecule prepare playbooks (#129) Changes: - Handle Rocky8 by renaming `roles/provision/tasks/RedHat9.yml` to `roles/provision/tasks/RedHat.yml` and including when `ansible_distribution_major_version` is not `7`. - Fix all the broken `prepare.yml` playbooks used by `molecule` - Changed triggers to run all tests on all PRs (closes #113) --- .github/workflows/molecule-docker.yml | 9 ++++++++- .github/workflows/molecule-firewalld.yml | 9 ++++++++- .github/workflows/molecule-install-omero.yml | 12 +++++++++--- .github/workflows/molecule-install-xnat.yml | 12 ++++++++---- .github/workflows/molecule-java.yml | 9 ++++++++- .github/workflows/molecule-monitoring.yml | 10 ++++++++-- .github/workflows/molecule-nginx.yml | 9 ++++++++- .github/workflows/molecule-postgresql.yml | 9 ++++++++- .github/workflows/molecule-postgresql_upgrade.yml | 6 ++++++ .github/workflows/molecule-provision.yml | 9 ++++++++- .github/workflows/molecule-provision_accounts.yml | 6 ++++++ .github/workflows/molecule-python.yml | 9 ++++++++- .github/workflows/molecule-tomcat.yml | 9 ++++++++- playbooks/molecule/resources/monitoring/prepare.yml | 6 ++---- playbooks/molecule/resources/shared/prepare.yml | 6 ++---- roles/docker/molecule/resources/prepare.yml | 7 +++---- roles/firewalld/molecule/resources/prepare.yml | 6 ++---- roles/install_java/molecule/resources/prepare.yml | 6 ++---- roles/install_python/molecule/resources/prepare.yml | 7 +++---- roles/nginx/molecule/resources/prepare.yml | 7 +++---- roles/postgresql/molecule/resources/prepare.yml | 6 ++---- .../molecule/resources/prepare.yml | 6 ++---- roles/provision/tasks/{RedHat9.yml => RedHat.yml} | 0 roles/provision/tasks/main.yml | 10 +++++++--- .../molecule/resources/prepare.yml | 6 ++---- roles/tomcat/molecule/resources/prepare.yml | 6 ++---- 26 files changed, 133 insertions(+), 64 deletions(-) rename roles/provision/tasks/{RedHat9.yml => RedHat.yml} (100%) diff --git a/.github/workflows/molecule-docker.yml b/.github/workflows/molecule-docker.yml index 6da2f519..6dc1153e 100644 --- a/.github/workflows/molecule-docker.yml +++ b/.github/workflows/molecule-docker.yml @@ -5,8 +5,15 @@ on: pull_request: paths: - molecule_configs/* - - roles/docker/** + - playbooks/** + - roles/** - .github/workflows/molecule-docker.yml + - "!**/README.md" + +concurrency: + cancel-in-progress: true + group: >- + ${{ github.workflow }}-${{ github.event.pull_request.number }} jobs: molecule-docker: diff --git a/.github/workflows/molecule-firewalld.yml b/.github/workflows/molecule-firewalld.yml index 38a38ad3..7e95f02c 100644 --- a/.github/workflows/molecule-firewalld.yml +++ b/.github/workflows/molecule-firewalld.yml @@ -5,8 +5,15 @@ on: pull_request: paths: - molecule_configs/* - - roles/firewalld/** + - playbooks/** + - roles/** - .github/workflows/molecule-firewalld.yml + - "!**/README.md" + +concurrency: + cancel-in-progress: true + group: >- + ${{ github.workflow }}-${{ github.event.pull_request.number }} jobs: molecule-firewalld: diff --git a/.github/workflows/molecule-install-omero.yml b/.github/workflows/molecule-install-omero.yml index e9ee5715..f59a6eb1 100644 --- a/.github/workflows/molecule-install-omero.yml +++ b/.github/workflows/molecule-install-omero.yml @@ -4,14 +4,20 @@ name: Test install_omero playbook on: pull_request: paths: - - roles/omero_server/** - - playbooks/install_omero.yml - - playbooks/molecule/**/omero/** + - molecule_configs/* + - playbooks/** + - roles/** - .github/workflows/molecule-install-omero.yml + - "!**/README.md" release: types: - published +concurrency: + cancel-in-progress: true + group: >- + ${{ github.workflow }}-${{ github.event.pull_request.number }} + jobs: molecule-install-omero: runs-on: ubuntu-latest diff --git a/.github/workflows/molecule-install-xnat.yml b/.github/workflows/molecule-install-xnat.yml index 5f8df7a2..25083858 100644 --- a/.github/workflows/molecule-install-xnat.yml +++ b/.github/workflows/molecule-install-xnat.yml @@ -5,15 +5,19 @@ on: pull_request: paths: - molecule_configs/* - - roles/xnat/** - - roles/xnat_container_service/** - - playbooks/install_xnat.yml - - playbooks/molecule/**/xnat/** + - playbooks/** + - roles/** - .github/workflows/molecule-install-xnat.yml + - "!**/README.md" release: types: - published +concurrency: + cancel-in-progress: true + group: >- + ${{ github.workflow }}-${{ github.event.pull_request.number }} + jobs: molecule-install-xnat: runs-on: ubuntu-latest diff --git a/.github/workflows/molecule-java.yml b/.github/workflows/molecule-java.yml index 20a386a6..1bfae1f9 100644 --- a/.github/workflows/molecule-java.yml +++ b/.github/workflows/molecule-java.yml @@ -5,8 +5,15 @@ on: pull_request: paths: - molecule_configs/* - - roles/install_java/** + - playbooks/** + - roles/** - .github/workflows/molecule-java.yml + - "!**/README.md" + +concurrency: + cancel-in-progress: true + group: >- + ${{ github.workflow }}-${{ github.event.pull_request.number }} jobs: molecule-java: diff --git a/.github/workflows/molecule-monitoring.yml b/.github/workflows/molecule-monitoring.yml index 07d5544c..16998ea0 100644 --- a/.github/workflows/molecule-monitoring.yml +++ b/.github/workflows/molecule-monitoring.yml @@ -5,9 +5,15 @@ on: pull_request: paths: - molecule_configs/* - - roles/monitoring_client/** - - roles/monitoring_server/** + - playbooks/** + - roles/** - .github/workflows/molecule-monitoring.yml + - "!**/README.md" + +concurrency: + cancel-in-progress: true + group: >- + ${{ github.workflow }}-${{ github.event.pull_request.number }} jobs: molecule-monitoring: diff --git a/.github/workflows/molecule-nginx.yml b/.github/workflows/molecule-nginx.yml index 30708e1e..6e075cb6 100644 --- a/.github/workflows/molecule-nginx.yml +++ b/.github/workflows/molecule-nginx.yml @@ -5,8 +5,15 @@ on: pull_request: paths: - molecule_configs/* - - roles/nginx/** + - playbooks/** + - roles/** - .github/workflows/molecule-nginx.yml + - "!**/README.md" + +concurrency: + cancel-in-progress: true + group: >- + ${{ github.workflow }}-${{ github.event.pull_request.number }} jobs: molecule-nginx: diff --git a/.github/workflows/molecule-postgresql.yml b/.github/workflows/molecule-postgresql.yml index 22c9c480..dd373d24 100644 --- a/.github/workflows/molecule-postgresql.yml +++ b/.github/workflows/molecule-postgresql.yml @@ -5,8 +5,15 @@ on: pull_request: paths: - molecule_configs/* - - roles/postgresql/** + - playbooks/** + - roles/** - .github/workflows/molecule-postgresql.yml + - "!**/README.md" + +concurrency: + cancel-in-progress: true + group: >- + ${{ github.workflow }}-${{ github.event.pull_request.number }} jobs: molecule-postgresql: diff --git a/.github/workflows/molecule-postgresql_upgrade.yml b/.github/workflows/molecule-postgresql_upgrade.yml index 89fd055b..5cd2daec 100644 --- a/.github/workflows/molecule-postgresql_upgrade.yml +++ b/.github/workflows/molecule-postgresql_upgrade.yml @@ -7,6 +7,12 @@ on: - molecule_configs/* - roles/postgresql_upgrade/** - .github/workflows/molecule-postgresql_upgrade.yml + - "!**/README.md" + +concurrency: + cancel-in-progress: true + group: >- + ${{ github.workflow }}-${{ github.event.pull_request.number }} jobs: molecule-postgresql-upgrade: diff --git a/.github/workflows/molecule-provision.yml b/.github/workflows/molecule-provision.yml index 7ebc547b..feecac5d 100644 --- a/.github/workflows/molecule-provision.yml +++ b/.github/workflows/molecule-provision.yml @@ -5,8 +5,15 @@ on: pull_request: paths: - molecule_configs/* - - roles/provision/** + - playbooks/** + - roles/** - .github/workflows/molecule-provision.yml + - "!**/README.md" + +concurrency: + cancel-in-progress: true + group: >- + ${{ github.workflow }}-${{ github.event.pull_request.number }} jobs: molecule-provision: diff --git a/.github/workflows/molecule-provision_accounts.yml b/.github/workflows/molecule-provision_accounts.yml index 988e7dff..f2a010d1 100644 --- a/.github/workflows/molecule-provision_accounts.yml +++ b/.github/workflows/molecule-provision_accounts.yml @@ -8,6 +8,12 @@ on: - roles/provision_accounts/** - playbooks/setup_user_accounts.yml - .github/workflows/molecule-provision_accounts.yml + - "!**/README.md" + +concurrency: + cancel-in-progress: true + group: >- + ${{ github.workflow }}-${{ github.event.pull_request.number }} jobs: molecule-provision-accounts: diff --git a/.github/workflows/molecule-python.yml b/.github/workflows/molecule-python.yml index cc0dc01d..92d7a71b 100644 --- a/.github/workflows/molecule-python.yml +++ b/.github/workflows/molecule-python.yml @@ -5,8 +5,15 @@ on: pull_request: paths: - molecule_configs/* - - roles/install_python/** + - playbooks/** + - roles/** - .github/workflows/molecule-python.yml + - "!**/README.md" + +concurrency: + cancel-in-progress: true + group: >- + ${{ github.workflow }}-${{ github.event.pull_request.number }} jobs: molecule-python: diff --git a/.github/workflows/molecule-tomcat.yml b/.github/workflows/molecule-tomcat.yml index 73babfb7..fb58a3a4 100644 --- a/.github/workflows/molecule-tomcat.yml +++ b/.github/workflows/molecule-tomcat.yml @@ -5,8 +5,15 @@ on: pull_request: paths: - molecule_configs/* - - roles/tomcat/** + - playbooks/** + - roles/** - .github/workflows/molecule-tomcat.yml + - "!**/README.md" + +concurrency: + cancel-in-progress: true + group: >- + ${{ github.workflow }}-${{ github.event.pull_request.number }} jobs: molecule-tomcat: diff --git a/playbooks/molecule/resources/monitoring/prepare.yml b/playbooks/molecule/resources/monitoring/prepare.yml index 4b61e68a..d9e7ec89 100644 --- a/playbooks/molecule/resources/monitoring/prepare.yml +++ b/playbooks/molecule/resources/monitoring/prepare.yml @@ -6,10 +6,8 @@ - name: Update YUM repo baseurls ansible.builtin.include_role: name: mirsg.infrastructure.provision - tasks_from: CentOS.yml - when: - ansible_facts['os_family'] == "RedHat" and - ansible_facts['distribution_major_version'] is version('7') + tasks_from: RedHat7.yml + when: ansible_facts['distribution_major_version'] is version('7') - name: Install sudo ansible.builtin.package: diff --git a/playbooks/molecule/resources/shared/prepare.yml b/playbooks/molecule/resources/shared/prepare.yml index 88059a03..5785eb2a 100644 --- a/playbooks/molecule/resources/shared/prepare.yml +++ b/playbooks/molecule/resources/shared/prepare.yml @@ -6,10 +6,8 @@ - name: Update YUM repo baseurls ansible.builtin.include_role: name: mirsg.infrastructure.provision - tasks_from: CentOS.yml - when: - ansible_facts['os_family'] == "RedHat" and - ansible_facts['distribution_major_version'] is version('7') + tasks_from: RedHat7.yml + when: ansible_facts['distribution_major_version'] is version('7') - name: Install sudo ansible.builtin.package: diff --git a/roles/docker/molecule/resources/prepare.yml b/roles/docker/molecule/resources/prepare.yml index 26ac907b..9e5373cf 100644 --- a/roles/docker/molecule/resources/prepare.yml +++ b/roles/docker/molecule/resources/prepare.yml @@ -6,10 +6,9 @@ - name: Update YUM repo baseurls ansible.builtin.include_role: name: mirsg.infrastructure.provision - tasks_from: CentOS.yml - when: - ansible_facts['os_family'] == "RedHat" and - ansible_facts['distribution_major_version'] is version('7') + tasks_from: RedHat7.yml + when: ansible_facts['distribution_major_version'] is version('7') + - name: Install sudo ansible.builtin.package: name: sudo diff --git a/roles/firewalld/molecule/resources/prepare.yml b/roles/firewalld/molecule/resources/prepare.yml index 708ba126..109bf946 100644 --- a/roles/firewalld/molecule/resources/prepare.yml +++ b/roles/firewalld/molecule/resources/prepare.yml @@ -6,10 +6,8 @@ - name: Update YUM repo baseurls ansible.builtin.include_role: name: mirsg.infrastructure.provision - tasks_from: CentOS.yml - when: - ansible_facts['os_family'] == "RedHat" and - ansible_facts['distribution_major_version'] is version('7') + tasks_from: RedHat7.yml + when: ansible_facts['distribution_major_version'] is version('7') - name: Install sudo ansible.builtin.package: diff --git a/roles/install_java/molecule/resources/prepare.yml b/roles/install_java/molecule/resources/prepare.yml index a04093b3..024bf7b0 100644 --- a/roles/install_java/molecule/resources/prepare.yml +++ b/roles/install_java/molecule/resources/prepare.yml @@ -6,10 +6,8 @@ - name: Update YUM repo baseurls ansible.builtin.include_role: name: mirsg.infrastructure.provision - tasks_from: CentOS.yml - when: - ansible_facts['os_family'] == "RedHat" and - ansible_facts['distribution_major_version'] is version('7') + tasks_from: RedHat7.yml + when: ansible_facts['distribution_major_version'] is version('7') - name: Install sudo ansible.builtin.package: diff --git a/roles/install_python/molecule/resources/prepare.yml b/roles/install_python/molecule/resources/prepare.yml index 8684968a..e3d24015 100644 --- a/roles/install_python/molecule/resources/prepare.yml +++ b/roles/install_python/molecule/resources/prepare.yml @@ -7,10 +7,9 @@ - name: Update YUM repo baseurls ansible.builtin.include_role: name: mirsg.infrastructure.provision - tasks_from: CentOS.yml - when: - ansible_facts['os_family'] == "RedHat" and - ansible_facts['distribution_major_version'] is version('7') + tasks_from: RedHat7.yml + when: ansible_facts['distribution_major_version'] is version('7') + - name: Install sudo ansible.builtin.package: name: sudo diff --git a/roles/nginx/molecule/resources/prepare.yml b/roles/nginx/molecule/resources/prepare.yml index 0bab1ce9..3c014205 100644 --- a/roles/nginx/molecule/resources/prepare.yml +++ b/roles/nginx/molecule/resources/prepare.yml @@ -6,10 +6,9 @@ - name: Update YUM repo baseurls ansible.builtin.include_role: name: mirsg.infrastructure.provision - tasks_from: CentOS.yml - when: - ansible_facts['os_family'] == "RedHat" and - ansible_facts['distribution_major_version'] is version('7') + tasks_from: RedHat7.yml + when: ansible_facts['distribution_major_version'] is version('7') + - name: Install sudo ansible.builtin.package: name: sudo diff --git a/roles/postgresql/molecule/resources/prepare.yml b/roles/postgresql/molecule/resources/prepare.yml index 26bd43f7..ac628122 100644 --- a/roles/postgresql/molecule/resources/prepare.yml +++ b/roles/postgresql/molecule/resources/prepare.yml @@ -6,10 +6,8 @@ - name: Update YUM repo baseurls ansible.builtin.include_role: name: mirsg.infrastructure.provision - tasks_from: CentOS.yml - when: - ansible_facts['os_family'] == "RedHat" and - ansible_facts['distribution_major_version'] is version('7') + tasks_from: RedHat7.yml + when: ansible_facts['distribution_major_version'] is version('7') - name: Install sudo ansible.builtin.package: diff --git a/roles/postgresql_upgrade/molecule/resources/prepare.yml b/roles/postgresql_upgrade/molecule/resources/prepare.yml index 9a80ca05..99ac3fe3 100644 --- a/roles/postgresql_upgrade/molecule/resources/prepare.yml +++ b/roles/postgresql_upgrade/molecule/resources/prepare.yml @@ -6,10 +6,8 @@ - name: Update YUM repo baseurls ansible.builtin.include_role: name: mirsg.infrastructure.provision - tasks_from: CentOS.yml - when: - ansible_facts['os_family'] == "RedHat" and - ansible_facts['distribution_major_version'] is version('7') + tasks_from: RedHat7.yml + when: ansible_facts['distribution_major_version'] is version('7') - name: Install sudo ansible.builtin.package: diff --git a/roles/provision/tasks/RedHat9.yml b/roles/provision/tasks/RedHat.yml similarity index 100% rename from roles/provision/tasks/RedHat9.yml rename to roles/provision/tasks/RedHat.yml diff --git a/roles/provision/tasks/main.yml b/roles/provision/tasks/main.yml index af4d57e1..8970841e 100644 --- a/roles/provision/tasks/main.yml +++ b/roles/provision/tasks/main.yml @@ -4,9 +4,13 @@ ansible.builtin.include_tasks: check_mounts.yml when: external_storage_drive is defined -- name: Set up for specific distribution - ansible.builtin.include_tasks: - RedHat{{ ansible_distribution_major_version }}.yml +- name: Set up for RedHat 7 + ansible.builtin.include_tasks: RedHat7.yml + when: ansible_facts['distribution_major_version'] is version('7') + +- name: Set up for RedHat > 7 + ansible.builtin.include_tasks: RedHat.yml + when: ansible_facts['distribution_major_version'] is not version('7') - name: Upgrade all packages # noqa: package-latest ansible.builtin.yum: diff --git a/roles/provision_accounts/molecule/resources/prepare.yml b/roles/provision_accounts/molecule/resources/prepare.yml index cd5a9a85..5900ba78 100644 --- a/roles/provision_accounts/molecule/resources/prepare.yml +++ b/roles/provision_accounts/molecule/resources/prepare.yml @@ -6,10 +6,8 @@ - name: Update YUM repo baseurls ansible.builtin.include_role: name: mirsg.infrastructure.provision - tasks_from: CentOS.yml - when: - ansible_facts['os_family'] == "RedHat" and - ansible_facts['distribution_major_version'] is version('7') + tasks_from: RedHat7.yml + when: ansible_facts['distribution_major_version'] is version('7') - name: Install sudo ansible.builtin.package: diff --git a/roles/tomcat/molecule/resources/prepare.yml b/roles/tomcat/molecule/resources/prepare.yml index bbc93f04..c58700b8 100644 --- a/roles/tomcat/molecule/resources/prepare.yml +++ b/roles/tomcat/molecule/resources/prepare.yml @@ -6,10 +6,8 @@ - name: Update YUM repo baseurls ansible.builtin.include_role: name: mirsg.infrastructure.provision - tasks_from: CentOS.yml - when: - ansible_facts['os_family'] == "RedHat" and - ansible_facts['distribution_major_version'] is version('7') + tasks_from: RedHat7.yml + when: ansible_facts['distribution_major_version'] is version('7') - name: Install sudo ansible.builtin.package: