|
|
@ -6,6 +6,7 @@ Build the Docker images used for testing.
|
|
|
|
|
|
|
|
|
|
|
|
import commands
|
|
|
|
import commands
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
|
|
|
|
import tempfile
|
|
|
|
import shlex
|
|
|
|
import shlex
|
|
|
|
import subprocess
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
|
|
@ -19,25 +20,36 @@ def sh(s, *args):
|
|
|
|
return shlex.split(s)
|
|
|
|
return shlex.split(s)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for base_image, name in [('debian:stretch', 'debian'),
|
|
|
|
|
|
|
|
('centos:6', 'centos6'),
|
|
|
|
label_by_id = {}
|
|
|
|
('centos:7', 'centos7')]:
|
|
|
|
|
|
|
|
args = sh('docker run --rm -it -d %s /bin/bash', base_image)
|
|
|
|
for base_image, label in [('debian:stretch', 'debian'),
|
|
|
|
|
|
|
|
('centos:6', 'centos6'),
|
|
|
|
|
|
|
|
('centos:7', 'centos7')]:
|
|
|
|
|
|
|
|
args = sh('docker run --rm -it -d -h mitogen-%s %s /bin/bash',
|
|
|
|
|
|
|
|
label, base_image)
|
|
|
|
container_id = subprocess.check_output(args).strip()
|
|
|
|
container_id = subprocess.check_output(args).strip()
|
|
|
|
|
|
|
|
label_by_id[container_id] = label
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with tempfile.NamedTemporaryFile() as fp:
|
|
|
|
|
|
|
|
fp.write('[all]\n')
|
|
|
|
|
|
|
|
for id_, label in label_by_id.items():
|
|
|
|
|
|
|
|
fp.write('%s ansible_host=%s\n' % (label, id_))
|
|
|
|
|
|
|
|
fp.flush()
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
subprocess.check_call(
|
|
|
|
subprocess.check_call(
|
|
|
|
cwd=BASEDIR,
|
|
|
|
cwd=BASEDIR,
|
|
|
|
args=sh('''
|
|
|
|
args=sh('ansible-playbook -i %s -c docker setup.yml', fp.name),
|
|
|
|
ansible-playbook -i %s, -c docker setup.yml -vvv
|
|
|
|
|
|
|
|
''', container_id)
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
subprocess.check_call(sh('''
|
|
|
|
for container_id, label in label_by_id.items():
|
|
|
|
docker commit
|
|
|
|
subprocess.check_call(sh('''
|
|
|
|
--change 'EXPOSE 22'
|
|
|
|
docker commit
|
|
|
|
--change 'CMD ["/usr/sbin/sshd", "-D"]'
|
|
|
|
--change 'EXPOSE 22'
|
|
|
|
%s
|
|
|
|
--change 'CMD ["/usr/sbin/sshd", "-D"]'
|
|
|
|
mitogen/%s-test
|
|
|
|
%s
|
|
|
|
''', container_id, name))
|
|
|
|
mitogen/%s-test
|
|
|
|
|
|
|
|
''', container_id, label))
|
|
|
|
finally:
|
|
|
|
finally:
|
|
|
|
subprocess.check_call(sh('docker rm -f %s', container_id))
|
|
|
|
subprocess.check_call(sh('docker rm -f %s', ' '.join(label_by_id)))
|
|
|
|