blob: 1c1a647d464b6d86c7541eeea52b7097702b4f32 [file] [log] [blame]
---
# netprep molecule/default/verify.yml
#
# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
# SPDX-License-Identifier: Apache-2.0
- name: Verify
hosts: all
become: true
vars:
nginx_static_dir: "/srv/sites"
tasks:
- name: Create a test file to be served for port 8080, 8081 nginx server
lineinfile:
path: "{{ nginx_static_dir }}/{{ item }}.example.com/index.html"
line: "This file is served from {{ item }}.example.com"
mode: 0644
create: true
with_items:
- "port8080"
- "port8081"
- name: Create Docker container script
file:
dest: /tmp/docker_script.sh
state: touch
- name: Write content into Docker container script
lineinfile:
dest: /tmp/docker_script.sh
line: "{{ item }}"
with_items:
- "curl 172.17.0.1:8080 --connect-timeout 1 || exit 1"
- "curl 172.17.0.1:8081 --connect-timeout 1 || exit 1"
- "curl 172.27.0.1:8080 --connect-timeout 1 || exit 1"
- "curl 172.27.0.1:8081 --connect-timeout 1 && exit 1"
- "sleep 3600"
- name: Start a testing container
docker_container:
name: curl
image: curlimages/curl
state: started
entrypoint: "sh script.sh"
networks:
- name: bridge
- name: limited_network
volumes:
- /tmp/docker_script.sh:/script.sh
- name: Sleep for 5 seconds for curl execution
wait_for:
timeout: 5
- name: Get container's information
docker_container_info:
name: curl
register: result
- name: Check container is live (it'll be live if test pass)
docker_container_info:
name: curl
failed_when: result.container["State"]["Running"] != true