diff --git a/.github/workflows/Dockerfile-centos-7 b/.github/workflows/Dockerfile-centos-7 new file mode 100644 index 00000000..8c1d77f4 --- /dev/null +++ b/.github/workflows/Dockerfile-centos-7 @@ -0,0 +1,12 @@ +FROM centos:centos7 + +USER root + +RUN yum install -y epel-release +RUN yum install -y ansible +RUN yum install -y cronie + +COPY ./.github/workflows/test-playbook.sh /test-playbook.sh + +VOLUME [ “/sys/fs/cgroup” ] +CMD ["/usr/sbin/init"] diff --git a/.github/workflows/Dockerfile-centos-8 b/.github/workflows/Dockerfile-centos-8 new file mode 100644 index 00000000..74a1d4ec --- /dev/null +++ b/.github/workflows/Dockerfile-centos-8 @@ -0,0 +1,12 @@ +FROM centos:centos8 + +USER root + +RUN yum install -y epel-release +RUN yum install -y ansible +RUN yum install -y cronie + +COPY ./.github/workflows/test-playbook.sh /test-playbook.sh + +VOLUME [ “/sys/fs/cgroup” ] +CMD ["/usr/sbin/init"] diff --git a/.github/workflows/Dockerfile-ubuntu-18.04 b/.github/workflows/Dockerfile-ubuntu-18.04 new file mode 100644 index 00000000..f83f3343 --- /dev/null +++ b/.github/workflows/Dockerfile-ubuntu-18.04 @@ -0,0 +1,13 @@ +FROM ubuntu:18.04 + +USER root + +RUN apt-get update +RUN apt-get install -y cron gpg python3-pip systemd + +RUN pip3 install ansible + +COPY ./.github/workflows/test-playbook.sh /test-playbook.sh + +VOLUME [ “/sys/fs/cgroup” ] +CMD ["/lib/systemd/systemd"] diff --git a/.github/workflows/Dockerfile-ubuntu-20.04 b/.github/workflows/Dockerfile-ubuntu-20.04 new file mode 100644 index 00000000..f49f21d8 --- /dev/null +++ b/.github/workflows/Dockerfile-ubuntu-20.04 @@ -0,0 +1,14 @@ +FROM ubuntu:20.04 + +USER root + +RUN apt-get update +RUN apt-get install -y cron gpg python3-pip +RUN env DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt-get install -y systemd + +RUN pip3 install ansible + +COPY ./.github/workflows/test-playbook.sh /test-playbook.sh + +VOLUME [ “/sys/fs/cgroup” ] +CMD ["/lib/systemd/systemd"] diff --git a/.github/workflows/test-playbook.sh b/.github/workflows/test-playbook.sh new file mode 100755 index 00000000..3e599330 --- /dev/null +++ b/.github/workflows/test-playbook.sh @@ -0,0 +1,31 @@ +#!/bin/bash -l + +playbook=$1 +hostgroup=$(grep hosts $playbook | awk '{print $2}') + +# Make an inventory file with just the group for which we are running the playbook. +echo "[$hostgroup]" > inventory/hosts +echo "127.0.0.1" >> inventory/hosts + +# Make a site-specific configuration file +touch inventory/local_site_specific_vars.yml +echo 'local_cvmfs_http_proxies_allowed_clients:' >> inventory/local_site_specific_vars.yml +echo ' - 127.0.0.1' >> inventory/local_site_specific_vars.yml + +# Don't use the GEO API for the Stratum 1, since we do not have a key here. +export CVMFS_GEO_DB_FILE=NONE + +# Only test the cvmfs-config repo on the Stratum 1, as the other ones may be very large. +if [ $playbook == "stratum1.yml" ] +then + echo 'cvmfs_repositories: "[{{ eessi_cvmfs_config_repo.repository }}]"' >> inventory/local_site_specific_vars.yml +fi + +# Install the Ansible dependencies. +ansible-galaxy role install -r requirements.yml -p ./roles + +# Print our site-specific configuration file, for debugging purposes. +cat inventory/local_site_specific_vars.yml + +# Run the playbook! +ansible-playbook --connection=local -e @inventory/local_site_specific_vars.yml -v ${playbook} diff --git a/.github/workflows/test-playbooks.yml b/.github/workflows/test-playbooks.yml new file mode 100644 index 00000000..a5635f58 --- /dev/null +++ b/.github/workflows/test-playbooks.yml @@ -0,0 +1,39 @@ +name: Test Ansible Playbooks + +on: + push: + branches: + - master + paths-ignore: + - "**.md" + - "**.example" + pull_request: + branches: + - master + paths-ignore: + - "**.md" + - "**.example" + +jobs: + test-playbook: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + component: [stratum0, stratum1, localproxy, client] + os: [centos-7, centos-8, ubuntu-18.04, ubuntu-20.04] + steps: + - uses: actions/checkout@v2 + - name: Make temporary directory for /srv + run: mkdir ${GITHUB_WORKSPACE}/srv + - name: Build the Docker image + run: docker build . --file ./.github/workflows/Dockerfile-${{ matrix.os }} --tag "docker.pkg.github.com/$(echo $GITHUB_REPOSITORY | tr '[A-Z]' '[a-z]')/${{ matrix.os }}" + - name: Run the container + run: docker run -d --workdir /github/workspace --rm -e INPUT_PLAYBOOK -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v $HOME:"/github/home" -v "$HOME/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "$GITHUB_WORKSPACE":"/github/workspace" --privileged --device /dev/fuse --mount type=bind,source=${GITHUB_WORKSPACE}/srv,target=/srv --mount type=bind,source=${GITHUB_WORKSPACE}/srv,target=/var/spool/cvmfs --name ${{ matrix.component }}-${{ matrix.os }} docker.pkg.github.com/$(echo $GITHUB_REPOSITORY | tr '[A-Z]' '[a-z]')/${{ matrix.os }} + - name: Execute the playbook + run: docker exec ${{ matrix.component }}-${{ matrix.os }} /test-playbook.sh ${{ matrix.component }}.yml + - name: Execute additional playbook for Stratum 0 + run: docker exec ${{ matrix.component }}-${{ matrix.os }} /test-playbook.sh ${{ matrix.component }}-deploy-cvmfs-config.yml + if: ${{ matrix.component == 'stratum0' }} + - name: Stop the container + run: docker kill ${{ matrix.component }}-${{ matrix.os }} diff --git a/inventory/group_vars/cvmfsclients b/inventory/group_vars/cvmfsclients index 0d08e48f..ff211fcb 100644 --- a/inventory/group_vars/cvmfsclients +++ b/inventory/group_vars/cvmfsclients @@ -2,7 +2,7 @@ # List of proxies to be used for the clients. # Override this setting in your local_site_specific_vars.yml file. -cvmfs_http_proxies: "{{ local_cvmfs_http_proxies }}" +cvmfs_http_proxies: "{{ local_cvmfs_http_proxies | default(['DIRECT']) }}" # Use the CVMFS configuration repository for the clients. eessi_cvmfs_repos_enabled: config-repo diff --git a/requirements.yml b/requirements.yml index df7f39e3..ad1addb2 100644 --- a/requirements.yml +++ b/requirements.yml @@ -4,7 +4,7 @@ roles: - name: galaxyproject.cvmfs - version: 0.2.10 + version: 0.2.13 - name: geerlingguy.repo-epel version: 1.3.0 diff --git a/stratum0.yml b/stratum0.yml index 41271a3d..0e234861 100644 --- a/stratum0.yml +++ b/stratum0.yml @@ -2,6 +2,16 @@ --- - name: CVMFS Stratum 0 hosts: cvmfsstratum0servers + pre_tasks: + - name: Fix that adds additional dependencies for Debian systems + set_fact: + cvmfs_packages: + stratum0: + - apache2 + - cvmfs-server + - cvmfs-config-default + - cvmfs + when: ansible_facts['os_family'] == 'Debian' roles: - role: geerlingguy.repo-epel when: ansible_facts['os_family'] == 'RedHat' diff --git a/stratum1.yml b/stratum1.yml index 3968e208..17196dac 100644 --- a/stratum1.yml +++ b/stratum1.yml @@ -2,6 +2,27 @@ --- - name: CVMFS Stratum 1 hosts: cvmfsstratum1servers + pre_tasks: + - name: Fix that adds additional dependencies for Debian systems + set_fact: + cvmfs_packages: + stratum1: + - apache2 + - libapache2-mod-wsgi + - squid + - cvmfs-server + - cvmfs-config-default + when: ansible_facts['os_family'] == 'Debian' + - name: Fix for CentOS 8 + set_fact: + cvmfs_packages: + stratum1: + - httpd + - python3-mod_wsgi + - squid + - cvmfs-server + - cvmfs-config-default + when: ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '8' roles: - role: geerlingguy.repo-epel when: ansible_facts['os_family'] == 'RedHat'