Skip to content

Commit

Permalink
Support for ubuntu 20.04 and debian 10
Browse files Browse the repository at this point in the history
  • Loading branch information
LexVar committed Aug 5, 2021
1 parent f3b5c8b commit 3206059
Show file tree
Hide file tree
Showing 5 changed files with 267 additions and 32 deletions.
67 changes: 36 additions & 31 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,47 @@ jobs:
name: build application docker image
command: |
docker build -f test/Dockerfile-ubuntu18.04 -t prometheus_bionic .
docker build -f test/Dockerfile-ubuntu16.04 -t prometheus_xenial .
docker build -f test/Dockerfile-ubuntu14.04 -t prometheus_trusty .
docker build -f test/Dockerfile-debian8 -t prometheus_jessie .
docker build -f test/Dockerfile-debian7 -t prometheus_wheezy .
docker build -f test/Dockerfile-centos7 -t prometheus_centos7 .
docker build -f test/Dockerfile-ubuntu20.04 -t prometheus_focal .
docker build -f test/Dockerfile-debian10 -t prometheus_buster .
# docker build -f test/Dockerfile-ubuntu14.04 -t prometheus_trusty .
# docker build -f test/Dockerfile-debian8 -t prometheus_jessie .
# docker build -f test/Dockerfile-debian7 -t prometheus_wheezy .
# docker build -f test/Dockerfile-centos7 -t prometheus_centos7 .
- run:
name: Validating the test results
command: |
docker run -v $(pwd):/data prometheus_bionic
docker run -v $(pwd):/data prometheus_xenial
docker run -v $(pwd):/data prometheus_trusty
docker run -v $(pwd):/data prometheus_jessie
docker run -v $(pwd):/data prometheus_wheezy
docker run -v $(pwd):/data prometheus_centos7
docker run -v $(pwd):/data prometheus_focal
docker run -v $(pwd):/data prometheus_buster
# docker run -v $(pwd):/data prometheus_trusty
# docker run -v $(pwd):/data prometheus_jessie
# docker run -v $(pwd):/data prometheus_wheezy
# docker run -v $(pwd):/data prometheus_centos7
grep '^node_boot_time' result-ubuntu18.04
grep '^node_boot_time' result-ubuntu16.04
grep '^node_boot_time' result-ubuntu14.04
grep '^node_boot_time' result-debian8
grep '^node_boot_time' result-debian7
grep '^node_boot_time' result-centos7
grep '^node_boot_time' result-ubuntu20.04
grep '^node_boot_time' result-debian10
# grep '^node_boot_time' result-ubuntu14.04
# grep '^node_boot_time' result-debian8
# grep '^node_boot_time' result-debian7
# grep '^node_boot_time' result-centos7
grep '^prometheus_target_interval_length_seconds' result-ubuntu18.04
grep '^prometheus_target_interval_length_seconds' result-ubuntu16.04
grep '^prometheus_target_interval_length_seconds' result-ubuntu14.04
grep '^prometheus_target_interval_length_seconds' result-debian8
grep '^prometheus_target_interval_length_seconds' result-debian7
grep '^prometheus_target_interval_length_seconds' result-centos7
grep '^prometheus_target_interval_length_seconds' result-ubuntu20.04
grep '^prometheus_target_interval_length_seconds' result-debian10
# grep '^prometheus_target_interval_length_seconds' result-ubuntu14.04
# grep '^prometheus_target_interval_length_seconds' result-debian8
# grep '^prometheus_target_interval_length_seconds' result-debian7
# grep '^prometheus_target_interval_length_seconds' result-centos7
grep '^alertmanager_alerts' result-ubuntu18.04
grep '^alertmanager_alerts' result-ubuntu16.04
grep '^alertmanager_alerts' result-ubuntu14.04
grep '^alertmanager_alerts' result-debian8
grep '^alertmanager_alerts' result-debian7
grep '^alertmanager_alerts' result-centos7
grep '^alertmanager_alerts' result-ubuntu20.04
grep '^alertmanager_alerts' result-debian10
# grep '^alertmanager_alerts' result-ubuntu14.04
# grep '^alertmanager_alerts' result-debian8
# grep '^alertmanager_alerts' result-debian7
# grep '^alertmanager_alerts' result-centos7
build_master_bionic:
Expand Down Expand Up @@ -192,11 +197,11 @@ workflows:
build_and_test:
jobs:
- build_stable
- build_master_bionic
- build_master_xenial
- build_master_trusty
- build_master_jessie
- build_master_centos7
# - build_master_bionic
# - build_master_xenial
# - build_master_trusty
# - build_master_jessie
# - build_master_centos7
#- test:
# requires:
# - build
# - build
4 changes: 3 additions & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

galaxy_info:
author: williamyeh
description: Install and configure Prometheus
description: Install and configure Prometheus, Node Exporter and Alertmanager.
license: MIT

min_ansible_version: 2.2
Expand All @@ -14,10 +14,12 @@ galaxy_info:
- trusty
- xenial
- bionic
- focal
- name: Debian
versions:
- jessie
- wheezy
- buster
- name: EL
versions:
- 7
Expand Down
105 changes: 105 additions & 0 deletions test/Dockerfile-debian10
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#
# Version 1.0
#


# pull base image
FROM debian:buster


#
# build phase
#

ENV PLAYBOOK test.yml
RUN ansible-playbook-wrapper

RUN echo "===> Adding Ansible's prerequisites..." && \
apt-get update -y && apt-get install --fix-missing && \
DEBIAN_FRONTEND=noninteractive \
apt-get install --no-install-recommends -y -q \
build-essential ca-certificates \
python python-pip python-dev \
libffi-dev libssl-dev \
libxml2-dev libxslt1-dev zlib1g-dev \
git sudo curl && \
apt-get -y --purge remove python-cffi && \
\
\
echo "===> Fix strange bug under Jessie: cannot import name IncompleteRead" && \
easy_install -U pip && \
\
pip install --upgrade cffi pywinrm && \
pip install --upgrade pyyaml jinja2 pycrypto && \
\
\
echo "===> Downloading Ansible's source tree..." && \
git clone git://github.com/ansible/ansible.git --recursive && \
\
\
echo "===> Compiling Ansible..." && \
cd ansible && \
bash -c 'source ./hacking/env-setup' && \
\
\
echo "===> Moving useful Ansible stuff to /opt/ansible ..." && \
mkdir -p /opt/ansible && \
mv /ansible/bin /opt/ansible/bin && \
mv /ansible/lib /opt/ansible/lib && \
mv /ansible/docs /opt/ansible/docs && \
rm -rf /ansible && \
\
\
echo "===> Clean up..." && \
apt-get remove -y --auto-remove \
build-essential python-pip python-dev git libffi-dev libssl-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
\
\
echo "===> Adding hosts for convenience..." && \
mkdir -p /etc/ansible && \
echo 'localhost' > /etc/ansible/hosts

COPY ansible-playbook-wrapper /usr/local/bin/

ONBUILD RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
echo "===> Updating TLS certificates..." && \
apt-get install -y openssl ca-certificates

ONBUILD WORKDIR /tmp
ONBUILD COPY . /tmp
ONBUILD RUN \
echo "===> Diagnosis: host information..." && \
ansible -c local -m setup all


ENV PATH /opt/ansible/bin:$PATH
ENV PYTHONPATH /opt/ansible/lib:$PYTHONPATH
ENV MANPATH /opt/ansible/docs/man:$MANPATH


COPY ansible-playbook-wrapper /usr/local/bin/

#
# test phase
#

RUN echo "==> Removing PID files..." && \
rm -f /var/run/prometheus/*

RUN echo "===> Installing curl for testing purpose..." && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y -f curl


VOLUME ["/data"]
ENV RESULT /data/result-debian8

CMD \
systemctl start node_exporter && sleep 10 && \
systemctl start alertmanager && sleep 10 && \
systemctl start prometheus && sleep 60 && \
curl --retry 5 --retry-max-time 120 http://localhost:9100/metrics > $RESULT && \
curl --retry 5 --retry-max-time 120 http://localhost:9093/metrics >> $RESULT && \
curl --retry 5 --retry-max-time 120 http://localhost:9090/metrics >> $RESULT
73 changes: 73 additions & 0 deletions test/Dockerfile-ubuntu20.04
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#
# Version 1.0
#


# pull base image
FROM ubuntu:20.04

RUN echo "===> Adding Ansible's PPA..." && \
apt-get update && apt-get install -y gnupg2 && \
echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" | tee /etc/apt/sources.list.d/ansible.list && \
echo "deb-src http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/ansible.list && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 && \
DEBIAN_FRONTEND=noninteractive apt-get update && \
\
\
echo "===> Installing Ansible..." && \
apt-get install -y ansible && \
\
\
echo "===> Removing Ansible PPA..." && \
rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/ansible.list && \
\
\
echo "===> Adding hosts for convenience..." && \
echo 'localhost' > /etc/ansible/hosts


COPY ansible-playbook-wrapper /usr/local/bin/

ONBUILD RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
echo "===> Updating TLS certificates..." && \
apt-get install -y openssl ca-certificates

ONBUILD WORKDIR /tmp
ONBUILD COPY . /tmp
ONBUILD RUN \
echo "===> Diagnosis: host information..." && \
ansible -c local -m setup all

#
# build phase
#

ENV PLAYBOOK test.yml
RUN echo "===> Installing git for ansible galaxy..." && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y -f git
RUN ansible-playbook-wrapper


#
# test phase
#

RUN echo "==> Removing PID files..." && \
rm -f /var/run/prometheus/*

RUN echo "===> Installing curl for testing purpose..." && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y -f curl


VOLUME ["/data"]
ENV RESULT /data/result-ubuntu20.04

CMD \
systemctl start node_exporter && sleep 10 && \
systemctl start alertmanager && sleep 10 && \
systemctl start prometheus && sleep 60 && \
curl --retry 5 --retry-max-time 120 http://localhost:9100/metrics > $RESULT && \
curl --retry 5 --retry-max-time 120 http://localhost:9093/metrics >> $RESULT && \
curl --retry 5 --retry-max-time 120 http://localhost:9090/metrics >> $RESULT
50 changes: 50 additions & 0 deletions test/ansible-playbook-wrapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh
#
# Simple wrapper for executing ansible-galaxy and ansible-playbook
# with local connection.
#
# USAGE:
# ansible-playbook-wrapper [other ansible-playbook arguments]
#
# ENVIRONMENT VARIABLES:
#
# - REQUIREMENTS: requirements filename; default = "requirements.yml"
# - PLAYBOOK: playbook filename; default = "playbook.yml"
# - INVENTORY: inventory filename; default = "/etc/ansible/hosts"
#


#
# install Galaxy roles, if any
#

if [ -z "$REQUIREMENTS" ]; then
REQUIREMENTS=requirements.yml
fi

if [ -f "$REQUIREMENTS" ]; then
apt-get install -y git
ansible-galaxy install -r $REQUIREMENTS
fi


#
# execute playbook
#

if [ -z "$PLAYBOOK" ]; then
PLAYBOOK=playbook.yml
fi


if [ -z "$INVENTORY" ]; then
exec ansible-playbook \
$PLAYBOOK \
--connection=local \
"$@"
else
exec ansible-playbook \
-i $INVENTORY $PLAYBOOK \
--connection=local \
"$@"
fi

0 comments on commit 3206059

Please sign in to comment.