|
53 | 53 | $exec_path = ['c:/Windows/Temp/', 'C:/Program Files/Docker/']
|
54 | 54 | $exec_provider = 'powershell'
|
55 | 55 | $password_env = '$env:password'
|
| 56 | + $exec_user = undef |
56 | 57 | } else {
|
57 | 58 | $exec_environment = ['HOME=/root']
|
58 | 59 | $exec_path = ['/bin', '/usr/bin']
|
59 | 60 | $exec_timeout = 0
|
60 | 61 | $exec_provider = undef
|
61 | 62 | $password_env = "\${password}"
|
| 63 | + $exec_user = $local_user |
62 | 64 | }
|
63 | 65 |
|
64 | 66 | if $ensure == 'present' {
|
|
67 | 69 | $auth_environment = "password=${password}"
|
68 | 70 | }
|
69 | 71 | elsif $username != undef and $password != undef {
|
70 |
| - $auth_cmd = "${docker_command} login -u '${username}' -p ${password_env} ${server}" |
| 72 | + $auth_cmd = "${docker_command} login -u '${username}' -p '${password_env}' ${server}" |
71 | 73 | $auth_environment = "password=${password}"
|
72 | 74 | }
|
73 | 75 | else {
|
|
80 | 82 | $auth_environment = ''
|
81 | 83 | }
|
82 | 84 |
|
| 85 | + $docker_auth = "${title}${auth_environment}${auth_cmd}${local_user}" |
83 | 86 | if $receipt {
|
84 | 87 |
|
85 | 88 | # server may be an URI, which can contain /
|
|
90 | 93 | $local_user_strip = regsubst($local_user, '-', '', 'G')
|
91 | 94 |
|
92 | 95 | $_pass_hash = $pass_hash ? {
|
93 |
| - Undef => pw_hash("${title}${auth_environment}${auth_cmd}${local_user}", 'SHA-512', $local_user_strip), |
| 96 | + Undef => pw_hash($docker_auth, 'SHA-512', $local_user_strip), |
94 | 97 | default => $pass_hash
|
95 | 98 | }
|
96 | 99 | $_auth_command = "${auth_cmd} || rm -f \"/root/registry-auth-puppet_receipt_${server_strip}_${local_user}\""
|
|
101 | 104 | notify => Exec["${title} auth"],
|
102 | 105 | }
|
103 | 106 | } else {
|
104 |
| - $pass = "${title}${auth_environment}${auth_cmd}${local_user}" |
105 | 107 | $_auth_command = $auth_cmd
|
106 | 108 | $pw_hash_path = 'C:/Windows/Temp/compute_hash.ps1'
|
107 | 109 | $passfile = "C:/Windows/Temp/registry-auth-puppet_receipt_${server_strip}_${local_user}"
|
|
124 | 126 | $_auth_command = $auth_cmd
|
125 | 127 | }
|
126 | 128 |
|
| 129 | + if $auth_environment != '' { |
| 130 | + $exec_env = concat($exec_environment, $auth_environment, "docker_auth=${docker_auth}") |
| 131 | + } else { |
| 132 | + $exec_env = concat($exec_environment, "docker_auth=${docker_auth}") |
| 133 | + } |
| 134 | + |
127 | 135 | exec { "${title} auth":
|
128 |
| - environment => concat($exec_environment, $auth_environment), |
| 136 | + environment => $exec_env, |
129 | 137 | command => $_auth_command,
|
130 |
| - #user => $local_user, |
| 138 | + user => $exec_user, |
131 | 139 | path => $exec_path,
|
132 | 140 | timeout => $exec_timeout,
|
133 | 141 | provider => $exec_provider,
|
|
0 commit comments