This repository was archived by the owner on Aug 18, 2020. It is now read-only.
forked from puppetlabs/puppetlabs-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistry.pp
72 lines (67 loc) · 1.96 KB
/
registry.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# == Class: docker
#
# Module to configure private docker registries from which to pull Docker images
# If the registry does not require authentication, this module is not required.
#
# === Parameters
# [*server*]
# The hostname and port of the private Docker registry. Ex: dockerreg:5000
#
# [*ensure*]
# Whether or not you want to login or logout of a repository
#
# [*username*]
# Username for authentication to private Docker registry.
# auth is not required.
#
# [*password*]
# Password for authentication to private Docker registry. Leave undef if
# auth is not required.
#
# [*email*]
# Email for registration to private Docker registry. Leave undef if
# auth is not required.
#
# [*local_user*]
# The local user to log in as. Docker will store credentials in this
# users home directory
#
#
define docker::registry(
$server = $title,
$ensure = 'present',
$username = undef,
$password = undef,
$email = undef,
$local_user = 'root',
) {
include docker::params
validate_re($ensure, '^(present|absent)$')
$docker_command = $docker::params::docker_command
if $ensure == 'present' {
if $username != undef and $password != undef and $email != undef {
$auth_cmd = "${docker_command} login -u '${username}' -p \"\${password}\" -e '${email}' ${server}"
$auth_environment = "password=${password}"
}
elsif $username != undef and $password != undef {
$auth_cmd = "${docker_command} login -u '${username}' -p \"\${password}\" ${server}"
$auth_environment = "password=${password}"
}
else {
$auth_cmd = "${docker_command} login ${server}"
$auth_environment = undef
}
}
else {
$auth_cmd = "${docker_command} logout ${server}"
$auth_environment = undef
}
exec { "${title} auth":
environment => $auth_environment,
command => $auth_cmd,
user => $local_user,
cwd => '/root',
path => ['/bin', '/usr/bin'],
timeout => 0,
}
}