This repository was archived by the owner on Oct 27, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +122
-0
lines changed Expand file tree Collapse file tree 5 files changed +122
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ sudo : required
3+
4+ env :
5+ - distribution : centos
6+ version : 7
7+ init : /usr/lib/systemd/systemd
8+ run_opts : " --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
9+ - distribution : ubuntu
10+ version : 16.04
11+ init : /sbin/init
12+ run_opts : " "
13+ - distribution : ubuntu
14+ version : 14.04
15+ init : /sbin/init
16+ run_opts : " "
17+
18+ services :
19+ - docker
20+
21+ before_install :
22+ # - sudo apt-get update
23+ # Pull container
24+ - ' sudo docker pull ${distribution}:${version}'
25+ # Customize container
26+ - ' sudo docker build --rm=true --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests'
27+
28+ script :
29+ - container_id=$(mktemp)
30+ # Run container in detached state
31+ - ' sudo docker run --privileged --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${distribution}-${version}:ansible "${init}" > "${container_id}"'
32+
33+ # Ansible syntax check.
34+ - ' sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check'
35+
36+ # Test role.
37+ - ' sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml'
38+
39+ # Test role idempotence.
40+ - >
41+ sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml
42+ | grep -q 'changed=0.*failed=0'
43+ && (echo 'Idempotence test: pass' && exit 0)
44+ || (echo 'Idempotence test: fail' && exit 1)
45+ # Clean up
46+ - ' sudo docker stop "$(cat ${container_id})"'
47+
48+ notifications :
49+ webhooks : https://galaxy.ansible.com/api/v1/notifications/
Original file line number Diff line number Diff line change 1+ FROM centos:7
2+
3+ # Install systemd -- See https://hub.docker.com/_/centos/
4+ RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs
5+ RUN yum -y update; yum clean all; \
6+ (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
7+ rm -f /lib/systemd/system/multi-user.target.wants/*; \
8+ rm -f /etc/systemd/system/*.wants/*; \
9+ rm -f /lib/systemd/system/local-fs.target.wants/*; \
10+ rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
11+ rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
12+ rm -f /lib/systemd/system/basic.target.wants/*; \
13+ rm -f /lib/systemd/system/anaconda.target.wants/*;
14+
15+ # Install Ansible
16+ RUN yum -y install epel-release
17+ RUN yum -y install git ansible sudo
18+ RUN yum clean all
19+
20+ # Disable requiretty
21+ RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
22+
23+ # Install Ansible inventory file
24+ RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
25+
26+ VOLUME ["/sys/fs/cgroup"]
27+ CMD ["/usr/sbin/init"]
Original file line number Diff line number Diff line change 1+ FROM ubuntu:14.04
2+ RUN apt-get update
3+
4+ # Install Ansible
5+ RUN apt-get install -y software-properties-common git
6+ RUN apt-add-repository -y ppa:ansible/ansible
7+ RUN apt-get update
8+ RUN apt-get install -y ansible
9+
10+ # Install Ansible inventory file
11+ RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
Original file line number Diff line number Diff line change 1+ FROM ubuntu:16.04
2+ RUN apt-get update
3+
4+ # Install Ansible
5+ RUN apt-get install -y software-properties-common git
6+ RUN apt-add-repository -y ppa:ansible/ansible
7+ RUN apt-get update
8+ RUN apt-get install -y ansible
9+
10+ # Install Ansible inventory file
11+ RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
Original file line number Diff line number Diff line change 1+ - hosts : all
2+
3+ pre_tasks :
4+ - name : Ensure build dependencies are installed (RedHat).
5+ yum : ' name="{{ item }}" state=present'
6+ with_items :
7+ - " @Development tools"
8+ - tar
9+ - unzip
10+ - sudo
11+ - which
12+ when : ansible_os_family == 'RedHat'
13+
14+ - name : Ensure build dependencies are installed (Debian).
15+ apt : ' name="{{ item }}" state=installed'
16+ with_items :
17+ - build-essential
18+ - unzip
19+ - tar
20+ - sudo
21+ when : ansible_os_family == 'Debian'
22+
23+ roles :
24+ - role_under_test
You can’t perform that action at this time.
0 commit comments