-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise3-grade.yaml
More file actions
38 lines (32 loc) · 1.12 KB
/
exercise3-grade.yaml
File metadata and controls
38 lines (32 loc) · 1.12 KB
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
- name: Grading the exercise3
hosts: localhost
gather_facts: true
vars:
user: "{{ lookup('env', 'USER') }}"
tasks:
- name: Getting URL from route
kubernetes.core.k8s_info:
kind: Route
namespace: "namespace-{{ user }}"
name: exercise3
register: routefacts
- name: Access the URL and check for the response
ansible.builtin.uri:
url: "https://{{ routefacts.resources[0].spec.host }}"
method: GET
return_content: true
register: urlcontent
no_log: false
ignore_errors: true
- name: Check if response contains the expected content
ansible.builtin.set_fact:
urlcontent_valid: >-
{{ 'Hello from exercise3, you are doing a great job!' in urlcontent.content }}
- name: Show success message if condition is true
ansible.builtin.debug:
msg: "Good job, it's working as expected!"
when: urlcontent_valid
- name: Show failure message if condition is false
ansible.builtin.fail:
msg: "Ops, something went wrong and you have to fix the exercise!"
when: not urlcontent_valid