| 1 |
# UNINSTALL |
| 2 |
- name: uninstall sos |
| 3 |
dnf: |
| 4 |
name: sos |
| 5 |
state: removed |
| 6 |
register: dnf_result |
| 7 |
|
| 8 |
- name: check sos with rpm |
| 9 |
shell: rpm -q sos |
| 10 |
failed_when: False |
| 11 |
register: rpm_result |
| 12 |
|
| 13 |
- name: verify uninstallation of sos |
| 14 |
assert: |
| 15 |
that: |
| 16 |
- "not dnf_result.failed | default(False)" |
| 17 |
- "rpm_result.rc == 1" |
| 18 |
|
| 19 |
# NOTE Now that the dnf module executed, libdnf is installed even for the case |
| 20 |
# when testing 'auto_install_module_deps: false' for dnf5 |
| 21 |
# and we can print libdnf version we test against for debugging purposes. |
| 22 |
- name: get libdnf version being tested |
| 23 |
command: "rpm -q {{ 'python3-libdnf5' if dnf5 else 'python3-libdnf' }}" |
| 24 |
register: libdnf_ver |
| 25 |
|
| 26 |
- name: libdnf version being tested |
| 27 |
debug: |
| 28 |
msg: "{{ libdnf_ver.stdout }}" |
| 29 |
|
| 30 |
# UNINSTALL AGAIN |
| 31 |
- name: uninstall sos |
| 32 |
dnf: |
| 33 |
name: sos |
| 34 |
state: removed |
| 35 |
register: dnf_result |
| 36 |
|
| 37 |
- name: verify no change on re-uninstall |
| 38 |
assert: |
| 39 |
that: |
| 40 |
- "not dnf_result.changed" |
| 41 |
|
| 42 |
# INSTALL |
| 43 |
- name: install sos (check_mode) |
| 44 |
dnf: |
| 45 |
name: sos |
| 46 |
state: present |
| 47 |
update_cache: True |
| 48 |
check_mode: True |
| 49 |
register: dnf_result |
| 50 |
|
| 51 |
- assert: |
| 52 |
that: |
| 53 |
- dnf_result is success |
| 54 |
- dnf_result.results|length > 0 |
| 55 |
- "dnf_result.results[0].startswith('Installed: ')" |
| 56 |
|
| 57 |
- name: install sos |
| 58 |
dnf: |
| 59 |
name: sos |
| 60 |
state: present |
| 61 |
update_cache: True |
| 62 |
register: dnf_result |
| 63 |
|
| 64 |
- find: |
| 65 |
paths: /var/cache/dnf |
| 66 |
patterns: "*.rpm" |
| 67 |
recurse: true |
| 68 |
register: r |
| 69 |
|
| 70 |
- name: verify that RPM cache is cleared after installation as keepcache is off by default |
| 71 |
assert: |
| 72 |
that: |
| 73 |
- r.matched == 0 |
| 74 |
|
| 75 |
- name: check sos with rpm |
| 76 |
shell: rpm -q sos |
| 77 |
failed_when: False |
| 78 |
register: rpm_result |
| 79 |
|
| 80 |
- name: verify installation of sos |
| 81 |
assert: |
| 82 |
that: |
| 83 |
- "not dnf_result.failed | default(False)" |
| 84 |
- "dnf_result.changed" |
| 85 |
- "rpm_result.rc == 0" |
| 86 |
|
| 87 |
- name: verify dnf module outputs |
| 88 |
assert: |
| 89 |
that: |
| 90 |
- "'changed' in dnf_result" |
| 91 |
- "'results' in dnf_result" |
| 92 |
|
| 93 |
# INSTALL AGAIN |
| 94 |
- name: install sos again (check_mode) |
| 95 |
dnf: |
| 96 |
name: sos |
| 97 |
state: present |
| 98 |
check_mode: True |
| 99 |
register: dnf_result |
| 100 |
|
| 101 |
- assert: |
| 102 |
that: |
| 103 |
- dnf_result is not changed |
| 104 |
- dnf_result.results|length == 0 |
| 105 |
|
| 106 |
- name: install sos again |
| 107 |
dnf: |
| 108 |
name: sos |
| 109 |
state: present |
| 110 |
register: dnf_result |
| 111 |
|
| 112 |
- name: verify no change on second install |
| 113 |
assert: |
| 114 |
that: |
| 115 |
- "not dnf_result.changed" |
| 116 |
|
| 117 |
- name: install sos again with empty string enablerepo |
| 118 |
dnf: |
| 119 |
name: sos |
| 120 |
state: present |
| 121 |
enablerepo: "" |
| 122 |
register: dnf_result |
| 123 |
|
| 124 |
- name: verify no change on third install with empty string enablerepo |
| 125 |
assert: |
| 126 |
that: |
| 127 |
- "dnf_result is success" |
| 128 |
- "not dnf_result is changed" |
| 129 |
|
| 130 |
# Multiple packages |
| 131 |
- name: uninstall sos and dos2unix |
| 132 |
dnf: name=sos,dos2unix state=removed |
| 133 |
register: dnf_result |
| 134 |
|
| 135 |
- name: check sos with rpm |
| 136 |
shell: rpm -q sos |
| 137 |
failed_when: False |
| 138 |
register: rpm_sos_result |
| 139 |
|
| 140 |
- name: check dos2unix with rpm |
| 141 |
shell: rpm -q dos2unix |
| 142 |
failed_when: False |
| 143 |
register: rpm_dos2unix_result |
| 144 |
|
| 145 |
- name: verify packages installed |
| 146 |
assert: |
| 147 |
that: |
| 148 |
- "rpm_sos_result.rc != 0" |
| 149 |
- "rpm_dos2unix_result.rc != 0" |
| 150 |
|
| 151 |
- name: install sos and dos2unix as comma separated |
| 152 |
dnf: name=sos,dos2unix state=present |
| 153 |
register: dnf_result |
| 154 |
|
| 155 |
- name: check sos with rpm |
| 156 |
shell: rpm -q sos |
| 157 |
failed_when: False |
| 158 |
register: rpm_sos_result |
| 159 |
|
| 160 |
- name: check dos2unix with rpm |
| 161 |
shell: rpm -q dos2unix |
| 162 |
failed_when: False |
| 163 |
register: rpm_dos2unix_result |
| 164 |
|
| 165 |
- name: verify packages installed |
| 166 |
assert: |
| 167 |
that: |
| 168 |
- "not dnf_result.failed | default(False)" |
| 169 |
- "dnf_result.changed" |
| 170 |
- "rpm_sos_result.rc == 0" |
| 171 |
- "rpm_dos2unix_result.rc == 0" |
| 172 |
|
| 173 |
- name: uninstall sos and dos2unix |
| 174 |
dnf: name=sos,dos2unix state=removed |
| 175 |
register: dnf_result |
| 176 |
|
| 177 |
- name: install sos and dos2unix as list |
| 178 |
dnf: |
| 179 |
name: |
| 180 |
- sos |
| 181 |
- dos2unix |
| 182 |
state: present |
| 183 |
register: dnf_result |
| 184 |
|
| 185 |
- name: check sos with rpm |
| 186 |
shell: rpm -q sos |
| 187 |
failed_when: False |
| 188 |
register: rpm_sos_result |
| 189 |
|
| 190 |
- name: check dos2unix with rpm |
| 191 |
shell: rpm -q dos2unix |
| 192 |
failed_when: False |
| 193 |
register: rpm_dos2unix_result |
| 194 |
|
| 195 |
- name: verify packages installed |
| 196 |
assert: |
| 197 |
that: |
| 198 |
- "not dnf_result.failed | default(False)" |
| 199 |
- "dnf_result.changed" |
| 200 |
- "rpm_sos_result.rc == 0" |
| 201 |
- "rpm_dos2unix_result.rc == 0" |
| 202 |
|
| 203 |
- name: uninstall sos and dos2unix |
| 204 |
dnf: |
| 205 |
name: "sos,dos2unix" |
| 206 |
state: removed |
| 207 |
register: dnf_result |
| 208 |
|
| 209 |
- name: install sos and dos2unix as comma separated with spaces |
| 210 |
dnf: |
| 211 |
name: "sos, dos2unix" |
| 212 |
state: present |
| 213 |
register: dnf_result |
| 214 |
|
| 215 |
- name: check sos with rpm |
| 216 |
shell: rpm -q sos |
| 217 |
failed_when: False |
| 218 |
register: rpm_sos_result |
| 219 |
|
| 220 |
- name: check sos with rpm |
| 221 |
shell: rpm -q dos2unix |
| 222 |
failed_when: False |
| 223 |
register: rpm_dos2unix_result |
| 224 |
|
| 225 |
- name: verify packages installed |
| 226 |
assert: |
| 227 |
that: |
| 228 |
- "not dnf_result.failed | default(False)" |
| 229 |
- "dnf_result.changed" |
| 230 |
- "rpm_sos_result.rc == 0" |
| 231 |
- "rpm_dos2unix_result.rc == 0" |
| 232 |
|
| 233 |
- name: uninstall sos and dos2unix (check_mode) |
| 234 |
dnf: |
| 235 |
name: |
| 236 |
- sos |
| 237 |
- dos2unix |
| 238 |
state: removed |
| 239 |
check_mode: True |
| 240 |
register: dnf_result |
| 241 |
|
| 242 |
- assert: |
| 243 |
that: |
| 244 |
- dnf_result is success |
| 245 |
- dnf_result.results|length >= 2 |
| 246 |
- "dnf_result.results[0].startswith('Removed: ')" |
| 247 |
- "dnf_result.results[1].startswith('Removed: ')" |
| 248 |
|
| 249 |
- name: uninstall sos and dos2unix |
| 250 |
dnf: |
| 251 |
name: |
| 252 |
- sos |
| 253 |
- dos2unix |
| 254 |
state: removed |
| 255 |
register: dnf_result |
| 256 |
|
| 257 |
- assert: |
| 258 |
that: |
| 259 |
- dnf_result is changed |
| 260 |
|
| 261 |
- name: install non-existent rpm |
| 262 |
dnf: |
| 263 |
name: does-not-exist |
| 264 |
register: non_existent_rpm |
| 265 |
ignore_errors: True |
| 266 |
|
| 267 |
- name: check non-existent rpm install failed |
| 268 |
assert: |
| 269 |
that: |
| 270 |
- non_existent_rpm is failed |
| 271 |
|
| 272 |
# Install in installroot='/'. This should be identical to default |
| 273 |
- name: install sos in / |
| 274 |
dnf: name=sos state=present installroot='/' |
| 275 |
register: dnf_result |
| 276 |
|
| 277 |
- name: check sos with rpm in / |
| 278 |
shell: rpm -q sos --root=/ |
| 279 |
failed_when: False |
| 280 |
register: rpm_result |
| 281 |
|
| 282 |
- name: verify installation of sos in / |
| 283 |
assert: |
| 284 |
that: |
| 285 |
- "not dnf_result.failed | default(False)" |
| 286 |
- "dnf_result.changed" |
| 287 |
- "rpm_result.rc == 0" |
| 288 |
|
| 289 |
- name: verify dnf module outputs in / |
| 290 |
assert: |
| 291 |
that: |
| 292 |
- "'changed' in dnf_result" |
| 293 |
- "'results' in dnf_result" |
| 294 |
|
| 295 |
- name: uninstall sos in / |
| 296 |
dnf: name=sos installroot='/' |
| 297 |
register: dnf_result |
| 298 |
|
| 299 |
- name: uninstall sos for downloadonly test |
| 300 |
dnf: |
| 301 |
name: sos |
| 302 |
state: absent |
| 303 |
|
| 304 |
- name: Test download_only (check_mode) |
| 305 |
dnf: |
| 306 |
name: sos |
| 307 |
state: latest |
| 308 |
download_only: true |
| 309 |
check_mode: true |
| 310 |
register: dnf_result |
| 311 |
|
| 312 |
- assert: |
| 313 |
that: |
| 314 |
- dnf_result is success |
| 315 |
- "dnf_result.results[0].startswith('Downloaded: ')" |
| 316 |
|
| 317 |
- name: Test download_only |
| 318 |
dnf: |
| 319 |
name: sos |
| 320 |
state: latest |
| 321 |
download_only: true |
| 322 |
register: dnf_result |
| 323 |
|
| 324 |
- name: verify download of sos (part 1 -- dnf "install" succeeded) |
| 325 |
assert: |
| 326 |
that: |
| 327 |
- "dnf_result is success" |
| 328 |
- "dnf_result is changed" |
| 329 |
|
| 330 |
- name: uninstall sos (noop) |
| 331 |
dnf: |
| 332 |
name: sos |
| 333 |
state: absent |
| 334 |
register: dnf_result |
| 335 |
|
| 336 |
- name: verify download of sos (part 2 -- nothing removed during uninstall) |
| 337 |
assert: |
| 338 |
that: |
| 339 |
- "dnf_result is success" |
| 340 |
- "not dnf_result is changed" |
| 341 |
|
| 342 |
- name: uninstall sos for downloadonly/downloaddir test |
| 343 |
dnf: |
| 344 |
name: sos |
| 345 |
state: absent |
| 346 |
|
| 347 |
- name: Test download_only/download_dir |
| 348 |
dnf: |
| 349 |
name: sos |
| 350 |
state: latest |
| 351 |
download_only: true |
| 352 |
download_dir: "/var/tmp/packages" |
| 353 |
register: dnf_result |
| 354 |
|
| 355 |
- name: verify dnf output |
| 356 |
assert: |
| 357 |
that: |
| 358 |
- "dnf_result is success" |
| 359 |
- "dnf_result is changed" |
| 360 |
|
| 361 |
- command: "ls /var/tmp/packages" |
| 362 |
register: ls_out |
| 363 |
|
| 364 |
- name: Verify specified download_dir was used |
| 365 |
assert: |
| 366 |
that: |
| 367 |
- "'sos' in ls_out.stdout" |
| 368 |
|
| 369 |
# GROUP INSTALL |
| 370 |
- name: install Custom Group group |
| 371 |
dnf: |
| 372 |
name: "@Custom Group" |
| 373 |
state: present |
| 374 |
register: dnf_result |
| 375 |
|
| 376 |
- name: check dinginessentail with rpm |
| 377 |
command: rpm -q dinginessentail |
| 378 |
failed_when: False |
| 379 |
register: dinginessentail_result |
| 380 |
|
| 381 |
- name: verify installation of the group |
| 382 |
assert: |
| 383 |
that: |
| 384 |
- not dnf_result is failed |
| 385 |
- dnf_result is changed |
| 386 |
- "'results' in dnf_result" |
| 387 |
- dinginessentail_result.rc == 0 |
| 388 |
|
| 389 |
- name: install the group again |
| 390 |
dnf: |
| 391 |
name: "@Custom Group" |
| 392 |
state: present |
| 393 |
register: dnf_result |
| 394 |
|
| 395 |
- name: verify nothing changed |
| 396 |
assert: |
| 397 |
that: |
| 398 |
- not dnf_result is changed |
| 399 |
- "'msg' in dnf_result" |
| 400 |
|
| 401 |
- name: verify that landsidescalping is not installed |
| 402 |
dnf: |
| 403 |
name: landsidescalping |
| 404 |
state: absent |
| 405 |
|
| 406 |
- name: install the group again but also with a package that is not yet installed |
| 407 |
dnf: |
| 408 |
name: |
| 409 |
- "@Custom Group" |
| 410 |
- landsidescalping |
| 411 |
state: present |
| 412 |
register: dnf_result |
| 413 |
|
| 414 |
- name: check landsidescalping with rpm |
| 415 |
command: rpm -q landsidescalping |
| 416 |
failed_when: False |
| 417 |
register: landsidescalping_result |
| 418 |
|
| 419 |
- name: verify landsidescalping is installed |
| 420 |
assert: |
| 421 |
that: |
| 422 |
- dnf_result is changed |
| 423 |
- "'results' in dnf_result" |
| 424 |
- landsidescalping_result.rc == 0 |
| 425 |
|
| 426 |
- name: try to install the group again, with --check to check 'changed' |
| 427 |
dnf: |
| 428 |
name: "@Custom Group" |
| 429 |
state: present |
| 430 |
check_mode: yes |
| 431 |
register: dnf_result |
| 432 |
|
| 433 |
- name: verify nothing changed |
| 434 |
assert: |
| 435 |
that: |
| 436 |
- not dnf_result is changed |
| 437 |
- "'msg' in dnf_result" |
| 438 |
|
| 439 |
- name: remove landsidescalping after test |
| 440 |
dnf: |
| 441 |
name: landsidescalping |
| 442 |
state: absent |
| 443 |
|
| 444 |
- dnf: |
| 445 |
name: "@Custom Group" |
| 446 |
state: absent |
| 447 |
|
| 448 |
# GROUP UPGRADE - this will go to the same method as group install |
| 449 |
# but through group_update - it is its invocation we're testing here |
| 450 |
# see commit 119c9e5d6eb572c4a4800fbe8136095f9063c37b |
| 451 |
- name: install latest Custom Group |
| 452 |
dnf: |
| 453 |
name: "@Custom Group" |
| 454 |
state: latest |
| 455 |
register: dnf_result |
| 456 |
|
| 457 |
- name: verify installation of the group |
| 458 |
assert: |
| 459 |
that: |
| 460 |
- not dnf_result is failed |
| 461 |
- dnf_result is changed |
| 462 |
- "'results' in dnf_result" |
| 463 |
|
| 464 |
- dnf: |
| 465 |
name: "@Custom Group" |
| 466 |
state: absent |
| 467 |
|
| 468 |
- name: try to install non existing group |
| 469 |
dnf: |
| 470 |
name: "@non-existing-group" |
| 471 |
state: present |
| 472 |
register: dnf_result |
| 473 |
ignore_errors: True |
| 474 |
|
| 475 |
- name: verify installation of the non existing group failed |
| 476 |
assert: |
| 477 |
that: |
| 478 |
- "not dnf_result.changed" |
| 479 |
- "dnf_result is failed" |
| 480 |
|
| 481 |
- name: verify dnf module outputs |
| 482 |
assert: |
| 483 |
that: |
| 484 |
- "'changed' in dnf_result" |
| 485 |
- "'msg' in dnf_result" |
| 486 |
|
| 487 |
- name: try to install non existing file |
| 488 |
dnf: |
| 489 |
name: /tmp/non-existing-1.0.0.fc26.noarch.rpm |
| 490 |
state: present |
| 491 |
register: dnf_result |
| 492 |
ignore_errors: yes |
| 493 |
|
| 494 |
- name: verify installation failed |
| 495 |
assert: |
| 496 |
that: |
| 497 |
- "dnf_result is failed" |
| 498 |
- "not dnf_result.changed" |
| 499 |
|
| 500 |
- name: verify dnf module outputs |
| 501 |
assert: |
| 502 |
that: |
| 503 |
- "'changed' in dnf_result" |
| 504 |
- "'msg' in dnf_result" |
| 505 |
|
| 506 |
- name: try to install from non existing url |
| 507 |
dnf: |
| 508 |
name: https://ci-files.testing.ansible.com/test/integration/targets/dnf/non-existing-1.0.0.fc26.noarch.rpm |
| 509 |
state: present |
| 510 |
register: dnf_result |
| 511 |
ignore_errors: yes |
| 512 |
|
| 513 |
- name: verify installation failed |
| 514 |
assert: |
| 515 |
that: |
| 516 |
- "dnf_result is failed" |
| 517 |
- "not dnf_result.changed" |
| 518 |
- "'Failure downloading' in dnf_result.msg or 'Failed to download' in dnf_result.msg" |
| 519 |
|
| 520 |
- name: verify dnf module outputs |
| 521 |
assert: |
| 522 |
that: |
| 523 |
- "'changed' in dnf_result" |
| 524 |
- "'msg' in dnf_result" |
| 525 |
|
| 526 |
# ENVIRONMENT UPGRADE |
| 527 |
# see commit de299ef77c03a64a8f515033a79ac6b7db1bc710 |
| 528 |
- name: install Custom Environment Group |
| 529 |
dnf: |
| 530 |
name: "@Custom Environment Group" |
| 531 |
state: latest |
| 532 |
register: dnf_result |
| 533 |
|
| 534 |
- name: check landsidescalping with rpm |
| 535 |
command: rpm -q landsidescalping |
| 536 |
register: landsidescalping_result |
| 537 |
|
| 538 |
- name: verify installation of the environment |
| 539 |
assert: |
| 540 |
that: |
| 541 |
- not dnf_result is failed |
| 542 |
- dnf_result is changed |
| 543 |
- "'results' in dnf_result" |
| 544 |
- landsidescalping_result.rc == 0 |
| 545 |
|
| 546 |
- name: uninstall Custom Environment Group |
| 547 |
dnf: |
| 548 |
name: "@Custom Environment Group" |
| 549 |
state: absent |
| 550 |
register: dnf_result |
| 551 |
|
| 552 |
- name: check landsidescalping with rpm |
| 553 |
command: rpm -q landsidescalping |
| 554 |
register: landsidescalping_result |
| 555 |
ignore_errors: yes |
| 556 |
|
| 557 |
- name: verify removal of the environment |
| 558 |
assert: |
| 559 |
that: |
| 560 |
- dnf_result is changed |
| 561 |
- landsidescalping_result.rc != 0 |
| 562 |
|
| 563 |
# https://github.com/ansible/ansible/issues/39704 |
| 564 |
- name: install non-existent rpm, state=latest |
| 565 |
dnf: |
| 566 |
name: non-existent-rpm |
| 567 |
state: latest |
| 568 |
ignore_errors: yes |
| 569 |
register: dnf_result |
| 570 |
|
| 571 |
- name: verify the result |
| 572 |
assert: |
| 573 |
that: |
| 574 |
- "dnf_result is failed" |
| 575 |
- "'non-existent-rpm' in dnf_result['failures'][0]" |
| 576 |
- "'No package non-existent-rpm available' in dnf_result['failures'][0]" |
| 577 |
- "'Failed to install some of the specified packages' in dnf_result['msg']" |
| 578 |
|
| 579 |
- name: ensure sos isn't installed |
| 580 |
dnf: |
| 581 |
name: sos |
| 582 |
state: absent |
| 583 |
|
| 584 |
- name: use latest to install sos |
| 585 |
dnf: |
| 586 |
name: sos |
| 587 |
state: latest |
| 588 |
register: dnf_result |
| 589 |
|
| 590 |
- name: verify sos was installed |
| 591 |
assert: |
| 592 |
that: |
| 593 |
- dnf_result is changed |
| 594 |
|
| 595 |
- name: uninstall sos |
| 596 |
dnf: |
| 597 |
name: sos |
| 598 |
state: removed |
| 599 |
|
| 600 |
- name: update sos only if it exists |
| 601 |
dnf: |
| 602 |
name: sos |
| 603 |
state: latest |
| 604 |
update_only: yes |
| 605 |
register: dnf_result |
| 606 |
|
| 607 |
- name: verify sos not installed |
| 608 |
assert: |
| 609 |
that: |
| 610 |
- "not dnf_result is changed" |
| 611 |
|
| 612 |
- name: try to install not compatible arch rpm, should fail |
| 613 |
dnf: |
| 614 |
name: https://ci-files.testing.ansible.com/test/integration/targets/dnf/banner-1.3.4-3.el7.ppc64le.rpm |
| 615 |
state: present |
| 616 |
register: dnf_result |
| 617 |
ignore_errors: True |
| 618 |
|
| 619 |
- name: verify that dnf failed |
| 620 |
assert: |
| 621 |
that: |
| 622 |
- "not dnf_result is changed" |
| 623 |
- "dnf_result is failed" |
| 624 |
|
| 625 |
- name: try to install an RPM with error in scriptlet |
| 626 |
dnf: |
| 627 |
name: broken-scriptlet |
| 628 |
state: present |
| 629 |
disable_gpg_check: true |
| 630 |
register: dnf_result |
| 631 |
ignore_errors: True |
| 632 |
|
| 633 |
- name: verify that dnf failed |
| 634 |
assert: |
| 635 |
that: |
| 636 |
- "not dnf_result is changed" |
| 637 |
- "dnf_result is failed" |
| 638 |
- dnf_result.failures | length > 0 |
| 639 |
- '"scriptlet failed, exit status 1" in dnf_result.failures[0]' |
| 640 |
|
| 641 |
# setup for testing installing an RPM from local file |
| 642 |
|
| 643 |
- set_fact: |
| 644 |
pkg_name: noarchfake |
| 645 |
pkg_path: '{{ repodir }}/noarchfake-1.0-1.noarch.rpm' |
| 646 |
|
| 647 |
- name: cleanup |
| 648 |
dnf: |
| 649 |
name: "{{ pkg_name }}" |
| 650 |
state: absent |
| 651 |
|
| 652 |
# setup end |
| 653 |
|
| 654 |
- name: install a local noarch rpm from file |
| 655 |
dnf: |
| 656 |
name: "{{ pkg_path }}" |
| 657 |
state: present |
| 658 |
disable_gpg_check: true |
| 659 |
register: dnf_result |
| 660 |
|
| 661 |
- name: verify installation |
| 662 |
assert: |
| 663 |
that: |
| 664 |
- "dnf_result is success" |
| 665 |
- "dnf_result is changed" |
| 666 |
|
| 667 |
- name: install the downloaded rpm again |
| 668 |
dnf: |
| 669 |
name: "{{ pkg_path }}" |
| 670 |
state: present |
| 671 |
register: dnf_result |
| 672 |
|
| 673 |
- name: verify installation |
| 674 |
assert: |
| 675 |
that: |
| 676 |
- "dnf_result is success" |
| 677 |
- "not dnf_result is changed" |
| 678 |
|
| 679 |
- name: clean up |
| 680 |
dnf: |
| 681 |
name: "{{ pkg_name }}" |
| 682 |
state: absent |
| 683 |
|
| 684 |
- name: install from url |
| 685 |
dnf: |
| 686 |
name: "file://{{ pkg_path }}" |
| 687 |
state: present |
| 688 |
disable_gpg_check: true |
| 689 |
register: dnf_result |
| 690 |
|
| 691 |
- name: verify installation |
| 692 |
assert: |
| 693 |
that: |
| 694 |
- "dnf_result is success" |
| 695 |
- "dnf_result is changed" |
| 696 |
- "dnf_result is not failed" |
| 697 |
|
| 698 |
- name: verify dnf module outputs |
| 699 |
assert: |
| 700 |
that: |
| 701 |
- "'changed' in dnf_result" |
| 702 |
- "'results' in dnf_result" |
| 703 |
|
| 704 |
# Install RPM from url with update_only |
| 705 |
- name: install from url with update_only |
| 706 |
dnf: |
| 707 |
name: "file://{{ pkg_path }}" |
| 708 |
state: latest |
| 709 |
update_only: true |
| 710 |
disable_gpg_check: true |
| 711 |
register: dnf_result |
| 712 |
|
| 713 |
- name: verify installation |
| 714 |
assert: |
| 715 |
that: |
| 716 |
- "dnf_result is success" |
| 717 |
- "not dnf_result is changed" |
| 718 |
- "dnf_result is not failed" |
| 719 |
|
| 720 |
- name: verify dnf module outputs |
| 721 |
assert: |
| 722 |
that: |
| 723 |
- "'changed' in dnf_result" |
| 724 |
- "'results' in dnf_result" |
| 725 |
|
| 726 |
- name: Create a temp RPM file which does not contain nevra information |
| 727 |
file: |
| 728 |
name: "/tmp/non_existent_pkg.rpm" |
| 729 |
state: touch |
| 730 |
|
| 731 |
- name: Try installing RPM file which does not contain nevra information |
| 732 |
dnf: |
| 733 |
name: "/tmp/non_existent_pkg.rpm" |
| 734 |
state: present |
| 735 |
register: no_nevra_info_result |
| 736 |
ignore_errors: yes |
| 737 |
|
| 738 |
- name: Verify RPM failed to install |
| 739 |
assert: |
| 740 |
that: |
| 741 |
- "'changed' in no_nevra_info_result" |
| 742 |
- "'msg' in no_nevra_info_result" |
| 743 |
|
| 744 |
- name: Delete a temp RPM file |
| 745 |
file: |
| 746 |
name: "/tmp/non_existent_pkg.rpm" |
| 747 |
state: absent |
| 748 |
|
| 749 |
- name: uninstall lsof |
| 750 |
dnf: |
| 751 |
name: lsof |
| 752 |
state: removed |
| 753 |
|
| 754 |
- name: check lsof with rpm |
| 755 |
shell: rpm -q lsof |
| 756 |
ignore_errors: True |
| 757 |
register: rpm_lsof_result |
| 758 |
|
| 759 |
- name: verify lsof is uninstalled |
| 760 |
assert: |
| 761 |
that: |
| 762 |
- "rpm_lsof_result is failed" |
| 763 |
|
| 764 |
- name: create conf file that excludes lsof |
| 765 |
copy: |
| 766 |
content: | |
| 767 |
[main] |
| 768 |
exclude=lsof* |
| 769 |
dest: '{{ remote_tmp_dir }}/test-dnf.conf' |
| 770 |
register: test_dnf_copy |
| 771 |
|
| 772 |
- block: |
| 773 |
# begin test case where disable_excludes is supported |
| 774 |
- name: Try install lsof without disable_excludes |
| 775 |
dnf: name=lsof state=latest conf_file={{ test_dnf_copy.dest }} |
| 776 |
register: dnf_lsof_result |
| 777 |
ignore_errors: True |
| 778 |
|
| 779 |
- name: verify lsof did not install because it is in exclude list |
| 780 |
assert: |
| 781 |
that: |
| 782 |
- "dnf_lsof_result is failed" |
| 783 |
|
| 784 |
- name: install lsof with disable_excludes |
| 785 |
dnf: name=lsof state=latest disable_excludes=all conf_file={{ test_dnf_copy.dest }} |
| 786 |
register: dnf_lsof_result_using_excludes |
| 787 |
|
| 788 |
- name: verify lsof did install using disable_excludes=all |
| 789 |
assert: |
| 790 |
that: |
| 791 |
- "dnf_lsof_result_using_excludes is success" |
| 792 |
- "dnf_lsof_result_using_excludes is changed" |
| 793 |
- "dnf_lsof_result_using_excludes is not failed" |
| 794 |
always: |
| 795 |
- name: remove exclude lsof conf file |
| 796 |
file: |
| 797 |
path: '{{ remote_tmp_dir }}/test-dnf.conf' |
| 798 |
state: absent |
| 799 |
|
| 800 |
# end test case where disable_excludes is supported |
| 801 |
|
| 802 |
- name: Test "dnf install /usr/bin/vi" |
| 803 |
block: |
| 804 |
- name: Clean vim-minimal |
| 805 |
dnf: |
| 806 |
name: vim-minimal |
| 807 |
state: absent |
| 808 |
|
| 809 |
- name: Install vim-minimal by specifying "/usr/bin/vi" |
| 810 |
dnf: |
| 811 |
name: /usr/bin/vi |
| 812 |
state: present |
| 813 |
|
| 814 |
- name: Get rpm output |
| 815 |
command: rpm -q vim-minimal |
| 816 |
register: rpm_output |
| 817 |
|
| 818 |
- name: Check installation was successful |
| 819 |
assert: |
| 820 |
that: |
| 821 |
- "'vim-minimal' in rpm_output.stdout" |
| 822 |
when: |
| 823 |
- ansible_distribution == 'Fedora' |
| 824 |
|
| 825 |
- name: Remove wildcard package that isn't installed |
| 826 |
dnf: |
| 827 |
name: firefox* |
| 828 |
state: absent |
| 829 |
register: wildcard_absent |
| 830 |
|
| 831 |
- assert: |
| 832 |
that: |
| 833 |
- wildcard_absent is successful |
| 834 |
- wildcard_absent is not changed |
| 835 |
|
| 836 |
- name: Test removing with various package specs |
| 837 |
block: |
| 838 |
- name: Ensure sos is installed |
| 839 |
dnf: |
| 840 |
name: sos |
| 841 |
state: present |
| 842 |
|
| 843 |
- name: Determine version of sos |
| 844 |
command: rpm -q --queryformat=%{version} sos |
| 845 |
register: sos_version_command |
| 846 |
|
| 847 |
- name: Determine release of sos |
| 848 |
command: rpm -q --queryformat=%{release} sos |
| 849 |
register: sos_release_command |
| 850 |
|
| 851 |
- name: Determine arch of sos |
| 852 |
command: rpm -q --queryformat=%{arch} sos |
| 853 |
register: sos_arch_command |
| 854 |
|
| 855 |
- set_fact: |
| 856 |
sos_version: "{{ sos_version_command.stdout | trim }}" |
| 857 |
sos_release: "{{ sos_release_command.stdout | trim }}" |
| 858 |
sos_arch: "{{ sos_arch_command.stdout | trim }}" |
| 859 |
|
| 860 |
# We are just trying to remove the package by specifying its spec in a |
| 861 |
# bunch of different ways. Each "item" here is a test (a name passed, to make |
| 862 |
# sure it matches, with how we call Hawkey in the dnf module). |
| 863 |
- include_tasks: test_sos_removal.yml |
| 864 |
with_items: |
| 865 |
- sos |
| 866 |
- sos-{{ sos_version }} |
| 867 |
- sos-{{ sos_version }}-{{ sos_release }} |
| 868 |
- sos-{{ sos_version }}-{{ sos_release }}.{{ sos_arch }} |
| 869 |
- sos-*-{{ sos_release }} |
| 870 |
- sos-{{ sos_version[0] }}* |
| 871 |
- sos-{{ sos_version[0] }}*-{{ sos_release }} |
| 872 |
- sos-{{ sos_version[0] }}*{{ sos_arch }} |
| 873 |
|
| 874 |
- name: Ensure deleting a non-existing package fails correctly |
| 875 |
dnf: |
| 876 |
name: a-non-existent-package |
| 877 |
state: absent |
| 878 |
ignore_errors: true |
| 879 |
register: nonexisting |
| 880 |
|
| 881 |
- assert: |
| 882 |
that: |
| 883 |
- nonexisting is success |
| 884 |
- nonexisting.msg == 'Nothing to do' |
| 885 |
|
| 886 |
# running on RHEL which is --remote where .mo language files are present |
| 887 |
# for dnf as opposed to in --docker |
| 888 |
- when: ansible_distribution == 'RedHat' |
| 889 |
block: |
| 890 |
- dnf: |
| 891 |
name: langpacks-ja |
| 892 |
state: present |
| 893 |
|
| 894 |
- dnf: |
| 895 |
name: nginx-mod* |
| 896 |
state: absent |
| 897 |
environment: |
| 898 |
LANG: ja_JP.UTF-8 |
| 899 |
always: |
| 900 |
- dnf: |
| 901 |
name: langpacks-ja |
| 902 |
state: absent |
| 903 |
|
| 904 |
- name: test passing non existing plugins, should fail |
| 905 |
block: |
| 906 |
- dnf: |
| 907 |
name: sos |
| 908 |
enable_plugin: nonexisting |
| 909 |
ignore_errors: true |
| 910 |
register: enable_plugin_result |
| 911 |
|
| 912 |
- dnf: |
| 913 |
name: sos |
| 914 |
disable_plugin: nonexisting |
| 915 |
ignore_errors: true |
| 916 |
register: disable_plugin_result |
| 917 |
|
| 918 |
- assert: |
| 919 |
that: |
| 920 |
- enable_plugin_result is failed |
| 921 |
- disable_plugin_result is failed |
| 922 |
- '"No matches were found for the following plugin name patterns while enabling libdnf5 plugins: " in enable_plugin_result.msg' |
| 923 |
- '"No matches were found for the following plugin name patterns while disabling libdnf5 plugins: " in disable_plugin_result.msg' |
| 924 |
- '"nonexisting" in enable_plugin_result.msg' |
| 925 |
- '"nonexisting" in disable_plugin_result.msg' |
| 926 |
when: dnf5 |