From a68fc9aaa39ba731d781e513eec4f116817037d1 Mon Sep 17 00:00:00 2001 From: Alex Thibault--Ferial <alex.thibault-ferial@ess.eu> Date: Thu, 17 Aug 2023 13:51:31 +0200 Subject: [PATCH] Ubuntu 22 compatibility --- .gitlab-ci.yml | 62 ++++++++++++++++++++++++++++++++++- molecule/default/molecule.yml | 8 +++++ molecule/default/prepare.yml | 5 +-- tasks/main.yml | 7 ++++ 4 files changed, 79 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 91f165f..2a10de8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,2 +1,62 @@ --- -include: 'https://gitlab.esss.lu.se/ics-infrastructure/gitlab-ci-yml/raw/master/Molecule.gitlab-ci.yml' +variables: + GIT_SUBMODULE_STRATEGY: normal + CSENTRY_URL: https://csentry.esss.lu.se + CSENTRY_TOKEN: to-be-defined-in-group-variables + ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS: ignore + MOLECULE_FLAGS: "" + +workflow: + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_PROJECT_ID == $CI_MERGE_REQUEST_SOURCE_PROJECT_ID + when: never + - when: always + +default: + after_script: + - rm -f ~/.ssh/id_ed25519 + before_script: + # Make sure there are no other roles or playbooks in the parent directory + # molecule lint would process them otherwise (if they are dependencies) + - find .. -maxdepth 1 -mindepth 1 -type d ! -name ${CI_PROJECT_NAME} ! -name ${CI_PROJECT_NAME}.tmp -exec rm -rf {} \; + # Add a ssh key to be able to clone private roles + - mkdir -p ~/.ssh + - echo "${MOLECULE_SSH_KEY}" > ~/.ssh/id_ed25519 + - chmod 600 ~/.ssh/id_ed25519 + - ssh-keyscan -H gitlab.esss.lu.se > ~/.ssh/known_hosts + - conda activate molecule + +stages: + - test + - analyse + +run_molecule: + tags: + - molecule + stage: test + script: + - molecule $MOLECULE_FLAGS test --all + rules: + - if: '$CI_COMMIT_TAG == null' + +run_pytest: + tags: + - molecule + stage: test + script: + - pytest -v tests + rules: + - if: '$CI_COMMIT_TAG == null' + exists: + - tests/*.py + +run-sonar-scanner: + tags: + - docker + stage: analyse + image: sonarsource/sonar-scanner-cli:latest + before_script: [] + script: + - sonar-scanner -Dsonar.projectKey=$CI_PROJECT_NAME -Dsonar.sources=. + rules: + - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PROJECT_ROOT_NAMESPACE == "ics-ansible-galaxy"' diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 72b8afd..4a9624a 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -28,3 +28,11 @@ platforms: - "vbguest.auto_update = false" groups: - default_group + - name: ics-ans-role-jmasar-ubuntu + box: ubuntu/jammy64 + memory: 2048 + cpus: 2 + instance_raw_config_args: + - "vbguest.auto_update = false" + groups: + - default_group diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml index 29049e3..730b09b 100644 --- a/molecule/default/prepare.yml +++ b/molecule/default/prepare.yml @@ -1,10 +1,10 @@ --- - name: Prepare hosts: all - gather_facts: false + gather_facts: true tasks: - name: Install python for Ansible - raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal) + raw: test -e /usr/bin/python || (apt -y update && apt install -y python3-minimal) become: true changed_when: false - name: set selinux to permissive @@ -12,3 +12,4 @@ selinux: policy: targeted state: permissive + when: ansible_os_family == 'RedHat' diff --git a/tasks/main.yml b/tasks/main.yml index 2fe21ea..803d04e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -3,6 +3,13 @@ yum: name: "{{ jmasar_required_packages }}" state: present + when: ansible_os_family == 'RedHat' + +- name: install jmasar dependencies + apt: + name: "{{ jmasar_required_packages }}" + state: present + when: ansible_os_family == 'Debian' - name: create jmasar user to run the service user: -- GitLab