如何使用Travis-CI在CentOS 7上运行测试?

时间:2015-09-12 04:36:35

标签: docker travis-ci

我尝试使用Travis-CI to test my ansible playbooks on CentOS 7

我收到了一个错误: error: unpacking of archive failed on file /usr/sbin/suexec: cpio: cap_set_file.

我也安装了docker:

curl -sSL https://get.docker.com/ | sh

在我的Ubuntu上:

# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.3 LTS
Release:        14.04
Codename:       trusty

但是有这个错误:

#docker run --rm=true -ti centos:7 /bin/bash
[root@08bf52d53465 /]#
[root@ca03cf7a13e2 /]# yum install httpd -y
Loaded plugins: fastestmirror
base                                                                                                  | 3.6 kB  00:00:00
extras                                                                                                | 3.4 kB  00:00:00
updates                                                                                               | 3.4 kB  00:00:00
(1/4): extras/7/x86_64/primary_db                                                                     |  74 kB  00:00:00
(2/4): base/7/x86_64/group_gz                                                                         | 154 kB  00:00:01
(3/4): updates/7/x86_64/primary_db                                                                    | 3.3 MB  00:00:06
(4/4): base/7/x86_64/primary_db                                                                       | 5.1 MB  00:00:06
Determining fastest mirrors
 * base: mirror.nonstop.co.il
 * extras: centos.joinweb.co.il
 * updates: centos.joinweb.co.il
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-31.el7.centos.1 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-31.el7.centos.1 for package: httpd-2.4.6-31.el7.centos.1.x86_64
--> Processing Dependency: system-logos >= 7.92.1-1 for package: httpd-2.4.6-31.el7.centos.1.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-31.el7.centos.1.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-31.el7.centos.1.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-31.el7.centos.1.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package centos-logos.noarch 0:70.0.6-2.el7.centos will be installed
---> Package httpd-tools.x86_64 0:2.4.6-31.el7.centos.1 will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================
 Package                       Arch                    Version                                Repository                Size
=============================================================================================================================
Installing:
 httpd                         x86_64                  2.4.6-31.el7.centos.1                  updates                  2.7 M
Installing for dependencies:
 apr                           x86_64                  1.4.8-3.el7                            base                     103 k
 apr-util                      x86_64                  1.5.2-6.el7                            base                      92 k
 centos-logos                  noarch                  70.0.6-2.el7.centos                    updates                   21 M
 httpd-tools                   x86_64                  2.4.6-31.el7.centos.1                  updates                   79 k
 mailcap                       noarch                  2.1.41-2.el7                           base                      31 k

Transaction Summary
=============================================================================================================================
Install  1 Package (+5 Dependent packages)

Total download size: 24 M
Installed size: 32 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/apr-1.4.8-3.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for apr-1.4.8-3.el7.x86_64.rpm is not installed
(1/6): apr-1.4.8-3.el7.x86_64.rpm                                                                     | 103 kB  00:00:00
(2/6): mailcap-2.1.41-2.el7.noarch.rpm                                                                |  31 kB  00:00:00
(3/6): apr-util-1.5.2-6.el7.x86_64.rpm                                                                |  92 kB  00:00:00
Public key for httpd-tools-2.4.6-31.el7.centos.1.x86_64.rpm is not installed               ] 559 kB/s | 764 kB  00:00:43 ETA
(4/6): httpd-tools-2.4.6-31.el7.centos.1.x86_64.rpm                                                   |  79 kB  00:00:01
(5/6): httpd-2.4.6-31.el7.centos.1.x86_64.rpm                                                         | 2.7 MB  00:00:03
(6/6): centos-logos-70.0.6-2.el7.centos.noarch.rpm                                                    |  21 MB  00:00:16
-----------------------------------------------------------------------------------------------------------------------------
Total                                                                                        1.5 MB/s |  24 MB  00:00:16
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-1.1503.el7.centos.2.8.x86_64 (@CentOS)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-3.el7.x86_64                                                                                    1/6
  Installing : apr-util-1.5.2-6.el7.x86_64                                                                               2/6
  Installing : httpd-tools-2.4.6-31.el7.centos.1.x86_64                                                                  3/6
  Installing : mailcap-2.1.41-2.el7.noarch                                                                               4/6
  Installing : centos-logos-70.0.6-2.el7.centos.noarch                                                                   5/6
  Installing : httpd-2.4.6-31.el7.centos.1.x86_64                                                                        6/6
Error unpacking rpm package httpd-2.4.6-31.el7.centos.1.x86_64
error: unpacking of archive failed on file /usr/sbin/suexec: cpio: cap_set_file
error: httpd-2.4.6-31.el7.centos.1.x86_64: install failed
  Verifying  : centos-logos-70.0.6-2.el7.centos.noarch                                                                   1/6
  Verifying  : apr-1.4.8-3.el7.x86_64                                                                                    2/6
  Verifying  : mailcap-2.1.41-2.el7.noarch                                                                               3/6
  Verifying  : apr-util-1.5.2-6.el7.x86_64                                                                               4/6
  Verifying  : httpd-tools-2.4.6-31.el7.centos.1.x86_64                                                                  5/6
  Verifying  : httpd-2.4.6-31.el7.centos.1.x86_64                                                                        6/6

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7                      apr-util.x86_64 0:1.5.2-6.el7    centos-logos.noarch 0:70.0.6-2.el7.centos
  httpd-tools.x86_64 0:2.4.6-31.el7.centos.1    mailcap.noarch 0:2.1.41-2.el7

Failed:
  httpd.x86_64 0:2.4.6-31.el7.centos.1

Complete!
[root@ca03cf7a13e2 /]#

我创建了包含Ansible https://github.com/weldpua2008/docker-ansible/blob/ansible_1.9.2/centos/7/Dockerfile

的“特殊”泊坞窗图片

是否有可能在CentOS 7上运行ansible playbook的测试?

所以我用:

更新了/ etc / default / docker
DOCKER_OPTS="-s devicemapper"

重启码头:     服务码头重启

docker run --rm = true -ti centos:7 / bin / bash

[root@16702cbf3f2c /]# yum install -y httpd
Loaded plugins: fastestmirror
base                                                                                                  | 3.6 kB  00:00:00
extras                                                                                                | 3.4 kB  00:00:00
systemdcontainer                                                                                      | 1.9 kB  00:00:00
updates                                                                                               | 3.4 kB  00:00:00
(1/4): base/7/x86_64/group_gz                                                                         | 154 kB  00:00:03
(2/4): extras/7/x86_64/primary_db                                                                     |  74 kB  00:00:04
(3/4): updates/7/x86_64/primary_db                                                                    | 3.3 MB  00:01:10
(4/4): base/7/x86_64/primary_db                                                                       | 5.1 MB  00:01:22
systemdcontainer/primary_db                                                                           |  20 kB  00:00:01
Determining fastest mirrors
 * base: centos.syn.co.il
 * extras: centos.syn.co.il
 * updates: centos.syn.co.il
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-31.el7.centos.1 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-31.el7.centos.1 for package: httpd-2.4.6-31.el7.centos.1.x86_64
--> Processing Dependency: system-logos >= 7.92.1-1 for package: httpd-2.4.6-31.el7.centos.1.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-31.el7.centos.1.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-31.el7.centos.1.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-31.el7.centos.1.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package centos-logos.noarch 0:70.0.6-2.el7.centos will be installed
---> Package httpd-tools.x86_64 0:2.4.6-31.el7.centos.1 will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================
 Package                       Arch                    Version                                Repository                Size
=============================================================================================================================
Installing:
 httpd                         x86_64                  2.4.6-31.el7.centos.1                  updates                  2.7 M
Installing for dependencies:
 apr                           x86_64                  1.4.8-3.el7                            base                     103 k
 apr-util                      x86_64                  1.5.2-6.el7                            base                      92 k
 centos-logos                  noarch                  70.0.6-2.el7.centos                    updates                   21 M
 httpd-tools                   x86_64                  2.4.6-31.el7.centos.1                  updates                   79 k
 mailcap                       noarch                  2.1.41-2.el7                           base                      31 k

Transaction Summary
=============================================================================================================================
Install  1 Package (+5 Dependent packages)

Total download size: 24 M
Installed size: 32 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/updates/packages/httpd-tools-2.4.6-31.el7.centos.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for httpd-tools-2.4.6-31.el7.centos.1.x86_64.rpm is not installed
(1/6): httpd-tools-2.4.6-31.el7.centos.1.x86_64.rpm                                                   |  79 kB  00:00:03
Public key for apr-util-1.5.2-6.el7.x86_64.rpm is not installed
(2/6): apr-util-1.5.2-6.el7.x86_64.rpm                                                                |  92 kB  00:00:04
(3/6): mailcap-2.1.41-2.el7.noarch.rpm                                                                |  31 kB  00:00:02
(4/6): apr-1.4.8-3.el7.x86_64.rpm                                                                     | 103 kB  00:00:06
(5/6): httpd-2.4.6-31.el7.centos.1.x86_64.rpm                                                         | 2.7 MB  00:00:52
(6/6): centos-logos-70.0.6-2.el7.centos.noarch.rpm                                                    |  21 MB  00:01:11
-----------------------------------------------------------------------------------------------------------------------------
Total                                                                                        349 kB/s |  24 MB  00:01:11
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-1.1503.el7.centos.2.8.x86_64 (@CentOS)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-3.el7.x86_64                                                                                    1/6
  Installing : apr-util-1.5.2-6.el7.x86_64                                                                               2/6
  Installing : httpd-tools-2.4.6-31.el7.centos.1.x86_64                                                                  3/6
  Installing : mailcap-2.1.41-2.el7.noarch                                                                               4/6
  Installing : centos-logos-70.0.6-2.el7.centos.noarch                                                                   5/6
  Installing : httpd-2.4.6-31.el7.centos.1.x86_64                                                                        6/6
  Verifying  : centos-logos-70.0.6-2.el7.centos.noarch                                                                   1/6
  Verifying  : apr-1.4.8-3.el7.x86_64                                                                                    2/6
  Verifying  : mailcap-2.1.41-2.el7.noarch                                                                               3/6
  Verifying  : apr-util-1.5.2-6.el7.x86_64                                                                               4/6
  Verifying  : httpd-tools-2.4.6-31.el7.centos.1.x86_64                                                                  5/6
  Verifying  : httpd-2.4.6-31.el7.centos.1.x86_64                                                                        6/6

Installed:
  httpd.x86_64 0:2.4.6-31.el7.centos.1

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7                      apr-util.x86_64 0:1.5.2-6.el7    centos-logos.noarch 0:70.0.6-2.el7.centos
  httpd-tools.x86_64 0:2.4.6-31.el7.centos.1    mailcap.noarch 0:2.1.41-2.el7

Complete!

如果有可能在Travis CI上做同样的事情。我没有在手册http://docs.travis-ci.com/user/docker/中找到。

我无法修改泊坞窗设置https://travis-ci.org/weldpua2008/ansible-apache/jobs/79963906#L29

$ echo 'DOCKER_OPTS="-s devicemapper"' >> /etc/default/docker; service docker restart
/home/travis/build.sh: line 41: /etc/default/docker: Permission denied
/etc/init.d/docker: 38: .: Can't open /etc/default/docker

3 个答案:

答案 0 :(得分:10)

由于Travis CI Docker的错误,有办法使用新版本的Docker。感谢Travis CI团队的Dominic Jodoin。 .travis.yml:

sudo: required
env:
  #matrix:
  - OS_TYPE=centos OS_VERSION=6 ANSIBLE_VERSION=1.9.2

branches:
  only:
  - master
#  - stable

services:
  - docker

before_install:
  - sudo apt-get update
  - sudo apt-get upgrade lxc-docker
  - echo 'DOCKER_OPTS="-H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock -s devicemapper"' | sudo tee /etc/default/docker > /dev/null
  - sudo service docker restart
  - sleep 5
  - sudo docker pull weldpua2008/docker-ansible:${OS_TYPE}${OS_VERSION}_v${ANSIBLE_VERSION}

script:
 # Run tests in Container
 - sudo docker run --rm=true -v `pwd`:/ansible-apache:rw weldpua2008/docker-ansible:${OS_TYPE}${OS_VERSION}_v${ANSIBLE_VERSION} /bin/bash -c "/ansible-apache/tests/test-in-docker-image.sh ${OS_TYPE} ${OS_VERSION} ${ANSIBLE_VERSION}"

notifications:
  email: false

答案 1 :(得分:0)

您可以考虑使用Circle CI。它与Travis CI(与github,yaml配置集成)非常相似,但速度更快。因为它是免费的开源!以下是有关docker的一些文档:

https://circleci.com/docs/docker/

答案 2 :(得分:0)

在Travis CI上使用CentOS的基本用法是这样的。

services: docker
...
install: docker build --rm -t sample -f Dockerfile_centos .
script: docker run --rm -t sample

您可以参考以下项目的案例。