|
72 | 72 | # configuration. Most commonly used are on-failure or always.
|
73 | 73 | # Default: on-failure
|
74 | 74 | #
|
| 75 | +# [*custom_unless*] |
| 76 | +# (optional) Specify an additional unless for the Docker run command when using restart. |
| 77 | +# Default: undef |
| 78 | +# |
75 | 79 | define docker::run(
|
76 | 80 | Optional[Pattern[/^[\S]*$/]] $image,
|
77 | 81 | Optional[Pattern[/^present$|^absent$/]] $ensure = 'present',
|
|
126 | 130 | Optional[String] $health_check_cmd = undef,
|
127 | 131 | Optional[Boolean] $restart_on_unhealthy = false,
|
128 | 132 | Optional[Integer] $health_check_interval = undef,
|
| 133 | + Optional[Array] $custom_unless = undef, |
129 | 134 | ) {
|
130 | 135 | include docker::params
|
131 | 136 | if ($socket_connect != []) {
|
|
274 | 279 | "--name ${sanitised_title} --cidfile=${cidfile}",
|
275 | 280 | "--restart=\"${restart}\" ${image} ${command}",
|
276 | 281 | ]
|
| 282 | + $inspect = ["${docker_command} inspect ${sanitised_title}"] |
| 283 | + if $custom_unless { |
| 284 | + $exec_unless = concat($custom_unless, $inspect) |
| 285 | + } else { |
| 286 | + $exec_unless = $inspect |
| 287 | + } |
277 | 288 | exec { "run ${title} with docker":
|
278 | 289 | command => join($run_with_docker_command, ' '),
|
279 |
| - unless => "${docker_command} inspect ${sanitised_title}", |
| 290 | + unless => $exec_unless, |
280 | 291 | environment => $exec_environment,
|
281 | 292 | path => $exec_path,
|
282 | 293 | provider => $exec_provider,
|
|
0 commit comments