From 9f208d1be432c978d4e23ebfc1f27395c1737732 Mon Sep 17 00:00:00 2001 From: Sergei Antipov Date: Mon, 9 May 2016 14:52:43 +0600 Subject: [PATCH 1/2] Build Ubuntu 12.04 image insteed of pull it --- .travis.yml | 11 ++-- tests/Dockerfile.ubuntu-upstart_12.04-builded | 53 +++++++++++++++++++ 2 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 tests/Dockerfile.ubuntu-upstart_12.04-builded diff --git a/.travis.yml b/.travis.yml index 50b825c2..3624fb3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,13 +44,18 @@ before_install: - sudo apt-get update - sudo apt-get install ansible python-pip -y - sudo pip install docker-py==1.5.0 - # Pull docker image - - sudo docker pull ${DISTRIBUTION}:${DIST_VERSION} + # Pull docker image or build it + - > + if [ -f tests/Dockerfile.${DISTRIBUTION}_${DIST_VERSION} ]; then + sudo docker build --rm=true --file=tests/Dockerfile.${DISTRIBUTION}_${DIST_VERSION} + --tag ${DISTRIBUTION}:${DIST_VERSION} tests; else sudo docker pull ${DISTRIBUTION}:${DIST_VERSION}; fi - sudo ln -s ${PWD} /etc/ansible/roles/greendayonfire.mongodb script: # Test 1 - - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} + - > + sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} + -e image_name=${DISTRIBUTION}:${DIST_VERSION} # Idempotence test - > sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} diff --git a/tests/Dockerfile.ubuntu-upstart_12.04-builded b/tests/Dockerfile.ubuntu-upstart_12.04-builded new file mode 100644 index 00000000..3a00748e --- /dev/null +++ b/tests/Dockerfile.ubuntu-upstart_12.04-builded @@ -0,0 +1,53 @@ +FROM ubuntu:12.04 + +# much of this was gleaned from https://github.com/lxc/lxc/blob/lxc-0.8.0/templates/lxc-ubuntu.in +# and then heavily modified and hacked like crazy + +# we're going to want this bad boy installed so we can connect :) +RUN apt-get update && apt-get install -y ssh python + +ADD init-fake.conf /etc/init/fake-container-events.conf + +# undo some leet hax of the base image +RUN rm /usr/sbin/policy-rc.d; \ + rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl + +# generate a nice UTF-8 locale for our use +RUN locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8 + +# remove some pointless services +RUN /usr/sbin/update-rc.d -f ondemand remove; \ + for f in \ + /etc/init/u*.conf \ + /etc/init/mounted-dev.conf \ + /etc/init/mounted-proc.conf \ + /etc/init/mounted-run.conf \ + /etc/init/mounted-tmp.conf \ + /etc/init/mounted-var.conf \ + /etc/init/hostname.conf \ + /etc/init/networking.conf \ + /etc/init/tty*.conf \ + /etc/init/plymouth*.conf \ + /etc/init/hwclock*.conf \ + /etc/init/module*.conf\ + ; do \ + dpkg-divert --local --rename --add "$f"; \ + done; \ + echo '# /lib/init/fstab: cleared out for bare-bones Docker' > /lib/init/fstab + +# small fix for SSH in 13.10 (that's harmless everywhere else) +RUN sed -ri 's/^session\s+required\s+pam_loginuid.so$/session optional pam_loginuid.so/' /etc/pam.d/sshd + +RUN sed -ri 's/^PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config + +# let Upstart know it's in a container +ENV container docker + +# set a cheap, simple password for great convenience +RUN echo 'root:docker.io' | chpasswd + +# we can has SSH +EXPOSE 22 + +# pepare for takeoff +CMD ["/sbin/init"] \ No newline at end of file From 0e7e73871d3a77abcfe247ae54f755c95d46a58d Mon Sep 17 00:00:00 2001 From: Sergei Antipov Date: Mon, 9 May 2016 15:57:26 +0600 Subject: [PATCH 2/2] Fixed problem with testing for 12.04 version --- .travis.yml | 26 +++++++------------ tests/Dockerfile.ubuntu-upstart_12.04-builded | 2 +- tests/builds/init-fake.conf | 13 ++++++++++ 3 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 tests/builds/init-fake.conf diff --git a/.travis.yml b/.travis.yml index 3624fb3c..99068511 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,22 +17,16 @@ env: MONGODB_VERSION=2.6 - > DISTRIBUTION=ubuntu-upstart - DIST_VERSION=12.04 + DIST_VERSION=12.04-builded MONGODB_VERSION=3.2 - > DISTRIBUTION=ubuntu-upstart - DIST_VERSION=12.04 + DIST_VERSION=12.04-builded MONGODB_VERSION=3.0 - > DISTRIBUTION=ubuntu-upstart - DIST_VERSION=12.04 + DIST_VERSION=12.04-builded MONGODB_VERSION=2.6 -# - > -# distribution=ubuntu-upstart -# version=12.04 -# - > -# distribution=debian -# version=7 services: - docker @@ -59,7 +53,7 @@ script: # Idempotence test - > sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION} - | grep -q 'changed=0.*failed=0' + -e image_name=${DISTRIBUTION}:${DIST_VERSION} | grep -q 'changed=0.*failed=0' && (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1) @@ -68,11 +62,11 @@ script: # Test 2 - > - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 + sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_version=${MONGODB_VERSION} -e mongodb_security_authorization='enabled' # Idempotence test - > - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 + sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_version=${MONGODB_VERSION} -e mongodb_security_authorization='enabled' | grep -q 'changed=0.*failed=0' && (echo 'Idempotence test: pass' && exit 0) @@ -83,11 +77,11 @@ script: # Test 3 - > - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo + sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' # Idempotence test - > - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo + sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' | grep -q 'changed=0.*failed=0' && (echo 'Idempotence test: pass' && exit 0) @@ -98,12 +92,12 @@ script: # Test 4 - > - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo + sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' -e mongodb_security_authorization='enabled' # Idempotence test - > - sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo + sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION} -e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs' -e mongodb_security_authorization='enabled' | grep -q 'changed=0.*failed=0' diff --git a/tests/Dockerfile.ubuntu-upstart_12.04-builded b/tests/Dockerfile.ubuntu-upstart_12.04-builded index 3a00748e..78465dcb 100644 --- a/tests/Dockerfile.ubuntu-upstart_12.04-builded +++ b/tests/Dockerfile.ubuntu-upstart_12.04-builded @@ -6,7 +6,7 @@ FROM ubuntu:12.04 # we're going to want this bad boy installed so we can connect :) RUN apt-get update && apt-get install -y ssh python -ADD init-fake.conf /etc/init/fake-container-events.conf +ADD builds/init-fake.conf /etc/init/fake-container-events.conf # undo some leet hax of the base image RUN rm /usr/sbin/policy-rc.d; \ diff --git a/tests/builds/init-fake.conf b/tests/builds/init-fake.conf new file mode 100644 index 00000000..1b2b7458 --- /dev/null +++ b/tests/builds/init-fake.conf @@ -0,0 +1,13 @@ +# fake some events needed for correct startup other services + +description "In-Container Upstart Fake Events" + +start on startup + +script + rm -rf /var/run/*.pid + rm -rf /var/run/network/* + /sbin/initctl emit stopped JOB=udevtrigger --no-wait + /sbin/initctl emit started JOB=udev --no-wait + /sbin/initctl emit runlevel RUNLEVEL=3 --no-wait +end script \ No newline at end of file