| 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: Install required libs |
| 12 |
pip: |
| 13 |
name: python-gitlab |
| 14 |
state: present |
| 15 |
|
| 16 |
- name: purge all variables for check_mode test |
| 17 |
gitlab_project_variable: |
| 18 |
api_url: "{{ gitlab_host }}" |
| 19 |
api_token: "{{ gitlab_login_token }}" |
| 20 |
project: "{{ gitlab_project_name }}" |
| 21 |
purge: true |
| 22 |
|
| 23 |
- name: add a variable value in check_mode |
| 24 |
gitlab_project_variable: |
| 25 |
api_url: "{{ gitlab_host }}" |
| 26 |
api_token: "{{ gitlab_login_token }}" |
| 27 |
project: "{{ gitlab_project_name }}" |
| 28 |
vars: |
| 29 |
ACCESS_KEY_ID: checkmode |
| 30 |
check_mode: true |
| 31 |
register: gitlab_project_variable_state |
| 32 |
|
| 33 |
- name: check_mode state must be changed |
| 34 |
assert: |
| 35 |
that: |
| 36 |
- gitlab_project_variable_state is changed |
| 37 |
|
| 38 |
- name: apply add value from check_mode test |
| 39 |
gitlab_project_variable: |
| 40 |
api_url: "{{ gitlab_host }}" |
| 41 |
api_token: "{{ gitlab_login_token }}" |
| 42 |
project: "{{ gitlab_project_name }}" |
| 43 |
variables: |
| 44 |
- name: ACCESS_KEY_ID |
| 45 |
value: checkmode |
| 46 |
register: gitlab_project_variable_state |
| 47 |
|
| 48 |
- name: state must be changed |
| 49 |
assert: |
| 50 |
that: |
| 51 |
- gitlab_project_variable_state is changed |
| 52 |
|
| 53 |
- name: test new format |
| 54 |
gitlab_project_variable: |
| 55 |
api_url: "{{ gitlab_host }}" |
| 56 |
api_token: "{{ gitlab_login_token }}" |
| 57 |
project: "{{ gitlab_project_name }}" |
| 58 |
vars: |
| 59 |
ACCESS_KEY_ID: |
| 60 |
value: checkmode |
| 61 |
register: gitlab_project_variable_state |
| 62 |
|
| 63 |
- name: state must be not changed |
| 64 |
assert: |
| 65 |
that: |
| 66 |
- gitlab_project_variable_state is not changed |
| 67 |
|
| 68 |
- name: change protected attribute |
| 69 |
gitlab_project_variable: |
| 70 |
api_url: "{{ gitlab_host }}" |
| 71 |
api_token: "{{ gitlab_login_token }}" |
| 72 |
project: "{{ gitlab_project_name }}" |
| 73 |
vars: |
| 74 |
ACCESS_KEY_ID: |
| 75 |
value: checkmode |
| 76 |
protected: true |
| 77 |
register: gitlab_project_variable_state |
| 78 |
|
| 79 |
- name: state must be changed |
| 80 |
assert: |
| 81 |
that: |
| 82 |
- gitlab_project_variable_state is changed |
| 83 |
|
| 84 |
- name: revert protected attribute |
| 85 |
gitlab_project_variable: |
| 86 |
api_url: "{{ gitlab_host }}" |
| 87 |
api_token: "{{ gitlab_login_token }}" |
| 88 |
project: "{{ gitlab_project_name }}" |
| 89 |
vars: |
| 90 |
ACCESS_KEY_ID: |
| 91 |
value: checkmode |
| 92 |
protected: false |
| 93 |
register: gitlab_project_variable_state |
| 94 |
|
| 95 |
- name: state must be changed |
| 96 |
assert: |
| 97 |
that: |
| 98 |
- gitlab_project_variable_state is changed |
| 99 |
|
| 100 |
- name: change masked attribute |
| 101 |
gitlab_project_variable: |
| 102 |
api_url: "{{ gitlab_host }}" |
| 103 |
api_token: "{{ gitlab_login_token }}" |
| 104 |
project: "{{ gitlab_project_name }}" |
| 105 |
vars: |
| 106 |
ACCESS_KEY_ID: |
| 107 |
value: checkmode |
| 108 |
masked: true |
| 109 |
register: gitlab_project_variable_state |
| 110 |
|
| 111 |
- name: state must be changed |
| 112 |
assert: |
| 113 |
that: |
| 114 |
- gitlab_project_variable_state is changed |
| 115 |
|
| 116 |
- name: revert masked attribute by not mention it |
| 117 |
gitlab_project_variable: |
| 118 |
api_url: "{{ gitlab_host }}" |
| 119 |
api_token: "{{ gitlab_login_token }}" |
| 120 |
project: "{{ gitlab_project_name }}" |
| 121 |
vars: |
| 122 |
ACCESS_KEY_ID: |
| 123 |
value: checkmode |
| 124 |
register: gitlab_project_variable_state |
| 125 |
|
| 126 |
- name: state must be changed |
| 127 |
assert: |
| 128 |
that: |
| 129 |
- gitlab_project_variable_state is changed |
| 130 |
|
| 131 |
- name: revert again masked attribute by not mention it (idempotent) |
| 132 |
gitlab_project_variable: |
| 133 |
api_url: "{{ gitlab_host }}" |
| 134 |
api_token: "{{ gitlab_login_token }}" |
| 135 |
project: "{{ gitlab_project_name }}" |
| 136 |
vars: |
| 137 |
ACCESS_KEY_ID: |
| 138 |
value: checkmode |
| 139 |
register: gitlab_project_variable_state |
| 140 |
|
| 141 |
- name: state must be not changed |
| 142 |
assert: |
| 143 |
that: |
| 144 |
- gitlab_project_variable_state is not changed |
| 145 |
|
| 146 |
- name: set both (masked and protected) attribute |
| 147 |
gitlab_project_variable: |
| 148 |
api_url: "{{ gitlab_host }}" |
| 149 |
api_token: "{{ gitlab_login_token }}" |
| 150 |
project: "{{ gitlab_project_name }}" |
| 151 |
vars: |
| 152 |
ACCESS_KEY_ID: |
| 153 |
value: checkmode |
| 154 |
masked: true |
| 155 |
protected: true |
| 156 |
variable_type: env_var |
| 157 |
register: gitlab_project_variable_state |
| 158 |
|
| 159 |
- name: state must be changed |
| 160 |
assert: |
| 161 |
that: |
| 162 |
- gitlab_project_variable_state is changed |
| 163 |
|
| 164 |
- name: set again both (masked and protected) attribute (idempotent) |
| 165 |
gitlab_project_variable: |
| 166 |
api_url: "{{ gitlab_host }}" |
| 167 |
api_token: "{{ gitlab_login_token }}" |
| 168 |
project: "{{ gitlab_project_name }}" |
| 169 |
vars: |
| 170 |
ACCESS_KEY_ID: |
| 171 |
value: checkmode |
| 172 |
masked: true |
| 173 |
protected: true |
| 174 |
variable_type: env_var |
| 175 |
register: gitlab_project_variable_state |
| 176 |
|
| 177 |
- name: state must not be changed |
| 178 |
assert: |
| 179 |
that: |
| 180 |
- gitlab_project_variable_state is not changed |
| 181 |
|
| 182 |
- name: revert both (masked and protected) attribute |
| 183 |
gitlab_project_variable: |
| 184 |
api_url: "{{ gitlab_host }}" |
| 185 |
api_token: "{{ gitlab_login_token }}" |
| 186 |
project: "{{ gitlab_project_name }}" |
| 187 |
vars: |
| 188 |
ACCESS_KEY_ID: |
| 189 |
value: checkmode |
| 190 |
protected: false |
| 191 |
register: gitlab_project_variable_state |
| 192 |
|
| 193 |
- name: state must be changed |
| 194 |
assert: |
| 195 |
that: |
| 196 |
- gitlab_project_variable_state is changed |
| 197 |
|
| 198 |
- name: change a variable value in check_mode again |
| 199 |
gitlab_project_variable: |
| 200 |
api_url: "{{ gitlab_host }}" |
| 201 |
api_token: "{{ gitlab_login_token }}" |
| 202 |
project: "{{ gitlab_project_name }}" |
| 203 |
vars: |
| 204 |
ACCESS_KEY_ID: checkmode |
| 205 |
check_mode: true |
| 206 |
register: gitlab_project_variable_state |
| 207 |
|
| 208 |
- name: check_mode state must not be changed |
| 209 |
assert: |
| 210 |
that: |
| 211 |
- gitlab_project_variable_state is not changed |
| 212 |
|
| 213 |
- name: apply again the value change from check_mode test |
| 214 |
gitlab_project_variable: |
| 215 |
api_url: "{{ gitlab_host }}" |
| 216 |
api_token: "{{ gitlab_login_token }}" |
| 217 |
project: "{{ gitlab_project_name }}" |
| 218 |
vars: |
| 219 |
ACCESS_KEY_ID: checkmode |
| 220 |
register: gitlab_project_variable_state |
| 221 |
|
| 222 |
- name: state must not be changed |
| 223 |
assert: |
| 224 |
that: |
| 225 |
- gitlab_project_variable_state is not changed |
| 226 |
|
| 227 |
- name: change environment scope |
| 228 |
gitlab_project_variable: |
| 229 |
api_url: "{{ gitlab_host }}" |
| 230 |
api_token: "{{ gitlab_login_token }}" |
| 231 |
project: "{{ gitlab_project_name }}" |
| 232 |
vars: |
| 233 |
ACCESS_KEY_ID: |
| 234 |
environment_scope: testing |
| 235 |
value: checkmode |
| 236 |
register: gitlab_project_variable_state |
| 237 |
|
| 238 |
- name: state must be changed |
| 239 |
assert: |
| 240 |
that: |
| 241 |
- gitlab_project_variable_state is changed |
| 242 |
|
| 243 |
- name: apply again the environment scope change |
| 244 |
gitlab_project_variable: |
| 245 |
api_url: "{{ gitlab_host }}" |
| 246 |
api_token: "{{ gitlab_login_token }}" |
| 247 |
project: "{{ gitlab_project_name }}" |
| 248 |
vars: |
| 249 |
ACCESS_KEY_ID: |
| 250 |
environment_scope: testing |
| 251 |
value: checkmode |
| 252 |
register: gitlab_project_variable_state |
| 253 |
|
| 254 |
- name: state must not be changed |
| 255 |
assert: |
| 256 |
that: |
| 257 |
- gitlab_project_variable_state is not changed |
| 258 |
|
| 259 |
- name: purge all variables at the beginning |
| 260 |
gitlab_project_variable: |
| 261 |
api_url: "{{ gitlab_host }}" |
| 262 |
api_token: "{{ gitlab_login_token }}" |
| 263 |
project: "{{ gitlab_project_name }}" |
| 264 |
purge: true |
| 265 |
|
| 266 |
- name: set two test variables |
| 267 |
gitlab_project_variable: |
| 268 |
api_url: "{{ gitlab_host }}" |
| 269 |
api_token: "{{ gitlab_login_token }}" |
| 270 |
project: "{{ gitlab_project_name }}" |
| 271 |
vars: |
| 272 |
ACCESS_KEY_ID: abc123 |
| 273 |
SECRET_ACCESS_KEY: 321cba |
| 274 |
register: gitlab_project_variable_state |
| 275 |
|
| 276 |
- name: set two test variables state must be changed |
| 277 |
assert: |
| 278 |
that: |
| 279 |
- gitlab_project_variable_state is changed |
| 280 |
- gitlab_project_variable_state.project_variable.added|length == 2 |
| 281 |
- gitlab_project_variable_state.project_variable.untouched|length == 0 |
| 282 |
- gitlab_project_variable_state.project_variable.removed|length == 0 |
| 283 |
- gitlab_project_variable_state.project_variable.updated|length == 0 |
| 284 |
|
| 285 |
- name: re-set two test variables |
| 286 |
gitlab_project_variable: |
| 287 |
api_url: "{{ gitlab_host }}" |
| 288 |
api_token: "{{ gitlab_login_token }}" |
| 289 |
project: "{{ gitlab_project_name }}" |
| 290 |
vars: |
| 291 |
ACCESS_KEY_ID: abc123 |
| 292 |
SECRET_ACCESS_KEY: 321cba |
| 293 |
register: gitlab_project_variable_state |
| 294 |
|
| 295 |
- name: re-set two test variables state must not be changed |
| 296 |
assert: |
| 297 |
that: |
| 298 |
- gitlab_project_variable_state is not changed |
| 299 |
- gitlab_project_variable_state.project_variable.added|length == 0 |
| 300 |
- gitlab_project_variable_state.project_variable.untouched|length == 2 |
| 301 |
- gitlab_project_variable_state.project_variable.removed|length == 0 |
| 302 |
- gitlab_project_variable_state.project_variable.updated|length == 0 |
| 303 |
|
| 304 |
- name: edit one variable |
| 305 |
gitlab_project_variable: |
| 306 |
api_url: "{{ gitlab_host }}" |
| 307 |
api_token: "{{ gitlab_login_token }}" |
| 308 |
project: "{{ gitlab_project_name }}" |
| 309 |
vars: |
| 310 |
ACCESS_KEY_ID: changed |
| 311 |
purge: false |
| 312 |
register: gitlab_project_variable_state |
| 313 |
|
| 314 |
- name: edit one variable state must be changed |
| 315 |
assert: |
| 316 |
that: |
| 317 |
- gitlab_project_variable_state.changed |
| 318 |
- gitlab_project_variable_state.project_variable.added|length == 0 |
| 319 |
- gitlab_project_variable_state.project_variable.untouched|length == 1 |
| 320 |
- gitlab_project_variable_state.project_variable.removed|length == 0 |
| 321 |
- gitlab_project_variable_state.project_variable.updated|length == 1 |
| 322 |
- gitlab_project_variable_state.project_variable.updated[0] == "ACCESS_KEY_ID" |
| 323 |
|
| 324 |
- name: append one variable |
| 325 |
gitlab_project_variable: |
| 326 |
api_url: "{{ gitlab_host }}" |
| 327 |
api_token: "{{ gitlab_login_token }}" |
| 328 |
project: "{{ gitlab_project_name }}" |
| 329 |
vars: |
| 330 |
some: value |
| 331 |
purge: false |
| 332 |
register: gitlab_project_variable_state |
| 333 |
|
| 334 |
- name: append one variable state must be changed |
| 335 |
assert: |
| 336 |
that: |
| 337 |
- gitlab_project_variable_state.changed |
| 338 |
- gitlab_project_variable_state.project_variable.added|length == 1 |
| 339 |
- gitlab_project_variable_state.project_variable.untouched|length == 2 |
| 340 |
- gitlab_project_variable_state.project_variable.removed|length == 0 |
| 341 |
- gitlab_project_variable_state.project_variable.updated|length == 0 |
| 342 |
- gitlab_project_variable_state.project_variable.added[0] == "some" |
| 343 |
|
| 344 |
- name: re-set all variables |
| 345 |
gitlab_project_variable: |
| 346 |
api_url: "{{ gitlab_host }}" |
| 347 |
api_token: "{{ gitlab_login_token }}" |
| 348 |
project: "{{ gitlab_project_name }}" |
| 349 |
vars: |
| 350 |
ACCESS_KEY_ID: changed |
| 351 |
SECRET_ACCESS_KEY: 321cba |
| 352 |
some: value |
| 353 |
register: gitlab_project_variable_state |
| 354 |
|
| 355 |
- name: re-set all variables state must not be changed |
| 356 |
assert: |
| 357 |
that: |
| 358 |
- not gitlab_project_variable_state.changed |
| 359 |
- gitlab_project_variable_state.project_variable.added|length == 0 |
| 360 |
- gitlab_project_variable_state.project_variable.untouched|length == 3 |
| 361 |
- gitlab_project_variable_state.project_variable.removed|length == 0 |
| 362 |
- gitlab_project_variable_state.project_variable.updated|length == 0 |
| 363 |
|
| 364 |
- name: set one variables and purge all others |
| 365 |
gitlab_project_variable: |
| 366 |
api_url: "{{ gitlab_host }}" |
| 367 |
api_token: "{{ gitlab_login_token }}" |
| 368 |
project: "{{ gitlab_project_name }}" |
| 369 |
vars: |
| 370 |
some: value |
| 371 |
purge: true |
| 372 |
register: gitlab_project_variable_state |
| 373 |
|
| 374 |
- name: set one variables and purge all others state must be changed |
| 375 |
assert: |
| 376 |
that: |
| 377 |
- gitlab_project_variable_state.changed |
| 378 |
- gitlab_project_variable_state.project_variable.added|length == 0 |
| 379 |
- gitlab_project_variable_state.project_variable.untouched|length == 1 |
| 380 |
- gitlab_project_variable_state.project_variable.removed|length == 2 |
| 381 |
- gitlab_project_variable_state.project_variable.updated|length == 0 |
| 382 |
|
| 383 |
- name: only one variable is left |
| 384 |
gitlab_project_variable: |
| 385 |
api_url: "{{ gitlab_host }}" |
| 386 |
api_token: "{{ gitlab_login_token }}" |
| 387 |
project: "{{ gitlab_project_name }}" |
| 388 |
vars: |
| 389 |
some: value |
| 390 |
purge: false |
| 391 |
register: gitlab_project_variable_state |
| 392 |
|
| 393 |
- name: only one variable is left state must not be changed |
| 394 |
assert: |
| 395 |
that: |
| 396 |
- not gitlab_project_variable_state.changed |
| 397 |
- gitlab_project_variable_state.project_variable.added|length == 0 |
| 398 |
- gitlab_project_variable_state.project_variable.untouched|length == 1 |
| 399 |
- gitlab_project_variable_state.project_variable.removed|length == 0 |
| 400 |
- gitlab_project_variable_state.project_variable.updated|length == 0 |
| 401 |
- gitlab_project_variable_state.project_variable.untouched[0] == "some" |
| 402 |
|
| 403 |
- name: test integer values |
| 404 |
gitlab_project_variable: |
| 405 |
api_url: "{{ gitlab_host }}" |
| 406 |
api_token: "{{ gitlab_login_token }}" |
| 407 |
project: "{{ gitlab_project_name }}" |
| 408 |
vars: |
| 409 |
some: 42 |
| 410 |
purge: false |
| 411 |
register: gitlab_project_variable_state |
| 412 |
|
| 413 |
- name: only one variable is left state must be changed |
| 414 |
assert: |
| 415 |
that: |
| 416 |
- gitlab_project_variable_state.changed |
| 417 |
- gitlab_project_variable_state.project_variable.added|length == 0 |
| 418 |
- gitlab_project_variable_state.project_variable.untouched|length == 0 |
| 419 |
- gitlab_project_variable_state.project_variable.removed|length == 0 |
| 420 |
- gitlab_project_variable_state.project_variable.updated|length == 1 |
| 421 |
|
| 422 |
- name: test float values |
| 423 |
gitlab_project_variable: |
| 424 |
api_url: "{{ gitlab_host }}" |
| 425 |
api_token: "{{ gitlab_login_token }}" |
| 426 |
project: "{{ gitlab_project_name }}" |
| 427 |
vars: |
| 428 |
some: 42.23 |
| 429 |
purge: false |
| 430 |
register: gitlab_project_variable_state |
| 431 |
|
| 432 |
- name: only one variable is left state must be changed |
| 433 |
assert: |
| 434 |
that: |
| 435 |
- gitlab_project_variable_state.changed |
| 436 |
- gitlab_project_variable_state.project_variable.added|length == 0 |
| 437 |
- gitlab_project_variable_state.project_variable.untouched|length == 0 |
| 438 |
- gitlab_project_variable_state.project_variable.removed|length == 0 |
| 439 |
- gitlab_project_variable_state.project_variable.updated|length == 1 |
| 440 |
|
| 441 |
- name: delete the last left variable |
| 442 |
gitlab_project_variable: |
| 443 |
api_url: "{{ gitlab_host }}" |
| 444 |
api_token: "{{ gitlab_login_token }}" |
| 445 |
project: "{{ gitlab_project_name }}" |
| 446 |
state: absent |
| 447 |
vars: |
| 448 |
some: value |
| 449 |
register: gitlab_project_variable_state |
| 450 |
|
| 451 |
- name: no variable is left state must be changed |
| 452 |
assert: |
| 453 |
that: |
| 454 |
- gitlab_project_variable_state.changed |
| 455 |
- gitlab_project_variable_state.project_variable.added|length == 0 |
| 456 |
- gitlab_project_variable_state.project_variable.untouched|length == 0 |
| 457 |
- gitlab_project_variable_state.project_variable.removed|length == 1 |
| 458 |
- gitlab_project_variable_state.project_variable.updated|length == 0 |
| 459 |
- gitlab_project_variable_state.project_variable.removed[0] == "some" |
| 460 |
|
| 461 |
- name: add one variable with variable_type file |
| 462 |
gitlab_project_variable: |
| 463 |
api_url: "{{ gitlab_host }}" |
| 464 |
api_token: "{{ gitlab_login_token }}" |
| 465 |
project: "{{ gitlab_project_name }}" |
| 466 |
variables: |
| 467 |
- name: my_test_var |
| 468 |
value: my_test_value |
| 469 |
variable_type: file |
| 470 |
purge: false |
| 471 |
register: gitlab_project_variable_state |
| 472 |
|
| 473 |
- name: append one variable state must be changed |
| 474 |
assert: |
| 475 |
that: |
| 476 |
- gitlab_project_variable_state.changed |
| 477 |
- gitlab_project_variable_state.project_variable.added|length == 1 |
| 478 |
- gitlab_project_variable_state.project_variable.untouched|length == 0 |
| 479 |
- gitlab_project_variable_state.project_variable.removed|length == 0 |
| 480 |
- gitlab_project_variable_state.project_variable.updated|length == 0 |
| 481 |
# VALUE_SPECIFIED_IN_NO_LOG_PARAMETER |
| 482 |
# - gitlab_project_variable_state.project_variable.added[0] == "my_test_var" |
| 483 |
|
| 484 |
- name: change variable_type attribute |
| 485 |
gitlab_project_variable: |
| 486 |
api_url: "{{ gitlab_host }}" |
| 487 |
api_token: "{{ gitlab_login_token }}" |
| 488 |
project: "{{ gitlab_project_name }}" |
| 489 |
vars: |
| 490 |
my_test_var: |
| 491 |
value: my_test_value |
| 492 |
variable_type: env_var |
| 493 |
register: gitlab_project_variable_state |
| 494 |
|
| 495 |
- name: state must be changed |
| 496 |
assert: |
| 497 |
that: |
| 498 |
- gitlab_project_variable_state is changed |
| 499 |
|
| 500 |
- name: revert variable_type attribute |
| 501 |
gitlab_project_variable: |
| 502 |
api_url: "{{ gitlab_host }}" |
| 503 |
api_token: "{{ gitlab_login_token }}" |
| 504 |
project: "{{ gitlab_project_name }}" |
| 505 |
vars: |
| 506 |
my_test_var: |
| 507 |
value: my_test_value |
| 508 |
variable_type: file |
| 509 |
register: gitlab_project_variable_state |
| 510 |
|
| 511 |
- name: state must be changed |
| 512 |
assert: |
| 513 |
that: |
| 514 |
- gitlab_project_variable_state is changed |
| 515 |
|
| 516 |
- name: delete the variable_type file variable |
| 517 |
gitlab_project_variable: |
| 518 |
api_url: "{{ gitlab_host }}" |
| 519 |
api_token: "{{ gitlab_login_token }}" |
| 520 |
project: "{{ gitlab_project_name }}" |
| 521 |
state: absent |
| 522 |
vars: |
| 523 |
my_test_var: my_test_value |
| 524 |
register: gitlab_project_variable_state |
| 525 |
|
| 526 |
- name: no variable is left state must be changed |
| 527 |
assert: |
| 528 |
that: |
| 529 |
- gitlab_project_variable_state.changed |
| 530 |
- gitlab_project_variable_state.project_variable.added|length == 0 |
| 531 |
- gitlab_project_variable_state.project_variable.untouched|length == 0 |
| 532 |
- gitlab_project_variable_state.project_variable.removed|length == 1 |
| 533 |
- gitlab_project_variable_state.project_variable.updated|length == 0 |
| 534 |
- gitlab_project_variable_state.project_variable.removed[0] == "my_test_var" |
| 535 |
|
| 536 |
- name: set complete page and purge existing ones |
| 537 |
gitlab_project_variable: |
| 538 |
api_url: "{{ gitlab_host }}" |
| 539 |
api_token: "{{ gitlab_login_token }}" |
| 540 |
project: "{{ gitlab_project_name }}" |
| 541 |
vars: |
| 542 |
page1_var01: value |
| 543 |
page1_var02: value |
| 544 |
page1_var03: value |
| 545 |
page1_var04: value |
| 546 |
page1_var05: value |
| 547 |
page1_var06: value |
| 548 |
page1_var07: value |
| 549 |
page1_var08: value |
| 550 |
page1_var09: value |
| 551 |
page1_var10: value |
| 552 |
page1_var11: value |
| 553 |
page1_var12: value |
| 554 |
page1_var13: value |
| 555 |
page1_var14: value |
| 556 |
page1_var15: value |
| 557 |
page1_var16: value |
| 558 |
page1_var17: value |
| 559 |
page1_var18: value |
| 560 |
page1_var19: value |
| 561 |
page1_var20: value |
| 562 |
purge: true |
| 563 |
register: gitlab_project_variable_state |
| 564 |
|
| 565 |
- name: complete page added state must be changed |
| 566 |
assert: |
| 567 |
that: |
| 568 |
- gitlab_project_variable_state is changed |
| 569 |
- gitlab_project_variable_state.project_variable.added|length == 20 |
| 570 |
- gitlab_project_variable_state.project_variable.untouched|length == 0 |
| 571 |
|
| 572 |
- name: set complete page and keep existing ones |
| 573 |
gitlab_project_variable: |
| 574 |
api_url: "{{ gitlab_host }}" |
| 575 |
api_token: "{{ gitlab_login_token }}" |
| 576 |
project: "{{ gitlab_project_name }}" |
| 577 |
vars: |
| 578 |
page2_var01: value |
| 579 |
page2_var02: value |
| 580 |
page2_var03: value |
| 581 |
page2_var04: value |
| 582 |
page2_var05: value |
| 583 |
page2_var06: value |
| 584 |
page2_var07: value |
| 585 |
page2_var08: value |
| 586 |
page2_var09: value |
| 587 |
page2_var10: value |
| 588 |
page2_var11: value |
| 589 |
page2_var12: value |
| 590 |
page2_var13: value |
| 591 |
page2_var14: value |
| 592 |
page2_var15: value |
| 593 |
page2_var16: value |
| 594 |
page2_var17: value |
| 595 |
page2_var18: value |
| 596 |
page2_var19: value |
| 597 |
page2_var20: value |
| 598 |
purge: false |
| 599 |
register: gitlab_project_variable_state |
| 600 |
|
| 601 |
- name: existing page untouched state must be changed |
| 602 |
assert: |
| 603 |
that: |
| 604 |
- gitlab_project_variable_state is changed |
| 605 |
- gitlab_project_variable_state.project_variable.added|length == 20 |
| 606 |
- gitlab_project_variable_state.project_variable.untouched|length == 20 |
| 607 |
|
| 608 |
- name: check that no variables are left |
| 609 |
gitlab_project_variable: |
| 610 |
api_url: "{{ gitlab_host }}" |
| 611 |
api_token: "{{ gitlab_login_token }}" |
| 612 |
project: "{{ gitlab_project_name }}" |
| 613 |
purge: true |
| 614 |
register: gitlab_project_variable_state |
| 615 |
|
| 616 |
- name: check that no variables are untouched state must be changed |
| 617 |
assert: |
| 618 |
that: |
| 619 |
- gitlab_project_variable_state.changed |
| 620 |
- gitlab_project_variable_state.project_variable.added|length == 0 |
| 621 |
- gitlab_project_variable_state.project_variable.untouched|length == 0 |
| 622 |
- gitlab_project_variable_state.project_variable.removed|length == 40 |
| 623 |
- gitlab_project_variable_state.project_variable.updated|length == 0 |
| 624 |
|
| 625 |
- name: same vars, diff scope |
| 626 |
gitlab_project_variable: |
| 627 |
api_url: "{{ gitlab_host }}" |
| 628 |
api_token: "{{ gitlab_login_token }}" |
| 629 |
project: "{{ gitlab_project_name }}" |
| 630 |
purge: true |
| 631 |
variables: |
| 632 |
- name: SECRET_ACCESS_KEY |
| 633 |
value: 3214cbad |
| 634 |
masked: true |
| 635 |
protected: true |
| 636 |
variable_type: env_var |
| 637 |
environment_scope: production |
| 638 |
- name: SECRET_ACCESS_KEY |
| 639 |
value: hello_world |
| 640 |
masked: true |
| 641 |
protected: true |
| 642 |
variable_type: env_var |
| 643 |
environment_scope: development |
| 644 |
register: gitlab_project_variable_state |
| 645 |
|
| 646 |
- name: verify two vars |
| 647 |
assert: |
| 648 |
that: |
| 649 |
- gitlab_project_variable_state.changed |
| 650 |
- gitlab_project_variable_state.project_variable.added|length == 2 |
| 651 |
- gitlab_project_variable_state.project_variable.untouched|length == 0 |
| 652 |
- gitlab_project_variable_state.project_variable.removed|length == 0 |
| 653 |
- gitlab_project_variable_state.project_variable.updated|length == 0 |
| 654 |
|
| 655 |
- name: throw error when state is present but no value is given |
| 656 |
gitlab_project_variable: |
| 657 |
api_url: "{{ gitlab_host }}" |
| 658 |
api_token: "{{ gitlab_login_token }}" |
| 659 |
project: "{{ gitlab_project_name }}" |
| 660 |
variables: |
| 661 |
- name: delete_me |
| 662 |
register: gitlab_project_variable_state |
| 663 |
ignore_errors: true |
| 664 |
|
| 665 |
- name: verify fail |
| 666 |
assert: |
| 667 |
that: |
| 668 |
- gitlab_project_variable_state.failed |
| 669 |
- gitlab_project_variable_state is not changed |
| 670 |
|
| 671 |
- name: set a new variable to delete it later |
| 672 |
gitlab_project_variable: |
| 673 |
api_url: "{{ gitlab_host }}" |
| 674 |
api_token: "{{ gitlab_login_token }}" |
| 675 |
project: "{{ gitlab_project_name }}" |
| 676 |
purge: true |
| 677 |
variables: |
| 678 |
- name: delete_me |
| 679 |
value: ansible |
| 680 |
register: gitlab_project_variable_state |
| 681 |
|
| 682 |
- name: verify the change |
| 683 |
assert: |
| 684 |
that: |
| 685 |
- gitlab_project_variable_state.changed |
| 686 |
|
| 687 |
- name: delete variable without referencing its value |
| 688 |
gitlab_project_variable: |
| 689 |
api_url: "{{ gitlab_host }}" |
| 690 |
api_token: "{{ gitlab_login_token }}" |
| 691 |
project: "{{ gitlab_project_name }}" |
| 692 |
state: absent |
| 693 |
variables: |
| 694 |
- name: delete_me |
| 695 |
register: gitlab_project_variable_state |
| 696 |
|
| 697 |
- name: verify deletion |
| 698 |
assert: |
| 699 |
that: |
| 700 |
- gitlab_project_variable_state.changed |
| 701 |
- gitlab_project_variable_state.project_variable.removed|length == 1 |