Skip to content

Commit b71811e

Browse files
esalbergdavejrt
authored andcommitted
add custom_unless (#324)
1 parent 942f859 commit b71811e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Diff for: manifests/run.pp

+12-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
# configuration. Most commonly used are on-failure or always.
7373
# Default: on-failure
7474
#
75+
# [*custom_unless*]
76+
# (optional) Specify an additional unless for the Docker run command when using restart.
77+
# Default: undef
78+
#
7579
define docker::run(
7680
Optional[Pattern[/^[\S]*$/]] $image,
7781
Optional[Pattern[/^present$|^absent$/]] $ensure = 'present',
@@ -126,6 +130,7 @@
126130
Optional[String] $health_check_cmd = undef,
127131
Optional[Boolean] $restart_on_unhealthy = false,
128132
Optional[Integer] $health_check_interval = undef,
133+
Optional[Array] $custom_unless = undef,
129134
) {
130135
include docker::params
131136
if ($socket_connect != []) {
@@ -274,9 +279,15 @@
274279
"--name ${sanitised_title} --cidfile=${cidfile}",
275280
"--restart=\"${restart}\" ${image} ${command}",
276281
]
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+
}
277288
exec { "run ${title} with docker":
278289
command => join($run_with_docker_command, ' '),
279-
unless => "${docker_command} inspect ${sanitised_title}",
290+
unless => $exec_unless,
280291
environment => $exec_environment,
281292
path => $exec_path,
282293
provider => $exec_provider,

0 commit comments

Comments
 (0)