| 1 |
- name: Create OpenSearch clusters |
| 2 |
block: |
| 3 |
- name: test without specifying required module options |
| 4 |
opensearch: |
| 5 |
engine_version: "Elasticsearch_7.1" |
| 6 |
ignore_errors: true |
| 7 |
register: result |
| 8 |
|
| 9 |
- name: assert domain_name is a required module option |
| 10 |
assert: |
| 11 |
that: |
| 12 |
- "result.msg == 'missing required arguments: domain_name'" |
| 13 |
|
| 14 |
- name: Create public-facing OpenSearch cluster in check mode |
| 15 |
opensearch: |
| 16 |
state: present |
| 17 |
domain_name: "es-{{ tiny_prefix }}-public" |
| 18 |
engine_version: "OpenSearch_1.1" |
| 19 |
cluster_config: |
| 20 |
instance_type: "t2.small.search" |
| 21 |
instance_count: 2 |
| 22 |
dedicated_master: false |
| 23 |
access_policies: "{{ lookup('file', 'opensearch_policy.json') | from_json }}" |
| 24 |
ebs_options: |
| 25 |
ebs_enabled: true |
| 26 |
volume_size: 10 |
| 27 |
tags: |
| 28 |
Name: "es-{{ tiny_prefix }}-public" |
| 29 |
Environment: Testing |
| 30 |
Application: Search |
| 31 |
AnsibleTest: "AnsibleTestOpenSearchCluster" |
| 32 |
check_mode: true |
| 33 |
register: opensearch_domain |
| 34 |
- assert: |
| 35 |
that: |
| 36 |
- "opensearch_domain is changed" |
| 37 |
|
| 38 |
- name: Create public-facing OpenSearch cluster, changes expected |
| 39 |
# This could take 30 minutes |
| 40 |
opensearch: |
| 41 |
state: present |
| 42 |
# Note domain_name must be less than 28 characters and satisfy regex [a-z][a-z0-9\\-]+ |
| 43 |
domain_name: "es-{{ tiny_prefix }}-public" |
| 44 |
engine_version: "OpenSearch_1.1" |
| 45 |
cluster_config: |
| 46 |
instance_type: "t2.small.search" |
| 47 |
instance_count: 2 |
| 48 |
dedicated_master: false |
| 49 |
access_policies: "{{ lookup('file', 'opensearch_policy.json') | from_json }}" |
| 50 |
ebs_options: |
| 51 |
# EBS must be enabled for "t2.small.search" |
| 52 |
ebs_enabled: true |
| 53 |
volume_size: 10 |
| 54 |
tags: |
| 55 |
# Note: The domain name must start with a letter, but the tiny prefix may start with |
| 56 |
# a digit. |
| 57 |
Name: "es-{{ tiny_prefix }}-public" |
| 58 |
Environment: Testing |
| 59 |
Application: Search |
| 60 |
AnsibleTest: "AnsibleTestOpenSearchCluster" |
| 61 |
# Intentionally not waiting for cluster to be available. |
| 62 |
# All other integration tests are performed with the |
| 63 |
# OpenSearch cluster attached to the VPC. |
| 64 |
wait: false |
| 65 |
register: opensearch_domain |
| 66 |
- assert: |
| 67 |
that: |
| 68 |
- "opensearch_domain.tags | length == 4" |
| 69 |
- "opensearch_domain.engine_version == 'OpenSearch_1.1'" |
| 70 |
- "opensearch_domain.cluster_config.instance_count == 2" |
| 71 |
- "opensearch_domain.cluster_config.instance_type == 't2.small.search'" |
| 72 |
- "opensearch_domain.cluster_config.dedicated_master_enabled == false" |
| 73 |
- "opensearch_domain.cluster_config.warm_enabled == false" |
| 74 |
- "opensearch_domain.ebs_options.ebs_enabled == true" |
| 75 |
- "opensearch_domain.ebs_options.volume_size == 10" |
| 76 |
# Below should be default settings when not specified as input arguments |
| 77 |
- "opensearch_domain.ebs_options.volume_type == 'gp2'" |
| 78 |
- "opensearch_domain.advanced_security_options.enabled == false" |
| 79 |
- "opensearch_domain.cognito_options.enabled == false" |
| 80 |
- "opensearch_domain.domain_endpoint_options.custom_endpoint_enabled == false" |
| 81 |
- "opensearch_domain.encryption_at_rest_options.enabled == false" |
| 82 |
- "opensearch_domain.node_to_node_encryption_options.enabled == false" |
| 83 |
- "opensearch_domain.snapshot_options.automated_snapshot_start_hour == 0" |
| 84 |
# Assert task has changed/not changed OpenSearch domain |
| 85 |
- "opensearch_domain is changed" |
| 86 |
|
| 87 |
- name: Create public-facing OpenSearch cluster in check mode again |
| 88 |
opensearch: |
| 89 |
state: present |
| 90 |
domain_name: "es-{{ tiny_prefix }}-public" |
| 91 |
engine_version: "OpenSearch_1.1" |
| 92 |
cluster_config: |
| 93 |
instance_type: "t2.small.search" |
| 94 |
instance_count: 2 |
| 95 |
dedicated_master: false |
| 96 |
access_policies: "{{ lookup('file', 'opensearch_policy.json') | from_json }}" |
| 97 |
ebs_options: |
| 98 |
ebs_enabled: true |
| 99 |
volume_size: 10 |
| 100 |
tags: |
| 101 |
Name: "es-{{ tiny_prefix }}-public" |
| 102 |
Environment: Testing |
| 103 |
Application: Search |
| 104 |
AnsibleTest: "AnsibleTestOpenSearchCluster" |
| 105 |
check_mode: true |
| 106 |
register: opensearch_domain |
| 107 |
- assert: |
| 108 |
that: |
| 109 |
- opensearch_domain is not changed |
| 110 |
|
| 111 |
- name: Create public-facing OpenSearch cluster, no change expected |
| 112 |
opensearch: |
| 113 |
state: present |
| 114 |
domain_name: "es-{{ tiny_prefix }}-public" |
| 115 |
engine_version: "OpenSearch_1.1" |
| 116 |
cluster_config: |
| 117 |
instance_type: "t2.small.search" |
| 118 |
instance_count: 2 |
| 119 |
dedicated_master: false |
| 120 |
access_policies: "{{ lookup('file', 'opensearch_policy.json') | from_json }}" |
| 121 |
ebs_options: |
| 122 |
ebs_enabled: true |
| 123 |
volume_size: 10 |
| 124 |
tags: |
| 125 |
Name: "es-{{ tiny_prefix }}-public" |
| 126 |
Environment: Testing |
| 127 |
Application: Search |
| 128 |
AnsibleTest: "AnsibleTestOpenSearchCluster" |
| 129 |
register: opensearch_domain |
| 130 |
- assert: |
| 131 |
that: |
| 132 |
- opensearch_domain is not changed |
| 133 |
|
| 134 |
- name: Create VPC-attached OpenSearch cluster, check mode |
| 135 |
opensearch: |
| 136 |
state: present |
| 137 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 138 |
engine_version: "Elasticsearch_7.1" |
| 139 |
cluster_config: |
| 140 |
instance_type: "m5.large.search" |
| 141 |
instance_count: 2 |
| 142 |
zone_awareness: true |
| 143 |
availability_zone_count: 2 |
| 144 |
dedicated_master: true |
| 145 |
dedicated_master_instance_type: "m5.large.search" |
| 146 |
dedicated_master_instance_count: 3 |
| 147 |
ebs_options: |
| 148 |
ebs_enabled: true |
| 149 |
volume_type: "gp2" |
| 150 |
volume_size: 10 |
| 151 |
snapshot_options: |
| 152 |
automated_snapshot_start_hour: 12 |
| 153 |
access_policies: "{{ lookup('file', 'opensearch_policy.json') | from_json }}" |
| 154 |
vpc_options: |
| 155 |
subnets: |
| 156 |
- "{{ testing_subnet_1.subnet.id }}" |
| 157 |
- "{{ testing_subnet_2.subnet.id }}" |
| 158 |
security_groups: |
| 159 |
- "{{ sg.group_id }}" |
| 160 |
encryption_at_rest_options: |
| 161 |
enabled: false |
| 162 |
tags: |
| 163 |
Name: "es-{{ tiny_prefix }}-public" |
| 164 |
Environment: Testing |
| 165 |
Application: Search |
| 166 |
AnsibleTest: "AnsibleTestOpenSearchCluster" |
| 167 |
wait: true |
| 168 |
check_mode: true |
| 169 |
register: opensearch_domain |
| 170 |
- assert: |
| 171 |
that: |
| 172 |
- "opensearch_domain is changed" |
| 173 |
|
| 174 |
- name: Create VPC-attached OpenSearch cluster, change expected |
| 175 |
# Considerations for selecting node instances for test purpose: |
| 176 |
# 1) Low cost |
| 177 |
# 2) Supports encryption at rest, advanced security options, node-to-node encryption. |
| 178 |
# See https://docs.aws.amazon.com/opensearch-service/latest/developerguide/supported-instance-types.html |
| 179 |
opensearch: |
| 180 |
state: present |
| 181 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 182 |
engine_version: "Elasticsearch_7.1" |
| 183 |
cluster_config: |
| 184 |
instance_type: "m5.large.search" |
| 185 |
instance_count: 2 |
| 186 |
zone_awareness: true |
| 187 |
availability_zone_count: 2 |
| 188 |
dedicated_master: true |
| 189 |
dedicated_master_instance_type: "m5.large.search" |
| 190 |
dedicated_master_instance_count: 3 |
| 191 |
ebs_options: |
| 192 |
ebs_enabled: true |
| 193 |
volume_type: "gp2" |
| 194 |
volume_size: 10 |
| 195 |
snapshot_options: |
| 196 |
automated_snapshot_start_hour: 12 |
| 197 |
access_policies: "{{ lookup('file', 'opensearch_policy.json') | from_json }}" |
| 198 |
vpc_options: |
| 199 |
subnets: |
| 200 |
- "{{ testing_subnet_1.subnet.id }}" |
| 201 |
- "{{ testing_subnet_2.subnet.id }}" |
| 202 |
security_groups: |
| 203 |
- "{{ sg.group_id }}" |
| 204 |
encryption_at_rest_options: |
| 205 |
enabled: false |
| 206 |
tags: |
| 207 |
Name: "es-{{ tiny_prefix }}-public" |
| 208 |
Environment: Testing |
| 209 |
Application: Search |
| 210 |
AnsibleTest: "AnsibleTestOpenSearchCluster" |
| 211 |
wait: true |
| 212 |
# It could take about 45 minutes for the cluster to be created and available. |
| 213 |
wait_timeout: "{{ 45 * 60 }}" |
| 214 |
register: opensearch_domain |
| 215 |
- assert: |
| 216 |
that: |
| 217 |
- "opensearch_domain.tags | length == 4" |
| 218 |
- "opensearch_domain.engine_version == 'Elasticsearch_7.1'" |
| 219 |
- "opensearch_domain.cluster_config.instance_count == 2" |
| 220 |
- "opensearch_domain.cluster_config.instance_type == 'm5.large.search'" |
| 221 |
- "opensearch_domain.cluster_config.dedicated_master_enabled == true" |
| 222 |
- "opensearch_domain.cluster_config.dedicated_master_type == 'm5.large.search'" |
| 223 |
- "opensearch_domain.cluster_config.dedicated_master_count == 3" |
| 224 |
- "opensearch_domain.cluster_config.warm_enabled == false" |
| 225 |
- "opensearch_domain.cluster_config.zone_awareness_enabled == true" |
| 226 |
- "opensearch_domain.ebs_options.ebs_enabled == true" |
| 227 |
- "opensearch_domain.ebs_options.volume_size == 10" |
| 228 |
- "opensearch_domain.ebs_options.volume_type == 'gp2'" |
| 229 |
- "opensearch_domain.snapshot_options.automated_snapshot_start_hour == 12" |
| 230 |
- "opensearch_domain.vpc_options is defined" |
| 231 |
- "opensearch_domain.vpc_options.vpc_id is defined" |
| 232 |
- "opensearch_domain.vpc_options.vpc_id == testing_vpc.vpc.id" |
| 233 |
- "opensearch_domain.vpc_options.subnet_ids is defined" |
| 234 |
- "opensearch_domain.vpc_options.subnet_ids | length == 2" |
| 235 |
- "opensearch_domain.vpc_options.security_group_ids is defined" |
| 236 |
- "opensearch_domain.vpc_options.security_group_ids | length == 1" |
| 237 |
# Assert task has changed/not changed OpenSearch domain |
| 238 |
- "opensearch_domain is changed" |
| 239 |
|
| 240 |
- name: Create VPC-attached OpenSearch cluster, check mode again |
| 241 |
opensearch: |
| 242 |
state: present |
| 243 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 244 |
engine_version: "Elasticsearch_7.1" |
| 245 |
cluster_config: |
| 246 |
instance_type: "m5.large.search" |
| 247 |
instance_count: 2 |
| 248 |
zone_awareness: true |
| 249 |
availability_zone_count: 2 |
| 250 |
dedicated_master: true |
| 251 |
dedicated_master_instance_type: "m5.large.search" |
| 252 |
dedicated_master_instance_count: 3 |
| 253 |
ebs_options: |
| 254 |
ebs_enabled: true |
| 255 |
volume_type: "gp2" |
| 256 |
volume_size: 10 |
| 257 |
snapshot_options: |
| 258 |
automated_snapshot_start_hour: 12 |
| 259 |
access_policies: "{{ lookup('file', 'opensearch_policy.json') | from_json }}" |
| 260 |
vpc_options: |
| 261 |
subnets: |
| 262 |
- "{{ testing_subnet_1.subnet.id }}" |
| 263 |
- "{{ testing_subnet_2.subnet.id }}" |
| 264 |
security_groups: |
| 265 |
- "{{ sg.group_id }}" |
| 266 |
encryption_at_rest_options: |
| 267 |
enabled: false |
| 268 |
tags: |
| 269 |
Name: "es-{{ tiny_prefix }}-public" |
| 270 |
Environment: Testing |
| 271 |
Application: Search |
| 272 |
AnsibleTest: "AnsibleTestOpenSearchCluster" |
| 273 |
wait: true |
| 274 |
check_mode: true |
| 275 |
register: opensearch_domain |
| 276 |
- assert: |
| 277 |
that: |
| 278 |
- opensearch_domain is not changed |
| 279 |
|
| 280 |
- name: Create VPC-attached OpenSearch cluster, no change expected |
| 281 |
opensearch: |
| 282 |
state: present |
| 283 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 284 |
engine_version: "Elasticsearch_7.1" |
| 285 |
cluster_config: |
| 286 |
instance_type: "m5.large.search" |
| 287 |
instance_count: 2 |
| 288 |
zone_awareness: true |
| 289 |
availability_zone_count: 2 |
| 290 |
dedicated_master: true |
| 291 |
dedicated_master_instance_type: "m5.large.search" |
| 292 |
dedicated_master_instance_count: 3 |
| 293 |
ebs_options: |
| 294 |
ebs_enabled: true |
| 295 |
volume_type: "gp2" |
| 296 |
volume_size: 10 |
| 297 |
snapshot_options: |
| 298 |
automated_snapshot_start_hour: 12 |
| 299 |
access_policies: "{{ lookup('file', 'opensearch_policy.json') | from_json }}" |
| 300 |
vpc_options: |
| 301 |
subnets: |
| 302 |
- "{{ testing_subnet_1.subnet.id }}" |
| 303 |
- "{{ testing_subnet_2.subnet.id }}" |
| 304 |
security_groups: |
| 305 |
- "{{ sg.group_id }}" |
| 306 |
encryption_at_rest_options: |
| 307 |
enabled: false |
| 308 |
tags: |
| 309 |
Name: "es-{{ tiny_prefix }}-public" |
| 310 |
Environment: Testing |
| 311 |
Application: Search |
| 312 |
AnsibleTest: "AnsibleTestOpenSearchCluster" |
| 313 |
wait: true |
| 314 |
register: opensearch_domain |
| 315 |
- assert: |
| 316 |
that: |
| 317 |
- opensearch_domain is not changed |
| 318 |
|
| 319 |
- name: Get list of OpenSearch domains |
| 320 |
opensearch_info: |
| 321 |
tags: |
| 322 |
Environment: "Testing" |
| 323 |
Application: "Search" |
| 324 |
AnsibleTest: "AnsibleTestOpenSearchCluster" |
| 325 |
register: opensearch_domains_info |
| 326 |
- assert: |
| 327 |
that: |
| 328 |
- opensearch_domains_info.domains is defined |
| 329 |
- opensearch_domains_info.domains | length == 2 |
| 330 |
|
| 331 |
- name: Get OpenSearch domains matching domain name |
| 332 |
opensearch_info: |
| 333 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 334 |
register: opensearch_domains_info |
| 335 |
- assert: |
| 336 |
that: |
| 337 |
- opensearch_domains_info is not changed |
| 338 |
- opensearch_domains_info.domains is defined |
| 339 |
- opensearch_domains_info.domains | length == 1 |
| 340 |
- opensearch_domains_info.domains[0].domain_config is defined |
| 341 |
- opensearch_domains_info.domains[0].domain_status is defined |
| 342 |
# Even after waiting for the OpenSearch cluster to complete installation, |
| 343 |
# it may take a few additional minutes for the 'Endpoints' property |
| 344 |
# to be present in the AWS API. |
| 345 |
# See further down below. The same `opensearch_info` task is invoked |
| 346 |
# after running a task that takes time, and that time there is |
| 347 |
# an assert on the 'endpoint' property. |
| 348 |
#- opensearch_domains_info.domains[0].domain_status.endpoints is defined |
| 349 |
#- opensearch_domains_info.domains[0].domain_status.endpoints.vpc is defined |
| 350 |
|
| 351 |
- name: Tag Opensearch domain, check mode |
| 352 |
opensearch: |
| 353 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 354 |
tags: |
| 355 |
Name: "es-{{ tiny_prefix }}-public" |
| 356 |
Environment: Testing |
| 357 |
tag_a: 'value 1' |
| 358 |
Application: Search |
| 359 |
AnsibleTest: "AnsibleTestOpenSearchCluster" |
| 360 |
wait: true |
| 361 |
check_mode: true |
| 362 |
register: opensearch_domain |
| 363 |
- assert: |
| 364 |
that: |
| 365 |
- opensearch_domain is changed |
| 366 |
|
| 367 |
- name: Tag Opensearch domain, expect changes |
| 368 |
opensearch: |
| 369 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 370 |
tags: |
| 371 |
Name: "es-{{ tiny_prefix }}-public" |
| 372 |
Environment: Testing |
| 373 |
tag_a: 'value 1' |
| 374 |
Application: Search |
| 375 |
AnsibleTest: "AnsibleTestOpenSearchCluster" |
| 376 |
wait: true |
| 377 |
register: opensearch_domain |
| 378 |
- assert: |
| 379 |
that: |
| 380 |
- "opensearch_domain.tags | length == 5" |
| 381 |
- opensearch_domain is changed |
| 382 |
|
| 383 |
- name: Tag Opensearch domain, check mode again |
| 384 |
opensearch: |
| 385 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 386 |
tags: |
| 387 |
Name: "es-{{ tiny_prefix }}-public" |
| 388 |
Environment: Testing |
| 389 |
tag_a: 'value 1' |
| 390 |
Application: Search |
| 391 |
AnsibleTest: "AnsibleTestOpenSearchCluster" |
| 392 |
wait: true |
| 393 |
check_mode: true |
| 394 |
register: opensearch_domain |
| 395 |
- assert: |
| 396 |
that: |
| 397 |
- opensearch_domain is not changed |
| 398 |
|
| 399 |
- name: Tag Opensearch domain, expect no change |
| 400 |
opensearch: |
| 401 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 402 |
tags: |
| 403 |
Name: "es-{{ tiny_prefix }}-public" |
| 404 |
Environment: Testing |
| 405 |
tag_a: 'value 1' |
| 406 |
Application: Search |
| 407 |
AnsibleTest: "AnsibleTestOpenSearchCluster" |
| 408 |
wait: true |
| 409 |
register: opensearch_domain |
| 410 |
- assert: |
| 411 |
that: |
| 412 |
- "opensearch_domain.tags | length == 5" |
| 413 |
- opensearch_domain is not changed |
| 414 |
|
| 415 |
- name: Add tag_b to Opensearch domain without purging, check mode |
| 416 |
opensearch: |
| 417 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 418 |
tags: |
| 419 |
tag_b: 'value 2' |
| 420 |
purge_tags: false |
| 421 |
wait: true |
| 422 |
check_mode: true |
| 423 |
register: opensearch_domain |
| 424 |
- assert: |
| 425 |
that: |
| 426 |
- opensearch_domain is changed |
| 427 |
|
| 428 |
- name: Add tag_b to Opensearch domain without purging |
| 429 |
opensearch: |
| 430 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 431 |
tags: |
| 432 |
tag_b: 'value 2' |
| 433 |
purge_tags: false |
| 434 |
wait: true |
| 435 |
register: opensearch_domain |
| 436 |
- assert: |
| 437 |
that: |
| 438 |
- "opensearch_domain.tags | length == 6" |
| 439 |
- opensearch_domain is changed |
| 440 |
|
| 441 |
- name: Add tag_b to Opensearch domain without purging, check mode again |
| 442 |
opensearch: |
| 443 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 444 |
tags: |
| 445 |
tag_b: 'value 2' |
| 446 |
purge_tags: false |
| 447 |
wait: true |
| 448 |
check_mode: true |
| 449 |
register: opensearch_domain |
| 450 |
- assert: |
| 451 |
that: |
| 452 |
- opensearch_domain is not changed |
| 453 |
|
| 454 |
- name: Add tag_b to Opensearch domain without purging, no change expected |
| 455 |
opensearch: |
| 456 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 457 |
tags: |
| 458 |
tag_b: 'value 2' |
| 459 |
purge_tags: false |
| 460 |
wait: true |
| 461 |
register: opensearch_domain |
| 462 |
- assert: |
| 463 |
that: |
| 464 |
- "opensearch_domain.tags | length == 6" |
| 465 |
- opensearch_domain is not changed |
| 466 |
|
| 467 |
- name: Set tags to Opensearch domain and purge tags, check mode |
| 468 |
opensearch: |
| 469 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 470 |
tags: |
| 471 |
Name: "es-{{ tiny_prefix }}-public" |
| 472 |
Environment: Testing |
| 473 |
Application: Search |
| 474 |
AnsibleTest: "AnsibleTestOpenSearchCluster" |
| 475 |
purge_tags: true |
| 476 |
wait: true |
| 477 |
check_mode: true |
| 478 |
register: opensearch_domain |
| 479 |
- assert: |
| 480 |
that: |
| 481 |
- opensearch_domain is changed |
| 482 |
|
| 483 |
- name: Set tags to Opensearch domain and purge tags |
| 484 |
opensearch: |
| 485 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 486 |
tags: |
| 487 |
Name: "es-{{ tiny_prefix }}-public" |
| 488 |
Environment: Testing |
| 489 |
Application: Search |
| 490 |
AnsibleTest: "AnsibleTestOpenSearchCluster" |
| 491 |
purge_tags: true |
| 492 |
wait: true |
| 493 |
register: opensearch_domain |
| 494 |
- assert: |
| 495 |
that: |
| 496 |
- "opensearch_domain.tags | length == 4" |
| 497 |
- opensearch_domain is changed |
| 498 |
|
| 499 |
- name: Set tags to Opensearch domain and purge tags, check mode again |
| 500 |
opensearch: |
| 501 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 502 |
tags: |
| 503 |
Name: "es-{{ tiny_prefix }}-public" |
| 504 |
Environment: Testing |
| 505 |
Application: Search |
| 506 |
AnsibleTest: "AnsibleTestOpenSearchCluster" |
| 507 |
purge_tags: true |
| 508 |
wait: true |
| 509 |
check_mode: true |
| 510 |
register: opensearch_domain |
| 511 |
- assert: |
| 512 |
that: |
| 513 |
- opensearch_domain is not changed |
| 514 |
|
| 515 |
- name: Set tags to Opensearch domain and purge tags, no change expected |
| 516 |
opensearch: |
| 517 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 518 |
tags: |
| 519 |
Name: "es-{{ tiny_prefix }}-public" |
| 520 |
Environment: Testing |
| 521 |
Application: Search |
| 522 |
AnsibleTest: "AnsibleTestOpenSearchCluster" |
| 523 |
purge_tags: true |
| 524 |
wait: true |
| 525 |
register: opensearch_domain |
| 526 |
- assert: |
| 527 |
that: |
| 528 |
- "opensearch_domain.tags | length == 4" |
| 529 |
- opensearch_domain is not changed |
| 530 |
|
| 531 |
- name: Change EBS storage configuration, snapshot hour, instance count |
| 532 |
block: |
| 533 |
- name: Increase size of EBS volumes, check mode |
| 534 |
opensearch: |
| 535 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 536 |
ebs_options: |
| 537 |
volume_size: 12 |
| 538 |
wait: true |
| 539 |
check_mode: true |
| 540 |
register: opensearch_domain |
| 541 |
- assert: |
| 542 |
that: |
| 543 |
- opensearch_domain is changed |
| 544 |
|
| 545 |
- name: Increase size of EBS volumes, expect changes |
| 546 |
opensearch: |
| 547 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 548 |
ebs_options: |
| 549 |
volume_size: 12 |
| 550 |
wait: true |
| 551 |
# It could take 20 minutes to increase the size of the EBS volumes |
| 552 |
wait_timeout: "{{ 30 * 60 }}" |
| 553 |
register: opensearch_domain |
| 554 |
- assert: |
| 555 |
that: |
| 556 |
- "opensearch_domain.ebs_options.volume_size == 12" |
| 557 |
- opensearch_domain is changed |
| 558 |
|
| 559 |
- name: Increase size of EBS volumes, check mode again |
| 560 |
opensearch: |
| 561 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 562 |
ebs_options: |
| 563 |
volume_size: 12 |
| 564 |
wait: true |
| 565 |
check_mode: true |
| 566 |
register: opensearch_domain |
| 567 |
- assert: |
| 568 |
that: |
| 569 |
- opensearch_domain is not changed |
| 570 |
|
| 571 |
- name: Increase size of EBS volumes, expect no change |
| 572 |
opensearch: |
| 573 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 574 |
ebs_options: |
| 575 |
volume_size: 12 |
| 576 |
wait: true |
| 577 |
register: opensearch_domain |
| 578 |
- assert: |
| 579 |
that: |
| 580 |
- "opensearch_domain.ebs_options.volume_size == 12" |
| 581 |
- opensearch_domain is not changed |
| 582 |
|
| 583 |
- name: Get OpenSearch domains matching domain name |
| 584 |
opensearch_info: |
| 585 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 586 |
register: opensearch_domains_info |
| 587 |
- assert: |
| 588 |
that: |
| 589 |
- opensearch_domains_info is not changed |
| 590 |
- opensearch_domains_info.domains is defined |
| 591 |
- opensearch_domains_info.domains | length == 1 |
| 592 |
- opensearch_domains_info.domains[0].domain_config is defined |
| 593 |
- opensearch_domains_info.domains[0].domain_status is defined |
| 594 |
# Even after waiting for the OpenSearch cluster to complete installation, |
| 595 |
# it may take a few additional minutes for the 'Endpoints' property |
| 596 |
# to be present in the AWS API. |
| 597 |
- opensearch_domains_info.domains[0].domain_status.endpoints is defined |
| 598 |
- opensearch_domains_info.domains[0].domain_status.endpoints.vpc is defined |
| 599 |
|
| 600 |
- name: Set fact for OpenSearch endpoint FQDN in the VPC |
| 601 |
set_fact: |
| 602 |
opensearch_vpc_fqdn: "{{ opensearch_domains_info.domains[0].domain_status.endpoints.vpc }}" |
| 603 |
|
| 604 |
# Create a Route53 CNAME record. |
| 605 |
# This CNAME record will be used when configuring a custom endpoint |
| 606 |
# for the OpenSearch cluster. |
| 607 |
- name: Create CNAME record for the OpenSearch custom endpoint |
| 608 |
route53: |
| 609 |
state: present |
| 610 |
hosted_zone_id: "{{ route53_zone_id }}" |
| 611 |
record: "opensearch.ansible-integ-test.com" |
| 612 |
private_zone: true |
| 613 |
type: CNAME |
| 614 |
value: "{{ opensearch_vpc_fqdn }}" |
| 615 |
|
| 616 |
- name: Change snapshot start hour, check mode |
| 617 |
opensearch: |
| 618 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 619 |
snapshot_options: |
| 620 |
automated_snapshot_start_hour: 3 |
| 621 |
wait: true |
| 622 |
check_mode: true |
| 623 |
register: opensearch_domain |
| 624 |
- assert: |
| 625 |
that: |
| 626 |
- opensearch_domain is changed |
| 627 |
|
| 628 |
- name: Change snapshot start hour |
| 629 |
opensearch: |
| 630 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 631 |
snapshot_options: |
| 632 |
automated_snapshot_start_hour: 3 |
| 633 |
wait: true |
| 634 |
register: opensearch_domain |
| 635 |
- assert: |
| 636 |
that: |
| 637 |
- "opensearch_domain.snapshot_options.automated_snapshot_start_hour == 3" |
| 638 |
- opensearch_domain is changed |
| 639 |
|
| 640 |
- name: Change snapshot start hour, check mode again |
| 641 |
opensearch: |
| 642 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 643 |
snapshot_options: |
| 644 |
automated_snapshot_start_hour: 3 |
| 645 |
wait: true |
| 646 |
check_mode: true |
| 647 |
register: opensearch_domain |
| 648 |
- assert: |
| 649 |
that: |
| 650 |
- opensearch_domain is not changed |
| 651 |
|
| 652 |
- name: Change snapshot start hour, no change expected |
| 653 |
opensearch: |
| 654 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 655 |
snapshot_options: |
| 656 |
automated_snapshot_start_hour: 3 |
| 657 |
wait: true |
| 658 |
register: opensearch_domain |
| 659 |
- assert: |
| 660 |
that: |
| 661 |
- opensearch_domain is not changed |
| 662 |
|
| 663 |
- name: Set instance count to 4 in the OpenSearch cluster, check mode |
| 664 |
opensearch: |
| 665 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 666 |
cluster_config: |
| 667 |
# It's a 2-AZ deployment, therefore the node count must be even. |
| 668 |
instance_count: 4 |
| 669 |
wait: true |
| 670 |
check_mode: true |
| 671 |
register: opensearch_domain |
| 672 |
- assert: |
| 673 |
that: |
| 674 |
- opensearch_domain is changed |
| 675 |
|
| 676 |
- name: Set instance count to 4 in the OpenSearch cluster, changes expected |
| 677 |
opensearch: |
| 678 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 679 |
cluster_config: |
| 680 |
# It's a 2-AZ deployment, therefore the node count must be even. |
| 681 |
instance_count: 4 |
| 682 |
wait: true |
| 683 |
# It could take 20 minutes to increase the number of nodes in the cluster |
| 684 |
wait_timeout: "{{ 30 * 60 }}" |
| 685 |
register: opensearch_domain |
| 686 |
- assert: |
| 687 |
that: |
| 688 |
- "opensearch_domain.cluster_config.instance_count == 4" |
| 689 |
- opensearch_domain is changed |
| 690 |
|
| 691 |
- name: Set instance count to 4 in the OpenSearch cluster, check mode again |
| 692 |
opensearch: |
| 693 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 694 |
cluster_config: |
| 695 |
# It's a 2-AZ deployment, therefore the node count must be even. |
| 696 |
instance_count: 4 |
| 697 |
wait: true |
| 698 |
check_mode: true |
| 699 |
register: opensearch_domain |
| 700 |
- assert: |
| 701 |
that: |
| 702 |
- opensearch_domain is not changed |
| 703 |
|
| 704 |
- name: Set instance count to 4 in the OpenSearch cluster, no change expected |
| 705 |
opensearch: |
| 706 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 707 |
cluster_config: |
| 708 |
# It's a 2-AZ deployment, therefore the node count must be even. |
| 709 |
instance_count: 4 |
| 710 |
wait: true |
| 711 |
register: opensearch_domain |
| 712 |
- assert: |
| 713 |
that: |
| 714 |
- opensearch_domain is not changed |
| 715 |
|
| 716 |
- name: Set instance count to 2 in the OpenSearch cluster, check mode |
| 717 |
opensearch: |
| 718 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 719 |
cluster_config: |
| 720 |
instance_count: 2 |
| 721 |
wait: true |
| 722 |
check_mode: true |
| 723 |
register: opensearch_domain |
| 724 |
- assert: |
| 725 |
that: |
| 726 |
- opensearch_domain is changed |
| 727 |
|
| 728 |
- name: Set instance count to 2 in the OpenSearch cluster, changes expected |
| 729 |
opensearch: |
| 730 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 731 |
cluster_config: |
| 732 |
instance_count: 2 |
| 733 |
wait: true |
| 734 |
# It could take 20 minutes to decrease the number of nodes in the cluster |
| 735 |
wait_timeout: "{{ 30 * 60 }}" |
| 736 |
register: opensearch_domain |
| 737 |
- assert: |
| 738 |
that: |
| 739 |
- "opensearch_domain.cluster_config.instance_count == 2" |
| 740 |
- opensearch_domain is changed |
| 741 |
|
| 742 |
- name: Set instance count to 2 in the OpenSearch cluster, check mode again |
| 743 |
opensearch: |
| 744 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 745 |
cluster_config: |
| 746 |
instance_count: 2 |
| 747 |
wait: true |
| 748 |
check_mode: true |
| 749 |
register: opensearch_domain |
| 750 |
- assert: |
| 751 |
that: |
| 752 |
- opensearch_domain is not changed |
| 753 |
|
| 754 |
- name: Set instance count to 2 in the OpenSearch cluster, no change expected |
| 755 |
opensearch: |
| 756 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 757 |
cluster_config: |
| 758 |
instance_count: 2 |
| 759 |
wait: true |
| 760 |
register: opensearch_domain |
| 761 |
- assert: |
| 762 |
that: |
| 763 |
- "opensearch_domain.cluster_config.instance_count == 2" |
| 764 |
- opensearch_domain is not changed |
| 765 |
|
| 766 |
- name: Upgrade OpenSearch cluster |
| 767 |
block: |
| 768 |
- name: Upgrade OpenSearch cluster, check mode |
| 769 |
opensearch: |
| 770 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 771 |
engine_version: "Elasticsearch_7.10" |
| 772 |
check_mode: true |
| 773 |
register: opensearch_domain |
| 774 |
- assert: |
| 775 |
that: |
| 776 |
- opensearch_domain is changed |
| 777 |
|
| 778 |
- name: Upgrade OpenSearch cluster, change expected |
| 779 |
# Upgrade from version 7.1 to version 7.10. |
| 780 |
opensearch: |
| 781 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 782 |
engine_version: "Elasticsearch_7.10" |
| 783 |
wait: true |
| 784 |
# It could take 40 minutes to upgrade the cluster |
| 785 |
wait_timeout: "{{ 50 * 60 }}" |
| 786 |
register: opensearch_domain |
| 787 |
- assert: |
| 788 |
that: |
| 789 |
- "opensearch_domain.engine_version == 'Elasticsearch_7.10'" |
| 790 |
- "opensearch_domain.cluster_config.instance_count == 2" |
| 791 |
- opensearch_domain is changed |
| 792 |
|
| 793 |
- name: Upgrade OpenSearch cluster, check mode again |
| 794 |
opensearch: |
| 795 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 796 |
engine_version: "Elasticsearch_7.10" |
| 797 |
check_mode: true |
| 798 |
register: opensearch_domain |
| 799 |
- assert: |
| 800 |
that: |
| 801 |
- opensearch_domain is not changed |
| 802 |
|
| 803 |
- name: Upgrade OpenSearch cluster, no change expected |
| 804 |
opensearch: |
| 805 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 806 |
engine_version: "Elasticsearch_7.10" |
| 807 |
register: opensearch_domain |
| 808 |
- assert: |
| 809 |
that: |
| 810 |
- "opensearch_domain.engine_version == 'Elasticsearch_7.10'" |
| 811 |
- "opensearch_domain.cluster_config.instance_count == 2" |
| 812 |
- opensearch_domain is not changed |
| 813 |
|
| 814 |
- name: Configure encryption |
| 815 |
when: false |
| 816 |
block: |
| 817 |
- name: Enable node to node encryption, check mode |
| 818 |
opensearch: |
| 819 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 820 |
node_to_node_encryption_options: |
| 821 |
enabled: true |
| 822 |
wait: true |
| 823 |
check_mode: true |
| 824 |
register: opensearch_domain |
| 825 |
- assert: |
| 826 |
that: |
| 827 |
- opensearch_domain is changed |
| 828 |
|
| 829 |
- name: Enable node to node encryption, change expected |
| 830 |
opensearch: |
| 831 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 832 |
node_to_node_encryption_options: |
| 833 |
enabled: true |
| 834 |
wait: true |
| 835 |
# This may take a long time. |
| 836 |
wait_timeout: "{{ 60 * 60 }}" |
| 837 |
register: opensearch_domain |
| 838 |
- assert: |
| 839 |
that: |
| 840 |
- "opensearch_domain.node_to_node_encryption_options.enabled == True" |
| 841 |
- opensearch_domain is changed |
| 842 |
|
| 843 |
- name: Enable node to node encryption, check mode again |
| 844 |
opensearch: |
| 845 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 846 |
node_to_node_encryption_options: |
| 847 |
enabled: true |
| 848 |
wait: true |
| 849 |
check_mode: true |
| 850 |
register: opensearch_domain |
| 851 |
- assert: |
| 852 |
that: |
| 853 |
- opensearch_domain is not changed |
| 854 |
|
| 855 |
- name: Enable node to node encryption, no change expected |
| 856 |
opensearch: |
| 857 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 858 |
node_to_node_encryption_options: |
| 859 |
enabled: true |
| 860 |
wait: true |
| 861 |
register: opensearch_domain |
| 862 |
- assert: |
| 863 |
that: |
| 864 |
- "opensearch_domain.node_to_node_encryption_options.enabled == True" |
| 865 |
- opensearch_domain is not changed |
| 866 |
|
| 867 |
- name: Enable encryption at rest, check mode |
| 868 |
opensearch: |
| 869 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 870 |
encryption_at_rest_options: |
| 871 |
enabled: true |
| 872 |
#kms_key_id: "{{ kms_test_key.key_id }}" |
| 873 |
wait: true |
| 874 |
check_mode: true |
| 875 |
register: opensearch_domain |
| 876 |
- assert: |
| 877 |
that: |
| 878 |
- opensearch_domain is changed |
| 879 |
|
| 880 |
- name: Enable encryption at rest, change expected |
| 881 |
opensearch: |
| 882 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 883 |
encryption_at_rest_options: |
| 884 |
enabled: true |
| 885 |
# key ARN has the format: |
| 886 |
# 'arn:aws:kms:{{region}}:{{account}}:key/{{key_id}}' |
| 887 |
# The API docs indicate the value is the KMS key id, which works |
| 888 |
# However, the KMS key ARN seems to be a better option because |
| 889 |
# the AWS API actually returns the KMS key ARN. |
| 890 |
|
| 891 |
# Do not set 'kms_key_id' to let AWS manage the key. |
| 892 |
#kms_key_id: "{{ kms_test_key.key_arn }}" |
| 893 |
wait: true |
| 894 |
# It may take a long time for the task to complete. |
| 895 |
wait_timeout: "{{ 60 * 60 }}" |
| 896 |
register: opensearch_domain |
| 897 |
- assert: |
| 898 |
that: |
| 899 |
- "opensearch_domain.encryption_at_rest_options.enabled == True" |
| 900 |
- opensearch_domain is changed |
| 901 |
|
| 902 |
- name: Enable encryption at rest, check mode again |
| 903 |
opensearch: |
| 904 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 905 |
encryption_at_rest_options: |
| 906 |
enabled: true |
| 907 |
#kms_key_id: "{{ kms_test_key.key_arn }}" |
| 908 |
wait: true |
| 909 |
check_mode: true |
| 910 |
register: opensearch_domain |
| 911 |
- assert: |
| 912 |
that: |
| 913 |
- opensearch_domain is not changed |
| 914 |
|
| 915 |
- name: Enable encryption at rest, no change expected |
| 916 |
opensearch: |
| 917 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 918 |
encryption_at_rest_options: |
| 919 |
enabled: true |
| 920 |
#kms_key_id: "{{ kms_test_key.key_arn }}" |
| 921 |
wait: true |
| 922 |
register: opensearch_domain |
| 923 |
- assert: |
| 924 |
that: |
| 925 |
- opensearch_domain is not changed |
| 926 |
|
| 927 |
- name: Configure HTTPs endpoint |
| 928 |
when: false |
| 929 |
block: |
| 930 |
- name: Enforce HTTPS for OpenSearch endpoint, check mode |
| 931 |
opensearch: |
| 932 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 933 |
domain_endpoint_options: |
| 934 |
enforce_https: true |
| 935 |
tls_security_policy: "Policy-Min-TLS-1-0-2019-07" |
| 936 |
wait: true |
| 937 |
check_mode: true |
| 938 |
register: opensearch_domain |
| 939 |
- assert: |
| 940 |
that: |
| 941 |
- opensearch_domain is changed |
| 942 |
|
| 943 |
- name: Enforce HTTPS for OpenSearch endpoint, changes expected |
| 944 |
opensearch: |
| 945 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 946 |
domain_endpoint_options: |
| 947 |
enforce_https: true |
| 948 |
tls_security_policy: "Policy-Min-TLS-1-0-2019-07" |
| 949 |
# Refer to CNAME that was defined in the previous tasks. |
| 950 |
custom_endpoint_enabled: true |
| 951 |
custom_endpoint: "opensearch.ansible-integ-test.com" |
| 952 |
# TODO: create a certificate. There is a dependency on the aws_acm module |
| 953 |
# which does not support certificates issued by AWS. |
| 954 |
# The OpenSearch endpoint should have a certificate issued by a trusted CA |
| 955 |
# otherwise clients to the OpenSearch cluster will not be able to validate |
| 956 |
# the x.509 certificate of the OpenSearch endpoint. |
| 957 |
custom_endpoint_certificate_arn: "{{ opensearch_certificate_arn }}" |
| 958 |
wait: true |
| 959 |
wait_timeout: "{{ 60 * 60 }}" |
| 960 |
register: opensearch_domain |
| 961 |
until: opensearch_domain is not failed |
| 962 |
ignore_errors: true |
| 963 |
retries: 10 |
| 964 |
# After enabling at rest encryption, there is a period during which the API fails, so retry. |
| 965 |
delay: 30 |
| 966 |
- assert: |
| 967 |
that: |
| 968 |
- "opensearch_domain.domain_endpoint_options.enforce_https == True" |
| 969 |
- "opensearch_domain.domain_endpoint_options.tls_security_policy == 'Policy-Min-TLS-1-0-2019-07'" |
| 970 |
#- "opensearch_domain.domain_endpoint_options.custom_endpoint_enabled == True" |
| 971 |
- opensearch_domain is changed |
| 972 |
|
| 973 |
- name: Change TLS policy, check mode |
| 974 |
opensearch: |
| 975 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 976 |
domain_endpoint_options: |
| 977 |
tls_security_policy: "Policy-Min-TLS-1-2-2019-07" |
| 978 |
wait: true |
| 979 |
check_mode: true |
| 980 |
register: opensearch_domain |
| 981 |
- assert: |
| 982 |
that: |
| 983 |
- opensearch_domain is changed |
| 984 |
|
| 985 |
- name: Change TLS policy, change expected |
| 986 |
opensearch: |
| 987 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 988 |
domain_endpoint_options: |
| 989 |
tls_security_policy: "Policy-Min-TLS-1-2-2019-07" |
| 990 |
wait: true |
| 991 |
wait_timeout: "{{ 60 * 60 }}" |
| 992 |
register: opensearch_domain |
| 993 |
- assert: |
| 994 |
that: |
| 995 |
- "opensearch_domain.domain_endpoint_options.enforce_https == True" |
| 996 |
- "opensearch_domain.domain_endpoint_options.tls_security_policy == 'Policy-Min-TLS-1-2-2019-07'" |
| 997 |
- opensearch_domain is changed |
| 998 |
|
| 999 |
- name: Set common facts for advanced security tests |
| 1000 |
set_fact: |
| 1001 |
test_master_user_name: my_custom_admin_username |
| 1002 |
test_master_user_password: "{{ lookup('ansible.builtin.password', '/dev/null chars=ascii_lowercase,digits length=16') }}" |
| 1003 |
|
| 1004 |
- name: Configure advanced security |
| 1005 |
block: |
| 1006 |
- name: Enable advanced security, check mode |
| 1007 |
opensearch: |
| 1008 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 1009 |
advanced_security_options: |
| 1010 |
enabled: true |
| 1011 |
internal_user_database_enabled: false |
| 1012 |
master_user_options: |
| 1013 |
master_user_name: "{{ test_master_user_name }}" |
| 1014 |
master_user_password: "{{ test_master_user_password }}" |
| 1015 |
wait: true |
| 1016 |
check_mode: true |
| 1017 |
register: opensearch_domain |
| 1018 |
- assert: |
| 1019 |
that: |
| 1020 |
- opensearch_domain is changed |
| 1021 |
|
| 1022 |
# Pre-requisites before enabling advanced security options: |
| 1023 |
# 1) node-to-node encryption must be enabled. |
| 1024 |
# 2) encryption at rest to must be enabled. |
| 1025 |
# 3) Enforce HTTPS in the domain endpoint options. |
| 1026 |
- name: Enable advanced security, change expected |
| 1027 |
opensearch: |
| 1028 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 1029 |
advanced_security_options: |
| 1030 |
enabled: true |
| 1031 |
internal_user_database_enabled: false |
| 1032 |
master_user_options: |
| 1033 |
master_user_name: "{{ test_master_user_name }}" |
| 1034 |
master_user_password: "{{ test_master_user_password }}" |
| 1035 |
wait: true |
| 1036 |
wait_timeout: "{{ 60 * 60 }}" |
| 1037 |
register: opensearch_domain |
| 1038 |
- assert: |
| 1039 |
that: |
| 1040 |
- "opensearch_domain.advanced_security_options.enabled == True" |
| 1041 |
- "opensearch_domain.advanced_security_options.internal_user_database_enabled == False" |
| 1042 |
- "opensearch_domain.advanced_security_options.master_user_options is defined" |
| 1043 |
- "opensearch_domain.advanced_security_options.master_user_options.master_user_name is test_master_user_name" |
| 1044 |
- "opensearch_domain.advanced_security_options.master_user_options.master_user_password is test_master_user_password" |
| 1045 |
- opensearch_domain is changed |
| 1046 |
|
| 1047 |
- name: Enable advanced security, check mode again |
| 1048 |
opensearch: |
| 1049 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 1050 |
advanced_security_options: |
| 1051 |
enabled: true |
| 1052 |
internal_user_database_enabled: false |
| 1053 |
master_user_options: |
| 1054 |
master_user_name: "{{ test_master_user_name }}" |
| 1055 |
master_user_password: "{{ test_master_user_password }}" |
| 1056 |
wait: true |
| 1057 |
check_mode: true |
| 1058 |
register: opensearch_domain |
| 1059 |
- assert: |
| 1060 |
that: |
| 1061 |
- opensearch_domain is not changed |
| 1062 |
|
| 1063 |
- name: Enable advanced security, no change expected |
| 1064 |
opensearch: |
| 1065 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 1066 |
advanced_security_options: |
| 1067 |
enabled: true |
| 1068 |
internal_user_database_enabled: false |
| 1069 |
master_user_options: |
| 1070 |
master_user_name: "{{ test_master_user_name }}" |
| 1071 |
master_user_password: "{{ test_master_user_password }}" |
| 1072 |
wait: true |
| 1073 |
register: opensearch_domain |
| 1074 |
- assert: |
| 1075 |
that: |
| 1076 |
- "opensearch_domain.advanced_security_options.enabled == True" |
| 1077 |
- "opensearch_domain.advanced_security_options.internal_user_database_enabled == False" |
| 1078 |
- "opensearch_domain.advanced_security_options.master_user_options is defined" |
| 1079 |
- "opensearch_domain.advanced_security_options.master_user_options.master_user_name is test_master_user_name" |
| 1080 |
- "opensearch_domain.advanced_security_options.master_user_options.master_user_password is test_master_user_password" |
| 1081 |
- opensearch_domain is not changed |
| 1082 |
|
| 1083 |
- name: Configure warm and cold storage |
| 1084 |
block: |
| 1085 |
- name: Enable warm storage in check mode |
| 1086 |
opensearch: |
| 1087 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 1088 |
cluster_config: |
| 1089 |
warm_enabled: true |
| 1090 |
warm_type: "ultrawarm1.medium.search" |
| 1091 |
warm_count: 2 |
| 1092 |
wait: true |
| 1093 |
check_mode: true |
| 1094 |
register: opensearch_domain |
| 1095 |
- assert: |
| 1096 |
that: |
| 1097 |
- opensearch_domain is changed |
| 1098 |
|
| 1099 |
- name: Enable warm storage, change expected |
| 1100 |
opensearch: |
| 1101 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 1102 |
cluster_config: |
| 1103 |
warm_enabled: true |
| 1104 |
warm_type: "ultrawarm1.medium.search" |
| 1105 |
warm_count: 2 |
| 1106 |
wait: true |
| 1107 |
# Adding warm storage may take a long time. |
| 1108 |
wait_timeout: "{{ 45 * 60 }}" |
| 1109 |
register: opensearch_domain |
| 1110 |
- assert: |
| 1111 |
that: |
| 1112 |
- "opensearch_domain.cluster_config.warm_enabled == True" |
| 1113 |
- "opensearch_domain.cluster_config.warm_count == 2" |
| 1114 |
- "opensearch_domain.cluster_config.warm_type == 'ultrawarm1.medium.search'" |
| 1115 |
- opensearch_domain is changed |
| 1116 |
|
| 1117 |
- name: Enable warm storage in check mode again |
| 1118 |
opensearch: |
| 1119 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 1120 |
cluster_config: |
| 1121 |
warm_enabled: true |
| 1122 |
warm_type: "ultrawarm1.medium.search" |
| 1123 |
warm_count: 2 |
| 1124 |
wait: true |
| 1125 |
check_mode: true |
| 1126 |
register: opensearch_domain |
| 1127 |
- assert: |
| 1128 |
that: |
| 1129 |
- opensearch_domain is not changed |
| 1130 |
|
| 1131 |
- name: Enable warm storage, no change expected |
| 1132 |
opensearch: |
| 1133 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 1134 |
cluster_config: |
| 1135 |
warm_enabled: true |
| 1136 |
warm_type: "ultrawarm1.medium.search" |
| 1137 |
warm_count: 2 |
| 1138 |
wait: true |
| 1139 |
register: opensearch_domain |
| 1140 |
- assert: |
| 1141 |
that: |
| 1142 |
- "opensearch_domain.cluster_config.warm_enabled == True" |
| 1143 |
- "opensearch_domain.cluster_config.warm_count == 2" |
| 1144 |
- opensearch_domain is not changed |
| 1145 |
|
| 1146 |
- name: Enable cold storage in check mode |
| 1147 |
opensearch: |
| 1148 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 1149 |
cluster_config: |
| 1150 |
cold_storage_options: |
| 1151 |
enabled: true |
| 1152 |
wait: true |
| 1153 |
check_mode: true |
| 1154 |
register: opensearch_domain |
| 1155 |
- assert: |
| 1156 |
that: |
| 1157 |
- opensearch_domain is changed |
| 1158 |
|
| 1159 |
- name: Enable cold storage, change expected |
| 1160 |
opensearch: |
| 1161 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 1162 |
cluster_config: |
| 1163 |
cold_storage_options: |
| 1164 |
enabled: true |
| 1165 |
wait: true |
| 1166 |
# Adding cold storage may take a long time. |
| 1167 |
wait_timeout: "{{ 45 * 60 }}" |
| 1168 |
register: opensearch_domain |
| 1169 |
- assert: |
| 1170 |
that: |
| 1171 |
- "opensearch_domain.cluster_config.cold_storage_options.enabled == True" |
| 1172 |
- opensearch_domain is changed |
| 1173 |
|
| 1174 |
- name: Enable cold storage in check mode again |
| 1175 |
opensearch: |
| 1176 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 1177 |
cluster_config: |
| 1178 |
cold_storage_options: |
| 1179 |
enabled: true |
| 1180 |
wait: true |
| 1181 |
check_mode: true |
| 1182 |
register: opensearch_domain |
| 1183 |
- assert: |
| 1184 |
that: |
| 1185 |
- opensearch_domain is not changed |
| 1186 |
|
| 1187 |
- name: Enable cold storage, no change expected |
| 1188 |
opensearch: |
| 1189 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 1190 |
cluster_config: |
| 1191 |
cold_storage_options: |
| 1192 |
enabled: true |
| 1193 |
wait: true |
| 1194 |
register: opensearch_domain |
| 1195 |
- assert: |
| 1196 |
that: |
| 1197 |
- "opensearch_domain.cluster_config.cold_storage_options.enabled == True" |
| 1198 |
- opensearch_domain is not changed |
| 1199 |
|
| 1200 |
- name: Configure auto-tune options |
| 1201 |
block: |
| 1202 |
- name: Enable auto-tune options in check mode |
| 1203 |
opensearch: |
| 1204 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 1205 |
auto_tune_options: |
| 1206 |
desired_state: "ENABLED" |
| 1207 |
maintenance_schedules: |
| 1208 |
- start_at: "{{ ansible_date_time.year|int + 1 }}-01-01" |
| 1209 |
duration: |
| 1210 |
value: 10 |
| 1211 |
unit: "HOURS" |
| 1212 |
cron_expression_for_recurrence: "cron(0 12 * * ? *)" |
| 1213 |
wait: true |
| 1214 |
check_mode: true |
| 1215 |
register: opensearch_domain |
| 1216 |
- assert: |
| 1217 |
that: |
| 1218 |
- opensearch_domain is changed |
| 1219 |
|
| 1220 |
- name: Enable auto-tune options, changes expected |
| 1221 |
opensearch: |
| 1222 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 1223 |
auto_tune_options: |
| 1224 |
desired_state: "ENABLED" |
| 1225 |
maintenance_schedules: |
| 1226 |
# Create a schedule one year from the date we start the test. |
| 1227 |
# If we hard code the date, we have to pick a date, but the API will fail |
| 1228 |
# if start_at is in the past. |
| 1229 |
- start_at: "{{ ansible_date_time.year|int + 1 }}-01-01" |
| 1230 |
duration: |
| 1231 |
value: 10 |
| 1232 |
unit: "HOURS" |
| 1233 |
cron_expression_for_recurrence: "cron(0 12 * * ? *)" |
| 1234 |
# I have observed that at least during one test run, |
| 1235 |
# the cluster status was stuck in 'processing=true' for over 24 hours |
| 1236 |
# after enabling auto-tune options. |
| 1237 |
# This does not seem right. From a test perspective, that means we cannot |
| 1238 |
# execute any change that needs to wait until the cluster is not processing |
| 1239 |
# background tasks. |
| 1240 |
wait: false |
| 1241 |
register: opensearch_domain |
| 1242 |
- assert: |
| 1243 |
that: |
| 1244 |
- "opensearch_domain.auto_tune_options.state == 'ENABLED'" |
| 1245 |
- opensearch_domain is changed |
| 1246 |
|
| 1247 |
- name: Enable auto-tune options in check mode again |
| 1248 |
opensearch: |
| 1249 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 1250 |
auto_tune_options: |
| 1251 |
desired_state: "ENABLED" |
| 1252 |
maintenance_schedules: |
| 1253 |
- start_at: "{{ ansible_date_time.year|int + 1 }}-01-01" |
| 1254 |
duration: |
| 1255 |
value: 10 |
| 1256 |
unit: "HOURS" |
| 1257 |
cron_expression_for_recurrence: "cron(0 12 * * ? *)" |
| 1258 |
wait: false |
| 1259 |
check_mode: true |
| 1260 |
register: opensearch_domain |
| 1261 |
- assert: |
| 1262 |
that: |
| 1263 |
- opensearch_domain is not changed |
| 1264 |
|
| 1265 |
- name: Enable auto-tune options, no change expected |
| 1266 |
opensearch: |
| 1267 |
domain_name: "es-{{ tiny_prefix }}-vpc" |
| 1268 |
auto_tune_options: |
| 1269 |
desired_state: "ENABLED" |
| 1270 |
maintenance_schedules: |
| 1271 |
- start_at: "{{ ansible_date_time.year|int + 1 }}-01-01" |
| 1272 |
duration: |
| 1273 |
value: 10 |
| 1274 |
unit: "HOURS" |
| 1275 |
cron_expression_for_recurrence: "cron(0 12 * * ? *)" |
| 1276 |
wait: false |
| 1277 |
register: opensearch_domain |
| 1278 |
- assert: |
| 1279 |
that: |
| 1280 |
- "opensearch_domain.auto_tune_options.state == 'ENABLED'" |
| 1281 |
- opensearch_domain is not changed |