-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathansible_test.yml
44 lines (38 loc) · 1.3 KB
/
ansible_test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
- name: Test Domain Extractor Application
hosts: localhost
gather_facts: false
tasks:
- name: Check if Docker is installed
command: docker --version
register: docker_version
ignore_errors: true
- name: Check if Docker Compose is installed
command: docker-compose --version
register: docker_compose_version
ignore_errors: true
- name: Build and run Docker container
docker_compose:
project_src: .
state: present
when: docker_version.rc == 0 and docker_compose_version.rc == 0
- name: Wait for application to start
wait_for:
port: 5000
timeout: 30
when: docker_version.rc == 0 and docker_compose_version.rc == 0
- name: Test application health
uri:
url: http://localhost:5000
return_content: yes
register: app_health
when: docker_version.rc == 0 and docker_compose_version.rc == 0
- name: Stop and remove Docker container
docker_compose:
project_src: .
state: absent
when: docker_version.rc == 0 and docker_compose_version.rc == 0
- name: Display test results
debug:
msg: "Application health check {{ 'passed' if app_health.status == 200 else 'failed' }}"
when: docker_version.rc == 0 and docker_compose_version.rc == 0