diff --git a/manifests/registry.pp b/manifests/registry.pp index d85c6138f..3f2b7fb1d 100644 --- a/manifests/registry.pp +++ b/manifests/registry.pp @@ -34,6 +34,8 @@ $password = undef, $email = undef, $local_user = 'root', + $version = $docker::version, + $receipt = true, ) { include docker::params @@ -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}" } @@ -60,6 +62,17 @@ $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, @@ -67,6 +80,7 @@ cwd => '/root', path => ['/bin', '/usr/bin'], timeout => 0, + refreshonly => $receipt, } }