Initial test of the docker module
This commit is contained in:
parent
f9a66a7ff7
commit
a64de2e000
3 changed files with 75 additions and 0 deletions
|
@ -17,3 +17,4 @@
|
|||
- { role: test_mysql_db, tags: test_mysql_db}
|
||||
- { role: test_mysql_user, tags: test_mysql_user}
|
||||
- { role: test_mysql_variables, tags: test_mysql_variables}
|
||||
- { role: test_docker, tags: test_docker}
|
||||
|
|
20
test/integration/roles/test_docker/meta/main.yml
Normal file
20
test/integration/roles/test_docker/meta/main.yml
Normal file
|
@ -0,0 +1,20 @@
|
|||
# test code for the service module
|
||||
# (c) 2014, James Cammarata <jcammarata@ansible.com>
|
||||
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
dependencies:
|
||||
- prepare_tests
|
54
test/integration/roles/test_docker/tasks/main.yml
Normal file
54
test/integration/roles/test_docker/tasks/main.yml
Normal file
|
@ -0,0 +1,54 @@
|
|||
- name: Install docker packages (yum)
|
||||
yum:
|
||||
state: present
|
||||
name: docker,docker-registry,python-docker-py
|
||||
when: ansible_distribution in ['RedHat', 'CentOS', 'Fedora']
|
||||
|
||||
- name: Install docker packages (apt)
|
||||
apt:
|
||||
state: present
|
||||
# Note: add docker-registry when available
|
||||
name: docker.io,python-docker
|
||||
when: ansible_distribution in ['Ubuntu', 'Debian']
|
||||
|
||||
- name: Start docker daemon
|
||||
service:
|
||||
name: docker
|
||||
state: started
|
||||
|
||||
- name: Download busybox image
|
||||
docker:
|
||||
image: busybox
|
||||
state: present
|
||||
pull: missing
|
||||
|
||||
- name: Run a small script in busybox
|
||||
docker:
|
||||
image: busybox
|
||||
state: reloaded
|
||||
pull: always
|
||||
command: "nc -l -p 2000 -e xargs -n1 echo hello"
|
||||
detach: True
|
||||
|
||||
- name: Get the docker container id
|
||||
shell: "docker ps | grep busybox | awk '{ print $1 }'"
|
||||
register: container_id
|
||||
|
||||
- debug: var=container_id
|
||||
|
||||
- name: Get the docker container ip
|
||||
shell: "docker inspect {{ container_id.stdout_lines[0] }} | grep IPAddress | awk -F '\"' '{ print $4 }'"
|
||||
register: container_ip
|
||||
|
||||
- debug: var=container_ip
|
||||
|
||||
- name: Try to access the server
|
||||
shell: "echo 'world' | nc {{ container_ip.stdout_lines[0] }} 2000"
|
||||
register: docker_output
|
||||
|
||||
- debug: var=docker_output
|
||||
|
||||
- name: check that the script ran
|
||||
assert:
|
||||
that:
|
||||
- "'hello world' in docker_output.stdout_lines"
|
Loading…
Reference in a new issue