|
373 | 373 | }
|
374 | 374 |
|
375 | 375 | if $restart_on_unhealthy {
|
| 376 | + $unhealthy_command = [$docker_command, 'restart', $sanitised_title] |
| 377 | + |
376 | 378 | exec { "Restart unhealthy container ${title} with docker":
|
377 |
| - command => "${docker_command} restart ${sanitised_title}", |
| 379 | + command => $unhealthy_command, |
378 | 380 | onlyif => $restart_check,
|
379 | 381 | environment => $exec_environment,
|
380 | 382 | path => $exec_path,
|
|
385 | 387 |
|
386 | 388 | if $restart {
|
387 | 389 | 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 | + |
388 | 393 | exec { "stop ${title} with docker":
|
389 |
| - command => "${docker_command} stop --time=${stop_wait_time} ${sanitised_title}", |
390 |
| - onlyif => "${docker_command} inspect ${sanitised_title}", |
| 394 | + command => $restart_stop_command, |
| 395 | + onlyif => $restart_stop_onlyif, |
391 | 396 | environment => $exec_environment,
|
392 | 397 | path => $exec_path,
|
393 | 398 | provider => $exec_provider,
|
394 | 399 | timeout => $exec_timeout,
|
395 | 400 | }
|
396 | 401 |
|
| 402 | + $restart_remove_command = "${docker_command} rm -v ${sanitised_title}" |
| 403 | + $restart_remove_onlyif = [[$docker_command, 'inspect', $sanitised_title]] |
| 404 | + |
397 | 405 | exec { "remove ${title} with docker":
|
398 |
| - command => "${docker_command} rm -v ${sanitised_title}", |
399 |
| - onlyif => "${docker_command} inspect ${sanitised_title}", |
| 406 | + command => $restart_remove_command, |
| 407 | + onlyif => $restart_remove_onlyif, |
400 | 408 | environment => $exec_environment,
|
401 | 409 | path => $exec_path,
|
402 | 410 | provider => $exec_provider,
|
|
421 | 429 | $exec_unless = $inspect
|
422 | 430 | }
|
423 | 431 |
|
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 |
| - } |
| 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 | + } |
469 | 447 |
|
470 |
| - $detect_changes = Deferred('docker_params_changed', [$docker_params_changed_args]) |
| 448 | + $detect_changes = Deferred('docker_params_changed', [$docker_params_changed_args]) |
471 | 449 |
|
472 |
| - notify { "${title}_docker_params_changed": |
473 |
| - message => $detect_changes, |
474 |
| - } |
| 450 | + notify { "${title}_docker_params_changed": |
| 451 | + message => $detect_changes, |
475 | 452 | }
|
476 | 453 | }
|
477 | 454 | } else {
|
|
517 | 494 |
|
518 | 495 | if $ensure == 'absent' {
|
519 | 496 | 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 | + |
520 | 500 | exec { "stop container ${service_prefix}${sanitised_title}":
|
521 |
| - command => "${docker_command} stop --time=${stop_wait_time} ${sanitised_title}", |
522 |
| - onlyif => "${docker_command} inspect ${sanitised_title}", |
| 501 | + command => $absent_stop_command, |
| 502 | + onlyif => $absent_stop_onlyif, |
523 | 503 | environment => $exec_environment,
|
524 | 504 | path => $exec_path,
|
525 | 505 | provider => $exec_provider,
|
|
536 | 516 | notify => Exec["remove container ${service_prefix}${sanitised_title}"],
|
537 | 517 | }
|
538 | 518 | }
|
| 519 | + $absent_remove_command = "${docker_command} rm -v ${sanitised_title}" |
| 520 | + $absent_remove_onlyif = "${docker_command} inspect ${sanitised_title}" |
| 521 | + |
539 | 522 | exec { "remove container ${service_prefix}${sanitised_title}":
|
540 |
| - command => "${docker_command} rm -v ${sanitised_title}", |
541 |
| - onlyif => "${docker_command} inspect ${sanitised_title}", |
| 523 | + command => $absent_remove_command, |
| 524 | + onlyif => $absent_remove_onlyif, |
542 | 525 | environment => $exec_environment,
|
543 | 526 | path => $exec_path,
|
544 | 527 | refreshonly => true,
|
|
0 commit comments