Skip to content

Commit

Permalink
Merge pull request #40 from bedroge/ci
Browse files Browse the repository at this point in the history
CI for testing all playbooks + fixes for Ubuntu and Centos8
  • Loading branch information
boegel authored Oct 9, 2020
2 parents ad5bf0d + f5fe46a commit c4e0665
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/Dockerfile-centos-7
Original file line number Diff line number Diff line change
@@ -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"]
12 changes: 12 additions & 0 deletions .github/workflows/Dockerfile-centos-8
Original file line number Diff line number Diff line change
@@ -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"]
13 changes: 13 additions & 0 deletions .github/workflows/Dockerfile-ubuntu-18.04
Original file line number Diff line number Diff line change
@@ -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"]
14 changes: 14 additions & 0 deletions .github/workflows/Dockerfile-ubuntu-20.04
Original file line number Diff line number Diff line change
@@ -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"]
31 changes: 31 additions & 0 deletions .github/workflows/test-playbook.sh
Original file line number Diff line number Diff line change
@@ -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}
39 changes: 39 additions & 0 deletions .github/workflows/test-playbooks.yml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 1 addition & 1 deletion inventory/group_vars/cvmfsclients
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
roles:

- name: galaxyproject.cvmfs
version: 0.2.10
version: 0.2.13

- name: geerlingguy.repo-epel
version: 1.3.0
10 changes: 10 additions & 0 deletions stratum0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
21 changes: 21 additions & 0 deletions stratum1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit c4e0665

Please sign in to comment.