forked from projectatomic/atomic-host-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.yml
61 lines (53 loc) · 1.85 KB
/
main.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
# vim: set ft=ansible:
- name: Docker Build HTTPD - Test Suite
hosts: all
become: true
vars_files:
- vars.yml
vars:
tests: []
tasks:
- name: Set logging
set_fact:
log_results: true
result_file: "{{ playbook_dir }}/docker-build-httpd-result.log"
tags: setup
- include_tasks: 'setup.yml'
tags: setup
# TEST
# Verify user can build httpd with Docker
- block:
- include_tasks: 'docker-build-httpd.yml'
- set_fact:
tests: "{{ tests + [ { 'name':'Docker Build HTTPD Test', 'result':'Passed', 'result_details': '' } ] }}"
rescue:
- set_fact:
tests: "{{ tests + [ { 'name':'Docker Build HTTPD Test', 'result':'Failed', 'result_details': ansible_failed_result } ] }}"
tags: docker_build_httpd
# CLEANUP
- block:
- include_tasks: 'cleanup.yml'
- set_fact:
tests: "{{ tests + [ { 'name': 'Cleanup', 'result':'Passed', 'result_details': '' } ] }}"
rescue:
- set_fact:
tests: "{{ tests + [ { 'name':'Cleanup', 'result':'Failed', 'result_details': ansible_failed_result } ] }}"
always:
# WRITE RESULTS TO FILE
- name: Remove existing log files
local_action: file path={{ result_file }} state=absent
become: false
- name: Save result to file
when: log_results
local_action: copy content={{ tests | to_nice_yaml(indent=2) }} dest={{ result_file }}
become: false
tags: cleanup
# Handled exceptions show up as failures in Ansible but the playbook
# itself does not return 0, so explicitly fail the test by checking
# the test results
- name: Explicitly fail based on test results
when: item['result']|lower == "failed"
fail:
msg: "Failure found in test"
with_items: "{{ tests }}"