forked from projectatomic/atomic-host-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.yml
147 lines (120 loc) · 3.01 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
---
# vim: set ft=ansible:
#
# !!!NOTE!!! This playbook was tested using Ansible 2.2; it is recommended
# that the same version is used.
#
# This playbook tests the basic functions of docker or docker-latest. These
# functions include:
# - docker build
# - docker images
# - docker ps
# - docker pull
# - docker rm
# - docker rmi
# - docker run
# - docker start
# - docker stop
#
# To test docker-current, set the g_docker_latest variable to false in the
# vars.yml file.
#
- name: Docker - Setup
hosts: all
become: yes
tags:
- setup
vars_files:
- vars.yml
pre_tasks:
- name: Check for docker-latest package if running against docker-latest
command: rpm -qa
register: pkgs
when: g_docker_latest
- name: Fail if docker latest is not installed
fail:
msg: "This test is not valid because docker-latest is not installed"
when:
- g_docker_latest
- "'docker-latest' not in pkgs.stdout"
roles:
# This playbook requires Ansible 2.2 and an Atomic Host
- role: ansible_version_check
avc_major: "2"
avc_minor: "2"
tags:
- ansible_version_check
# Subscribe if the system is RHEL
- role: redhat_subscription
when: ansible_distribution == 'RedHat'
tags:
- redhat_subscription
- name: Docker - Functional Tests
hosts: all
become: yes
tags:
- functional
vars_files:
- vars.yml
roles:
- role: osname_set_fact
tags:
- osname_set_fact
- role: docker_remove_all
tags:
- docker_remove_all
- role: docker_latest_setup
tags:
- docker_latest_setup
when: g_docker_latest
- role: docker_pull_base_image
tags:
- docker_pull_base_image
- role: docker_build_httpd
tags:
- docker_build_httpd
- role: docker_run_httpd
tags:
- docker_run_httpd
- role: docker_rm_httpd_container
tags:
- docker_rm_httpd_container
- role: docker_rmi_httpd_image
tags:
- docker_rmi_httpd_image
- name: Docker - Cleanup
hosts: all
become: yes
tags:
- cleanup
vars_files:
- vars.yml
pre_tasks:
- block:
- name: Stop and disable docker-latest
service:
name: docker-latest
enabled: no
state: stopped
- name: Revert docker-latest binary
blockinfile:
dest: /etc/sysconfig/docker
block: |
#DOCKERBINARY=/usr/bin/docker-latest
#DOCKERDBINARY=/usr/bin/dockerd-latest
#DOCKER_CONTAINERD_BINARY=/usr/bin/docker-containerd-latest
#DOCKER_CONTAINERD_SHIM_BINARY=/usr/bin/docker-containerd-shim-latest
- name: Re-enable docker
service:
name: docker
enabled: yes
state: started
when: g_docker_latest
roles:
- role: docker_remove_all
tags:
- docker_remove_all
- role: redhat_unsubscribe
when: ansible_distribution == 'RedHat'
tags:
- redhat_unsubscribe