From 09cb8f15ba1fb40492de01dfd4e8a6e87a22c271 Mon Sep 17 00:00:00 2001 From: Dominika Hodovska Date: May 03 2018 12:46:29 +0000 Subject: Add standard role for docker images --- diff --git a/roles/standard-test-image-docker/README.md b/roles/standard-test-image-docker/README.md new file mode 100644 index 0000000..25643d1 --- /dev/null +++ b/roles/standard-test-image-docker/README.md @@ -0,0 +1,12 @@ +# Ansible role for docker images + +Put this role in your tests.yml playbook. This role will ensure docker engine is installed +and running on your localhost, pulls the image specified in image_name and runs the script +./runtest.sh that should execute image tests. You'll need +to have the following variables defined: + + * image_name: url of image to test + * artifacts: An artifacts directory + +Include any playbooks after this role with tests you want to +run. For example test_local.yml diff --git a/roles/standard-test-image-docker/meta/main.yml b/roles/standard-test-image-docker/meta/main.yml new file mode 100644 index 0000000..56d081d --- /dev/null +++ b/roles/standard-test-image-docker/meta/main.yml @@ -0,0 +1,4 @@ +--- + +dependencies: + - role: standard-test-basic diff --git a/roles/standard-test-image-docker/tasks/main.yml b/roles/standard-test-image-docker/tasks/main.yml new file mode 100644 index 0000000..cb926a1 --- /dev/null +++ b/roles/standard-test-image-docker/tasks/main.yml @@ -0,0 +1,36 @@ +--- +- name: Prepare the environment to run tests + block: + - name: Install the container engine + package: + name: docker + state: present + become: true + - name: Start the container engine + systemd: + name: docker + state: started + become: true + +- name: Pull the container image + docker_image: + name: "{{ image_name }}" + register: container_image_under_test + + +- block: + - name: Create temp dir to store tests + tempfile: + state: directory + register: tmp_tests + - name: Execute the role which performs testing + import_role: + name: standard-test-basic + vars: + tenv_workdir: "{{ tmp_tests.path }}" + always: + - name: delete the temp dir + file: + path: "{{ tmp_tests.path }}" + state: absent +