Skip to content

Commit 084f09a

Browse files
author
Sergei Antipov
committed
Merge branch 'ubuntu_1204_fix_travis_builds'
2 parents 0ea31ad + 0e7e738 commit 084f09a

File tree

3 files changed

+84
-19
lines changed

3 files changed

+84
-19
lines changed

.travis.yml

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,16 @@ env:
1717
MONGODB_VERSION=2.6
1818
- >
1919
DISTRIBUTION=ubuntu-upstart
20-
DIST_VERSION=12.04
20+
DIST_VERSION=12.04-builded
2121
MONGODB_VERSION=3.2
2222
- >
2323
DISTRIBUTION=ubuntu-upstart
24-
DIST_VERSION=12.04
24+
DIST_VERSION=12.04-builded
2525
MONGODB_VERSION=3.0
2626
- >
2727
DISTRIBUTION=ubuntu-upstart
28-
DIST_VERSION=12.04
28+
DIST_VERSION=12.04-builded
2929
MONGODB_VERSION=2.6
30-
# - >
31-
# distribution=ubuntu-upstart
32-
# version=12.04
33-
# - >
34-
# distribution=debian
35-
# version=7
3630
3731
services:
3832
- docker
@@ -44,17 +38,22 @@ before_install:
4438
- sudo apt-get update
4539
- sudo apt-get install ansible python-pip -y
4640
- sudo pip install docker-py==1.5.0
47-
# Pull docker image
48-
- sudo docker pull ${DISTRIBUTION}:${DIST_VERSION}
41+
# Pull docker image or build it
42+
- >
43+
if [ -f tests/Dockerfile.${DISTRIBUTION}_${DIST_VERSION} ]; then
44+
sudo docker build --rm=true --file=tests/Dockerfile.${DISTRIBUTION}_${DIST_VERSION}
45+
--tag ${DISTRIBUTION}:${DIST_VERSION} tests; else sudo docker pull ${DISTRIBUTION}:${DIST_VERSION}; fi
4946
- sudo ln -s ${PWD} /etc/ansible/roles/greendayonfire.mongodb
5047

5148
script:
5249
# Test 1
53-
- sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION}
50+
- >
51+
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION}
52+
-e image_name=${DISTRIBUTION}:${DIST_VERSION}
5453
# Idempotence test
5554
- >
5655
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e mongodb_version=${MONGODB_VERSION}
57-
| grep -q 'changed=0.*failed=0'
56+
-e image_name=${DISTRIBUTION}:${DIST_VERSION} | grep -q 'changed=0.*failed=0'
5857
&& (echo 'Idempotence test: pass' && exit 0)
5958
|| (echo 'Idempotence test: fail' && exit 1)
6059
@@ -63,11 +62,11 @@ script:
6362

6463
# Test 2
6564
- >
66-
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1
65+
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e image_name=${DISTRIBUTION}:${DIST_VERSION}
6766
-e mongodb_version=${MONGODB_VERSION} -e mongodb_security_authorization='enabled'
6867
# Idempotence test
6968
- >
70-
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1
69+
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo1 -e image_name=${DISTRIBUTION}:${DIST_VERSION}
7170
-e mongodb_version=${MONGODB_VERSION} -e mongodb_security_authorization='enabled'
7271
| grep -q 'changed=0.*failed=0'
7372
&& (echo 'Idempotence test: pass' && exit 0)
@@ -78,11 +77,11 @@ script:
7877

7978
# Test 3
8079
- >
81-
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo
80+
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION}
8281
-e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs'
8382
# Idempotence test
8483
- >
85-
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo
84+
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION}
8685
-e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs'
8786
| grep -q 'changed=0.*failed=0'
8887
&& (echo 'Idempotence test: pass' && exit 0)
@@ -93,12 +92,12 @@ script:
9392

9493
# Test 4
9594
- >
96-
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo
95+
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION}
9796
-e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs'
9897
-e mongodb_security_authorization='enabled'
9998
# Idempotence test
10099
- >
101-
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo
100+
sudo ansible-playbook -i tests/hosts tests/site.yml -e target=mongo -e image_name=${DISTRIBUTION}:${DIST_VERSION}
102101
-e mongodb_version=${MONGODB_VERSION} -e mongodb_replication_replset='testrs'
103102
-e mongodb_security_authorization='enabled'
104103
| grep -q 'changed=0.*failed=0'
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM ubuntu:12.04
2+
3+
# much of this was gleaned from https://github.com/lxc/lxc/blob/lxc-0.8.0/templates/lxc-ubuntu.in
4+
# and then heavily modified and hacked like crazy
5+
6+
# we're going to want this bad boy installed so we can connect :)
7+
RUN apt-get update && apt-get install -y ssh python
8+
9+
ADD builds/init-fake.conf /etc/init/fake-container-events.conf
10+
11+
# undo some leet hax of the base image
12+
RUN rm /usr/sbin/policy-rc.d; \
13+
rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl
14+
15+
# generate a nice UTF-8 locale for our use
16+
RUN locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8
17+
18+
# remove some pointless services
19+
RUN /usr/sbin/update-rc.d -f ondemand remove; \
20+
for f in \
21+
/etc/init/u*.conf \
22+
/etc/init/mounted-dev.conf \
23+
/etc/init/mounted-proc.conf \
24+
/etc/init/mounted-run.conf \
25+
/etc/init/mounted-tmp.conf \
26+
/etc/init/mounted-var.conf \
27+
/etc/init/hostname.conf \
28+
/etc/init/networking.conf \
29+
/etc/init/tty*.conf \
30+
/etc/init/plymouth*.conf \
31+
/etc/init/hwclock*.conf \
32+
/etc/init/module*.conf\
33+
; do \
34+
dpkg-divert --local --rename --add "$f"; \
35+
done; \
36+
echo '# /lib/init/fstab: cleared out for bare-bones Docker' > /lib/init/fstab
37+
38+
# small fix for SSH in 13.10 (that's harmless everywhere else)
39+
RUN sed -ri 's/^session\s+required\s+pam_loginuid.so$/session optional pam_loginuid.so/' /etc/pam.d/sshd
40+
41+
RUN sed -ri 's/^PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config
42+
43+
# let Upstart know it's in a container
44+
ENV container docker
45+
46+
# set a cheap, simple password for great convenience
47+
RUN echo 'root:docker.io' | chpasswd
48+
49+
# we can has SSH
50+
EXPOSE 22
51+
52+
# pepare for takeoff
53+
CMD ["/sbin/init"]

tests/builds/init-fake.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# fake some events needed for correct startup other services
2+
3+
description "In-Container Upstart Fake Events"
4+
5+
start on startup
6+
7+
script
8+
rm -rf /var/run/*.pid
9+
rm -rf /var/run/network/*
10+
/sbin/initctl emit stopped JOB=udevtrigger --no-wait
11+
/sbin/initctl emit started JOB=udev --no-wait
12+
/sbin/initctl emit runlevel RUNLEVEL=3 --no-wait
13+
end script

0 commit comments

Comments
 (0)