summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <toshio@fedoraproject.org>2015-03-17 12:32:07 -0700
committerToshio Kuratomi <toshio@fedoraproject.org>2015-03-19 13:51:29 -0700
commitaf908176228031cab8768487a2042d74b3a7b0e5 (patch)
tree0ccb3ece46c4494c3efd19a84f6d1bc146f35a2e
parent6a803f6582ac9dc93eab54bd44106dbe9879b83d (diff)
downloadansible-af908176228031cab8768487a2042d74b3a7b0e5.tar.gz
Initial test of the docker module
-rw-r--r--test/integration/destructive.yml1
-rw-r--r--test/integration/roles/test_docker/meta/main.yml20
-rw-r--r--test/integration/roles/test_docker/tasks/main.yml54
3 files changed, 75 insertions, 0 deletions
diff --git a/test/integration/destructive.yml b/test/integration/destructive.yml
index 54c905bdf6..b8f56d113b 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 0000000000..399f3fb6e7
--- /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 <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
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 0000000000..6141fe0534
--- /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"