Skip to content

Commit

Permalink
Backport: adding in logic to make docker::registry idempodent
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas Theunissen committed Dec 27, 2017
1 parent d8587b2 commit 4fb98fc
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion manifests/registry.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
$password = undef,
$email = undef,
$local_user = 'root',
$version = $docker::version,
$receipt = true,
) {
include docker::params

Expand All @@ -42,7 +44,7 @@
$docker_command = $docker::params::docker_command

if $ensure == 'present' {
if $username != undef and $password != undef and $email != undef {
if $username != undef and $password != undef and $email != undef and $version =~ /1[.][1-9]0?/ {
$auth_cmd = "${docker_command} login -u '${username}' -p \"\${password}\" -e '${email}' ${server}"
$auth_environment = "password=${password}"
}
Expand All @@ -60,13 +62,25 @@
$auth_environment = undef
}

if $receipt {
# no - with pw_hash
$local_user_strip = regsubst($local_user, '-', '', 'G')

file { "/root/registry-auth-puppet_receipt_${server}_${local_user}":
ensure => $ensure,
content => pw_hash("${title}${auth_environment}${auth_cmd}${local_user}", 'SHA-512', $local_user_strip),
notify => Exec["${title} auth"],
}
}

exec { "${title} auth":
environment => $auth_environment,
command => $auth_cmd,
user => $local_user,
cwd => '/root',
path => ['/bin', '/usr/bin'],
timeout => 0,
refreshonly => $receipt,
}

}

0 comments on commit 4fb98fc

Please sign in to comment.