summaryrefslogtreecommitdiffstats
path: root/test/integration/openshift_health_checker/setup_container.yml
diff options
context:
space:
mode:
authorOpenShift Bot <eparis+openshiftbot@redhat.com>2017-04-26 01:23:28 -0500
committerGitHub <noreply@github.com>2017-04-26 01:23:28 -0500
commitc12b00944940cd7f425323e1598a4b7683ddaf75 (patch)
treed1cb21b763579a5c5a2fa5dd0c30078b7383bbe7 /test/integration/openshift_health_checker/setup_container.yml
parent760bdbc78081d9780d2618c422f31913dd9d38c7 (diff)
parente5f14b515b07bcfa2079c3e68c35fee3e97970c7 (diff)
downloadopenshift-c12b00944940cd7f425323e1598a4b7683ddaf75.tar.gz
openshift-c12b00944940cd7f425323e1598a4b7683ddaf75.tar.bz2
openshift-c12b00944940cd7f425323e1598a4b7683ddaf75.tar.xz
openshift-c12b00944940cd7f425323e1598a4b7683ddaf75.zip
Merge pull request #3816 from sosiouxme/20170328-integration-tests
Merged by openshift-bot
Diffstat (limited to 'test/integration/openshift_health_checker/setup_container.yml')
-rw-r--r--test/integration/openshift_health_checker/setup_container.yml45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/integration/openshift_health_checker/setup_container.yml b/test/integration/openshift_health_checker/setup_container.yml
new file mode 100644
index 000000000..8793d954e
--- /dev/null
+++ b/test/integration/openshift_health_checker/setup_container.yml
@@ -0,0 +1,45 @@
+---
+# Include this play once for each container you want to create and use as a test host.
+#
+# Optional parameters on the include are as follows:
+# * scenario = unique name for the container to be started
+# * image = name of the image to start in the container
+# * command = command to run in the container
+# * l_groups = host groups that the container should be added to
+# * l_host_vars = any variables that should be added to the host
+
+- name: Start container for specified test host
+ gather_facts: no
+ hosts: localhost
+ connection: local
+ tasks:
+
+ - set_fact:
+ # This is a little weird but if we use a var instead of a fact,
+ # a different random value is generated for each task. See:
+ # https://opensolitude.com/2015/05/27/ansible-lookups-variables-vs-facts.html
+ container_name: openshift_ansible_test_{{ scenario | default(100000000000000 | random) }}
+
+ - name: start container
+ docker_container:
+ name: "{{ container_name }}"
+ image: "{{ lookup('env', 'IMAGE_PREFIX') | default('openshift-ansible-integration-', true) }}{{ image | default('test-target-base') }}"
+ command: "{{ command | default('sleep 1800') }}"
+ recreate: yes
+ # NOTE: When/if we need to run containers that are docker hosts as well:
+ # volumes: [ "/var/run/docker.sock:/var/run/docker.sock:z" ]
+
+ - name: add container as host in inventory
+ add_host:
+ ansible_connection: docker
+ name: "{{ container_name }}"
+ groups: '{{ l_groups | default("masters,nodes,etcd") }}'
+
+ # There ought to be a better way to transfer the host vars, but see:
+ # https://groups.google.com/forum/#!topic/Ansible-project/Jwx8RYhqxPA
+ - name: set host facts per test parameters
+ set_fact:
+ "{{ item.key }}": "{{ item.value }}"
+ delegate_facts: True
+ delegate_to: "{{ container_name }}"
+ with_dict: "{{ l_host_vars | default({}) }}"