| 1 |
--- |
| 2 |
#################################################################### |
| 3 |
# WARNING: These are designed specifically for Ansible tests # |
| 4 |
# and should not be used as examples of how to write Ansible roles # |
| 5 |
#################################################################### |
| 6 |
|
| 7 |
# Copyright (c) Ansible Project |
| 8 |
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 9 |
# SPDX-License-Identifier: GPL-3.0-or-later |
| 10 |
|
| 11 |
- name: Create customer (check mode) |
| 12 |
alerta_customer: |
| 13 |
alerta_url: "{{ alerta_url }}" |
| 14 |
api_username: "{{ alerta_user }}" |
| 15 |
api_password: "{{ alerta_password }}" |
| 16 |
customer: customer1 |
| 17 |
match: [email protected] |
| 18 |
check_mode: true |
| 19 |
register: result |
| 20 |
|
| 21 |
- name: Check result (check mode) |
| 22 |
assert: |
| 23 |
that: |
| 24 |
- result is changed |
| 25 |
|
| 26 |
- name: Create customer |
| 27 |
alerta_customer: |
| 28 |
alerta_url: "{{ alerta_url }}" |
| 29 |
api_username: "{{ alerta_user }}" |
| 30 |
api_password: "{{ alerta_password }}" |
| 31 |
customer: customer1 |
| 32 |
match: [email protected] |
| 33 |
register: result |
| 34 |
|
| 35 |
- name: Check customer creation |
| 36 |
assert: |
| 37 |
that: |
| 38 |
- result is changed |
| 39 |
|
| 40 |
- name: Test customer creation idempotency |
| 41 |
alerta_customer: |
| 42 |
alerta_url: "{{ alerta_url }}" |
| 43 |
api_username: "{{ alerta_user }}" |
| 44 |
api_password: "{{ alerta_password }}" |
| 45 |
customer: customer1 |
| 46 |
match: [email protected] |
| 47 |
register: result |
| 48 |
|
| 49 |
- name: Check customer creation idempotency |
| 50 |
assert: |
| 51 |
that: |
| 52 |
- result is not changed |
| 53 |
|
| 54 |
- name: Delete customer (check mode) |
| 55 |
alerta_customer: |
| 56 |
alerta_url: "{{ alerta_url }}" |
| 57 |
api_username: "{{ alerta_user }}" |
| 58 |
api_password: "{{ alerta_password }}" |
| 59 |
customer: customer1 |
| 60 |
match: [email protected] |
| 61 |
state: absent |
| 62 |
check_mode: true |
| 63 |
register: result |
| 64 |
|
| 65 |
- name: Check customer deletion (check mode) |
| 66 |
assert: |
| 67 |
that: |
| 68 |
- result is changed |
| 69 |
|
| 70 |
- name: Delete customer |
| 71 |
alerta_customer: |
| 72 |
alerta_url: "{{ alerta_url }}" |
| 73 |
api_username: "{{ alerta_user }}" |
| 74 |
api_password: "{{ alerta_password }}" |
| 75 |
customer: customer1 |
| 76 |
match: [email protected] |
| 77 |
state: absent |
| 78 |
register: result |
| 79 |
|
| 80 |
- name: Check customer deletion |
| 81 |
assert: |
| 82 |
that: |
| 83 |
- result is changed |
| 84 |
|
| 85 |
- name: Test customer deletion idempotency |
| 86 |
alerta_customer: |
| 87 |
alerta_url: "{{ alerta_url }}" |
| 88 |
api_username: "{{ alerta_user }}" |
| 89 |
api_password: "{{ alerta_password }}" |
| 90 |
customer: customer1 |
| 91 |
match: [email protected] |
| 92 |
state: absent |
| 93 |
register: result |
| 94 |
|
| 95 |
- name: Check customer deletion idempotency |
| 96 |
assert: |
| 97 |
that: |
| 98 |
- result is not changed |
| 99 |
|
| 100 |
- name: Delete non-existing customer (check mode) |
| 101 |
alerta_customer: |
| 102 |
alerta_url: "{{ alerta_url }}" |
| 103 |
api_username: "{{ alerta_user }}" |
| 104 |
api_password: "{{ alerta_password }}" |
| 105 |
customer: customer1 |
| 106 |
match: [email protected] |
| 107 |
state: absent |
| 108 |
check_mode: true |
| 109 |
register: result |
| 110 |
|
| 111 |
- name: Check non-existing customer deletion (check mode) |
| 112 |
assert: |
| 113 |
that: |
| 114 |
- result is not changed |
| 115 |
|
| 116 |
- name: Create customer with api key |
| 117 |
alerta_customer: |
| 118 |
alerta_url: "{{ alerta_url }}" |
| 119 |
api_key: "{{ alerta_key }}" |
| 120 |
customer: customer1 |
| 121 |
match: [email protected] |
| 122 |
register: result |
| 123 |
|
| 124 |
- name: Check customer creation with api key |
| 125 |
assert: |
| 126 |
that: |
| 127 |
- result is changed |
| 128 |
|
| 129 |
- name: Delete customer with api key |
| 130 |
alerta_customer: |
| 131 |
alerta_url: "{{ alerta_url }}" |
| 132 |
api_key: "{{ alerta_key }}" |
| 133 |
customer: customer1 |
| 134 |
match: [email protected] |
| 135 |
state: absent |
| 136 |
register: result |
| 137 |
|
| 138 |
- name: Check customer deletion with api key |
| 139 |
assert: |
| 140 |
that: |
| 141 |
- result is changed |
| 142 |
|
| 143 |
- name: Use wrong api key |
| 144 |
alerta_customer: |
| 145 |
alerta_url: "{{ alerta_url }}" |
| 146 |
api_key: wrong_key |
| 147 |
customer: customer1 |
| 148 |
match: [email protected] |
| 149 |
register: result |
| 150 |
ignore_errors: true |
| 151 |
|
| 152 |
- name: Check customer creation with api key |
| 153 |
assert: |
| 154 |
that: |
| 155 |
- result is not changed |
| 156 |
- result is failed |