diff --git a/test/integration/destructive.yml b/test/integration/destructive.yml index 54c905bdf6e..b8f56d113bf 100644 --- a/test/integration/destructive.yml +++ b/test/integration/destructive.yml @@ -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} diff --git a/test/integration/roles/test_docker/meta/main.yml b/test/integration/roles/test_docker/meta/main.yml new file mode 100644 index 00000000000..399f3fb6e77 --- /dev/null +++ b/test/integration/roles/test_docker/meta/main.yml @@ -0,0 +1,20 @@ +# test code for the service module +# (c) 2014, James Cammarata + +# 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 . + +dependencies: + - prepare_tests diff --git a/test/integration/roles/test_docker/tasks/main.yml b/test/integration/roles/test_docker/tasks/main.yml new file mode 100644 index 00000000000..6141fe05348 --- /dev/null +++ b/test/integration/roles/test_docker/tasks/main.yml @@ -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"