| 1 |
# Test code for the vmware_vcenter_settings module. |
| 2 |
# Copyright: (c) 2018, Christian Kotte <[email protected]> |
| 3 |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 4 |
|
| 5 |
- import_role: |
| 6 |
name: prepare_vmware_tests |
| 7 |
|
| 8 |
- name: Configure general settings in check mode |
| 9 |
community.vmware.vmware_vcenter_settings: |
| 10 |
hostname: "{{ vcenter_hostname }}" |
| 11 |
username: "{{ vcenter_username }}" |
| 12 |
password: "{{ vcenter_password }}" |
| 13 |
database: |
| 14 |
max_connections: 50 |
| 15 |
task_cleanup: true |
| 16 |
task_retention: 180 |
| 17 |
event_cleanup: true |
| 18 |
event_retention: 180 |
| 19 |
runtime_settings: |
| 20 |
unique_id: 7 |
| 21 |
managed_address: 192.168.1.0 |
| 22 |
vcenter_server_name: "{{ inventory_hostname }}" |
| 23 |
user_directory: |
| 24 |
timeout: 120 |
| 25 |
query_limit: true |
| 26 |
query_limit_size: 100000 |
| 27 |
validation: true |
| 28 |
validation_period: 1440 |
| 29 |
mail: |
| 30 |
server: mail.example.local |
| 31 |
sender: vcenter@{{ inventory_hostname }} |
| 32 |
snmp_receivers: |
| 33 |
snmp_receiver_1_url: localhost |
| 34 |
snmp_receiver_1_enabled: true |
| 35 |
snmp_receiver_1_port: 162 |
| 36 |
snmp_receiver_1_community: public |
| 37 |
timeout_settings: |
| 38 |
normal_operations: 30 |
| 39 |
long_operations: 120 |
| 40 |
logging_options: info |
| 41 |
validate_certs: false |
| 42 |
register: all_settings_results_check_mode |
| 43 |
check_mode: true |
| 44 |
|
| 45 |
- debug: var=all_settings_results_check_mode |
| 46 |
|
| 47 |
- name: Configure general settings |
| 48 |
community.vmware.vmware_vcenter_settings: |
| 49 |
hostname: "{{ vcenter_hostname }}" |
| 50 |
username: "{{ vcenter_username }}" |
| 51 |
password: "{{ vcenter_password }}" |
| 52 |
database: |
| 53 |
max_connections: 50 |
| 54 |
task_cleanup: true |
| 55 |
task_retention: 180 |
| 56 |
event_cleanup: true |
| 57 |
event_retention: 180 |
| 58 |
runtime_settings: |
| 59 |
unique_id: 7 |
| 60 |
managed_address: 192.168.1.0 |
| 61 |
vcenter_server_name: "{{ inventory_hostname }}" |
| 62 |
user_directory: |
| 63 |
timeout: 120 |
| 64 |
query_limit: true |
| 65 |
query_limit_size: 100000 |
| 66 |
validation: true |
| 67 |
validation_period: 1440 |
| 68 |
mail: |
| 69 |
server: mail.example.local |
| 70 |
sender: vcenter@{{ inventory_hostname }} |
| 71 |
snmp_receivers: |
| 72 |
snmp_receiver_1_url: localhost |
| 73 |
snmp_receiver_1_enabled: true |
| 74 |
snmp_receiver_1_port: 162 |
| 75 |
snmp_receiver_1_community: public |
| 76 |
timeout_settings: |
| 77 |
normal_operations: 30 |
| 78 |
long_operations: 120 |
| 79 |
logging_options: info |
| 80 |
validate_certs: false |
| 81 |
register: all_settings_results |
| 82 |
|
| 83 |
- debug: var=all_settings_results |
| 84 |
|
| 85 |
- name: Configure settings with out runtime_settings parameter |
| 86 |
community.vmware.vmware_vcenter_settings: |
| 87 |
hostname: "{{ vcenter_hostname }}" |
| 88 |
username: "{{ vcenter_username }}" |
| 89 |
password: "{{ vcenter_password }}" |
| 90 |
validate_certs: false |
| 91 |
mail: |
| 92 |
server: mail.example.local |
| 93 |
sender: vcenter@{{ inventory_hostname }} |
| 94 |
register: without_runtime_settings_results |
| 95 |
|
| 96 |
- debug: var=without_runtime_settings_results |
| 97 |
|
| 98 |
- name: Configure settings with check mode and diff mode |
| 99 |
community.vmware.vmware_vcenter_settings: |
| 100 |
hostname: "{{ vcenter_hostname }}" |
| 101 |
username: "{{ vcenter_username }}" |
| 102 |
password: "{{ vcenter_password }}" |
| 103 |
validate_certs: false |
| 104 |
database: |
| 105 |
max_connections: 50 |
| 106 |
task_cleanup: true |
| 107 |
task_retention: 180 |
| 108 |
event_cleanup: true |
| 109 |
event_retention: 180 |
| 110 |
mail: |
| 111 |
server: mail.example.local |
| 112 |
sender: vcenter@{{ inventory_hostname }} |
| 113 |
diff: true |
| 114 |
check_mode: true |
| 115 |
register: configure_settings_check_diff_mode_result |
| 116 |
|
| 117 |
- name: Make sure if the change occurred and to exist the diff key |
| 118 |
assert: |
| 119 |
that: |
| 120 |
- configure_settings_check_diff_mode_result.changed is sameas true |
| 121 |
- configure_settings_check_diff_mode_result.diff is defined |
| 122 |
|
| 123 |
- name: Configure settings without check mode and diff mode |
| 124 |
community.vmware.vmware_vcenter_settings: |
| 125 |
hostname: "{{ vcenter_hostname }}" |
| 126 |
username: "{{ vcenter_username }}" |
| 127 |
password: "{{ vcenter_password }}" |
| 128 |
validate_certs: false |
| 129 |
database: |
| 130 |
max_connections: 50 |
| 131 |
task_cleanup: true |
| 132 |
task_retention: 180 |
| 133 |
event_cleanup: true |
| 134 |
event_retention: 180 |
| 135 |
mail: |
| 136 |
server: mail.example.local |
| 137 |
sender: vcenter@{{ inventory_hostname }} |
| 138 |
register: configure_settings_result |
| 139 |
|
| 140 |
- name: Make sure if the change occurred |
| 141 |
assert: |
| 142 |
that: |
| 143 |
- configure_settings_result.changed is sameas true |
| 144 |
|
| 145 |
- name: Configure settings without check mode and diff mode(idempotency check) |
| 146 |
community.vmware.vmware_vcenter_settings: |
| 147 |
hostname: "{{ vcenter_hostname }}" |
| 148 |
username: "{{ vcenter_username }}" |
| 149 |
password: "{{ vcenter_password }}" |
| 150 |
validate_certs: false |
| 151 |
database: |
| 152 |
max_connections: 50 |
| 153 |
task_cleanup: true |
| 154 |
task_retention: 180 |
| 155 |
event_cleanup: true |
| 156 |
event_retention: 180 |
| 157 |
mail: |
| 158 |
server: mail.example.local |
| 159 |
sender: vcenter@{{ inventory_hostname }} |
| 160 |
register: configure_settings_idempotency_check_result |
| 161 |
|
| 162 |
- name: Make sure if the change doesn't occur |
| 163 |
assert: |
| 164 |
that: |
| 165 |
- configure_settings_idempotency_check_result.changed is sameas false |
| 166 |
|
| 167 |
- name: Configure advanced settings |
| 168 |
community.vmware.vmware_vcenter_settings: |
| 169 |
hostname: "{{ vcenter_hostname }}" |
| 170 |
username: "{{ vcenter_username }}" |
| 171 |
password: "{{ vcenter_password }}" |
| 172 |
validate_certs: false |
| 173 |
database: |
| 174 |
max_connections: 50 |
| 175 |
task_cleanup: true |
| 176 |
task_retention: 180 |
| 177 |
event_cleanup: true |
| 178 |
event_retention: 180 |
| 179 |
mail: |
| 180 |
server: mail.example.local |
| 181 |
sender: vcenter@{{ inventory_hostname }} |
| 182 |
advanced_settings: |
| 183 |
'config.vcls.clusters.domain-c8.enabled': 'false' |
| 184 |
register: configure_advanced_settings |
| 185 |
|
| 186 |
- name: Make sure that advanced settings are configured |
| 187 |
assert: |
| 188 |
that: |
| 189 |
- configure_advanced_settings.changed |
| 190 |
|
| 191 |
- name: Configure advanced settings again (idempotency) |
| 192 |
community.vmware.vmware_vcenter_settings: |
| 193 |
hostname: "{{ vcenter_hostname }}" |
| 194 |
username: "{{ vcenter_username }}" |
| 195 |
password: "{{ vcenter_password }}" |
| 196 |
validate_certs: false |
| 197 |
database: |
| 198 |
max_connections: 50 |
| 199 |
task_cleanup: true |
| 200 |
task_retention: 180 |
| 201 |
event_cleanup: true |
| 202 |
event_retention: 180 |
| 203 |
mail: |
| 204 |
server: mail.example.local |
| 205 |
sender: vcenter@{{ inventory_hostname }} |
| 206 |
advanced_settings: |
| 207 |
'config.vcls.clusters.domain-c8.enabled': 'false' |
| 208 |
register: configure_advanced_settings_again |
| 209 |
|
| 210 |
- name: Make sure that advanced settings are not configured (idempotency) |
| 211 |
assert: |
| 212 |
that: |
| 213 |
- not configure_advanced_settings_again.changed |
| 214 |
|
| 215 |
- name: Restore the original advanced_settings configuration |
| 216 |
community.vmware.vmware_vcenter_settings: |
| 217 |
hostname: "{{ vcenter_hostname }}" |
| 218 |
username: "{{ vcenter_username }}" |
| 219 |
password: "{{ vcenter_password }}" |
| 220 |
validate_certs: false |
| 221 |
advanced_settings: |
| 222 |
'config.vcls.clusters.domain-c8.enabled': 'true' |