-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for ubuntu 20.04 and debian 10
- Loading branch information
Showing
5 changed files
with
267 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |