Skip to content

Commit c4e0665

Browse files
authored
Merge pull request #40 from bedroge/ci
CI for testing all playbooks + fixes for Ubuntu and Centos8
2 parents ad5bf0d + f5fe46a commit c4e0665

10 files changed

+154
-2
lines changed

.github/workflows/Dockerfile-centos-7

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM centos:centos7
2+
3+
USER root
4+
5+
RUN yum install -y epel-release
6+
RUN yum install -y ansible
7+
RUN yum install -y cronie
8+
9+
COPY ./.github/workflows/test-playbook.sh /test-playbook.sh
10+
11+
VOLUME [ “/sys/fs/cgroup” ]
12+
CMD ["/usr/sbin/init"]

.github/workflows/Dockerfile-centos-8

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM centos:centos8
2+
3+
USER root
4+
5+
RUN yum install -y epel-release
6+
RUN yum install -y ansible
7+
RUN yum install -y cronie
8+
9+
COPY ./.github/workflows/test-playbook.sh /test-playbook.sh
10+
11+
VOLUME [ “/sys/fs/cgroup” ]
12+
CMD ["/usr/sbin/init"]
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM ubuntu:18.04
2+
3+
USER root
4+
5+
RUN apt-get update
6+
RUN apt-get install -y cron gpg python3-pip systemd
7+
8+
RUN pip3 install ansible
9+
10+
COPY ./.github/workflows/test-playbook.sh /test-playbook.sh
11+
12+
VOLUME [ “/sys/fs/cgroup” ]
13+
CMD ["/lib/systemd/systemd"]
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM ubuntu:20.04
2+
3+
USER root
4+
5+
RUN apt-get update
6+
RUN apt-get install -y cron gpg python3-pip
7+
RUN env DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt-get install -y systemd
8+
9+
RUN pip3 install ansible
10+
11+
COPY ./.github/workflows/test-playbook.sh /test-playbook.sh
12+
13+
VOLUME [ “/sys/fs/cgroup” ]
14+
CMD ["/lib/systemd/systemd"]

.github/workflows/test-playbook.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash -l
2+
3+
playbook=$1
4+
hostgroup=$(grep hosts $playbook | awk '{print $2}')
5+
6+
# Make an inventory file with just the group for which we are running the playbook.
7+
echo "[$hostgroup]" > inventory/hosts
8+
echo "127.0.0.1" >> inventory/hosts
9+
10+
# Make a site-specific configuration file
11+
touch inventory/local_site_specific_vars.yml
12+
echo 'local_cvmfs_http_proxies_allowed_clients:' >> inventory/local_site_specific_vars.yml
13+
echo ' - 127.0.0.1' >> inventory/local_site_specific_vars.yml
14+
15+
# Don't use the GEO API for the Stratum 1, since we do not have a key here.
16+
export CVMFS_GEO_DB_FILE=NONE
17+
18+
# Only test the cvmfs-config repo on the Stratum 1, as the other ones may be very large.
19+
if [ $playbook == "stratum1.yml" ]
20+
then
21+
echo 'cvmfs_repositories: "[{{ eessi_cvmfs_config_repo.repository }}]"' >> inventory/local_site_specific_vars.yml
22+
fi
23+
24+
# Install the Ansible dependencies.
25+
ansible-galaxy role install -r requirements.yml -p ./roles
26+
27+
# Print our site-specific configuration file, for debugging purposes.
28+
cat inventory/local_site_specific_vars.yml
29+
30+
# Run the playbook!
31+
ansible-playbook --connection=local -e @inventory/local_site_specific_vars.yml -v ${playbook}

.github/workflows/test-playbooks.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Test Ansible Playbooks
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths-ignore:
8+
- "**.md"
9+
- "**.example"
10+
pull_request:
11+
branches:
12+
- master
13+
paths-ignore:
14+
- "**.md"
15+
- "**.example"
16+
17+
jobs:
18+
test-playbook:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
component: [stratum0, stratum1, localproxy, client]
24+
os: [centos-7, centos-8, ubuntu-18.04, ubuntu-20.04]
25+
steps:
26+
- uses: actions/checkout@v2
27+
- name: Make temporary directory for /srv
28+
run: mkdir ${GITHUB_WORKSPACE}/srv
29+
- name: Build the Docker image
30+
run: docker build . --file ./.github/workflows/Dockerfile-${{ matrix.os }} --tag "docker.pkg.github.com/$(echo $GITHUB_REPOSITORY | tr '[A-Z]' '[a-z]')/${{ matrix.os }}"
31+
- name: Run the container
32+
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 }}
33+
- name: Execute the playbook
34+
run: docker exec ${{ matrix.component }}-${{ matrix.os }} /test-playbook.sh ${{ matrix.component }}.yml
35+
- name: Execute additional playbook for Stratum 0
36+
run: docker exec ${{ matrix.component }}-${{ matrix.os }} /test-playbook.sh ${{ matrix.component }}-deploy-cvmfs-config.yml
37+
if: ${{ matrix.component == 'stratum0' }}
38+
- name: Stop the container
39+
run: docker kill ${{ matrix.component }}-${{ matrix.os }}

inventory/group_vars/cvmfsclients

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# List of proxies to be used for the clients.
44
# Override this setting in your local_site_specific_vars.yml file.
5-
cvmfs_http_proxies: "{{ local_cvmfs_http_proxies }}"
5+
cvmfs_http_proxies: "{{ local_cvmfs_http_proxies | default(['DIRECT']) }}"
66

77
# Use the CVMFS configuration repository for the clients.
88
eessi_cvmfs_repos_enabled: config-repo

requirements.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
roles:
55

66
- name: galaxyproject.cvmfs
7-
version: 0.2.10
7+
version: 0.2.13
88

99
- name: geerlingguy.repo-epel
1010
version: 1.3.0

stratum0.yml

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
---
33
- name: CVMFS Stratum 0
44
hosts: cvmfsstratum0servers
5+
pre_tasks:
6+
- name: Fix that adds additional dependencies for Debian systems
7+
set_fact:
8+
cvmfs_packages:
9+
stratum0:
10+
- apache2
11+
- cvmfs-server
12+
- cvmfs-config-default
13+
- cvmfs
14+
when: ansible_facts['os_family'] == 'Debian'
515
roles:
616
- role: geerlingguy.repo-epel
717
when: ansible_facts['os_family'] == 'RedHat'

stratum1.yml

+21
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22
---
33
- name: CVMFS Stratum 1
44
hosts: cvmfsstratum1servers
5+
pre_tasks:
6+
- name: Fix that adds additional dependencies for Debian systems
7+
set_fact:
8+
cvmfs_packages:
9+
stratum1:
10+
- apache2
11+
- libapache2-mod-wsgi
12+
- squid
13+
- cvmfs-server
14+
- cvmfs-config-default
15+
when: ansible_facts['os_family'] == 'Debian'
16+
- name: Fix for CentOS 8
17+
set_fact:
18+
cvmfs_packages:
19+
stratum1:
20+
- httpd
21+
- python3-mod_wsgi
22+
- squid
23+
- cvmfs-server
24+
- cvmfs-config-default
25+
when: ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '8'
526
roles:
627
- role: geerlingguy.repo-epel
728
when: ansible_facts['os_family'] == 'RedHat'

0 commit comments

Comments
 (0)