|
373 | 373 | } |
374 | 374 |
|
375 | 375 | if $restart_on_unhealthy { |
376 | | - $unhealthy_command = [$docker_command, 'restart', $sanitised_title] |
377 | | - |
378 | 376 | exec { "Restart unhealthy container ${title} with docker": |
379 | | - command => $unhealthy_command, |
| 377 | + command => "${docker_command} restart ${sanitised_title}", |
380 | 378 | onlyif => $restart_check, |
381 | 379 | environment => $exec_environment, |
382 | 380 | path => $exec_path, |
|
387 | 385 |
|
388 | 386 | if $restart { |
389 | 387 | if $ensure == 'absent' { |
390 | | - $restart_stop_command = [$docker_command, 'stop', '--time', $stop_wait_time, $sanitised_title] |
391 | | - $restart_stop_onlyif = [[$docker_command, 'inspect', $sanitised_title]] |
392 | | - |
393 | 388 | exec { "stop ${title} with docker": |
394 | | - command => $restart_stop_command, |
395 | | - onlyif => $restart_stop_onlyif, |
| 389 | + command => "${docker_command} stop --time=${stop_wait_time} ${sanitised_title}", |
| 390 | + onlyif => "${docker_command} inspect ${sanitised_title}", |
396 | 391 | environment => $exec_environment, |
397 | 392 | path => $exec_path, |
398 | 393 | provider => $exec_provider, |
399 | 394 | timeout => $exec_timeout, |
400 | 395 | } |
401 | 396 |
|
402 | | - $restart_remove_command = "${docker_command} rm -v ${sanitised_title}" |
403 | | - $restart_remove_onlyif = [[$docker_command, 'inspect', $sanitised_title]] |
404 | | - |
405 | 397 | exec { "remove ${title} with docker": |
406 | | - command => $restart_remove_command, |
407 | | - onlyif => $restart_remove_onlyif, |
| 398 | + command => "${docker_command} rm -v ${sanitised_title}", |
| 399 | + onlyif => "${docker_command} inspect ${sanitised_title}", |
408 | 400 | environment => $exec_environment, |
409 | 401 | path => $exec_path, |
410 | 402 | provider => $exec_provider, |
|
429 | 421 | $exec_unless = $inspect |
430 | 422 | } |
431 | 423 |
|
432 | | - $docker_params_changed_args = { |
433 | | - sanitised_title => $sanitised_title, |
434 | | - osfamily => $facts['os']['family'], |
435 | | - command => join($run_with_docker_command, ' '), |
436 | | - cidfile => $cidfile, |
437 | | - image => $image, |
438 | | - volumes => $volumes, |
439 | | - ports => $ports, |
440 | | - stop_wait_time => $stop_wait_time, |
441 | | - container_running => $running, |
442 | | - # logfile_path => ($facts['os']['family'] == 'windows') ? { |
443 | | - # true => ::docker_user_temp_path, |
444 | | - # default => '/tmp', |
445 | | - # }, |
446 | | - } |
| 424 | + if versioncmp($facts['puppetversion'], '6') < 0 { |
| 425 | + exec { "run ${title} with docker": |
| 426 | + command => join($run_with_docker_command, ' '), |
| 427 | + unless => $exec_unless, |
| 428 | + environment => $exec_environment, |
| 429 | + path => $exec_path, |
| 430 | + provider => $exec_provider, |
| 431 | + timeout => $exec_timeout, |
| 432 | + } |
| 433 | + |
| 434 | + if $running == false { |
| 435 | + exec { "stop ${title} with docker": |
| 436 | + command => "${docker_command} stop --time=${stop_wait_time} ${sanitised_title}", |
| 437 | + onlyif => $container_running_check, |
| 438 | + environment => $exec_environment, |
| 439 | + path => $exec_path, |
| 440 | + provider => $exec_provider, |
| 441 | + timeout => $exec_timeout, |
| 442 | + } |
| 443 | + } else { |
| 444 | + exec { "start ${title} with docker": |
| 445 | + command => "${docker_command} start ${sanitised_title}", |
| 446 | + unless => $container_running_check, |
| 447 | + environment => $exec_environment, |
| 448 | + path => $exec_path, |
| 449 | + provider => $exec_provider, |
| 450 | + timeout => $exec_timeout, |
| 451 | + } |
| 452 | + } |
| 453 | + } else { |
| 454 | + $docker_params_changed_args = { |
| 455 | + sanitised_title => $sanitised_title, |
| 456 | + osfamily => $facts['os']['family'], |
| 457 | + command => join($run_with_docker_command, ' '), |
| 458 | + cidfile => $cidfile, |
| 459 | + image => $image, |
| 460 | + volumes => $volumes, |
| 461 | + ports => $ports, |
| 462 | + stop_wait_time => $stop_wait_time, |
| 463 | + container_running => $running, |
| 464 | + # logfile_path => ($facts['os']['family'] == 'windows') ? { |
| 465 | + # true => ::docker_user_temp_path, |
| 466 | + # default => '/tmp', |
| 467 | + # }, |
| 468 | + } |
447 | 469 |
|
448 | | - $detect_changes = Deferred('docker_params_changed', [$docker_params_changed_args]) |
| 470 | + $detect_changes = Deferred('docker_params_changed', [$docker_params_changed_args]) |
449 | 471 |
|
450 | | - notify { "${title}_docker_params_changed": |
451 | | - message => $detect_changes, |
| 472 | + notify { "${title}_docker_params_changed": |
| 473 | + message => $detect_changes, |
| 474 | + } |
452 | 475 | } |
453 | 476 | } |
454 | 477 | } else { |
|
494 | 517 |
|
495 | 518 | if $ensure == 'absent' { |
496 | 519 | if $facts['os']['family'] == 'windows' { |
497 | | - $absent_stop_command = "${docker_command} stop --time ${stop_wait_time} ${sanitised_title}" |
498 | | - $absent_stop_onlyif = "${docker_command} inspect ${sanitised_title}" |
499 | | - |
500 | 520 | exec { "stop container ${service_prefix}${sanitised_title}": |
501 | | - command => $absent_stop_command, |
502 | | - onlyif => $absent_stop_onlyif, |
| 521 | + command => "${docker_command} stop --time=${stop_wait_time} ${sanitised_title}", |
| 522 | + onlyif => "${docker_command} inspect ${sanitised_title}", |
503 | 523 | environment => $exec_environment, |
504 | 524 | path => $exec_path, |
505 | 525 | provider => $exec_provider, |
|
516 | 536 | notify => Exec["remove container ${service_prefix}${sanitised_title}"], |
517 | 537 | } |
518 | 538 | } |
519 | | - $absent_remove_command = "${docker_command} rm -v ${sanitised_title}" |
520 | | - $absent_remove_onlyif = "${docker_command} inspect ${sanitised_title}" |
521 | | - |
522 | 539 | exec { "remove container ${service_prefix}${sanitised_title}": |
523 | | - command => $absent_remove_command, |
524 | | - onlyif => $absent_remove_onlyif, |
| 540 | + command => "${docker_command} rm -v ${sanitised_title}", |
| 541 | + onlyif => "${docker_command} inspect ${sanitised_title}", |
525 | 542 | environment => $exec_environment, |
526 | 543 | path => $exec_path, |
527 | 544 | refreshonly => true, |
|
0 commit comments