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 pathcompose.pp
72 lines (67 loc) · 2.07 KB
/
compose.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::compose
#
# Class to install Docker Compose using the recommended curl command.
#
# === Parameters
#
# [*ensure*]
# Whether to install or remove Docker Compose
# Valid values are absent present
# Defaults to present
#
# [*version*]
# The version of Docker Compose to install.
# Defaults to the value set in $docker::params::compose_version
#
# [*install_path*]
# The path where to install Docker Compose.
# Defaults to the value set in $docker::params::compose_install_path
#
# [*proxy*]
# Proxy to use for downloading Docker Compose.
#
class docker::compose(
$ensure = 'present',
$version = $docker::params::compose_version,
$install_path = $docker::params::compose_install_path,
$proxy = undef
) inherits docker::params {
validate_string($version)
validate_re($ensure, '^(present|absent)$')
validate_absolute_path($install_path)
if $proxy != undef {
validate_re($proxy, '^(https?:\/\/)?([^:^@]+:[^:^@]+@|)([\da-z\.-]+)\.([a-z\.]{2,6})(:[\d])?([\/\w \.-]*)*\/?$')
}
if $ensure == 'present' {
ensure_packages(['curl'])
if $proxy != undef {
$proxy_opt = "--proxy ${proxy}"
} else {
$proxy_opt = ''
}
exec { "Install Docker Compose ${version}":
path => '/usr/bin/',
cwd => '/tmp',
command => "curl -s -L ${proxy_opt} https://github.com/docker/compose/releases/download/${version}/docker-compose-${::kernel}-x86_64 > ${install_path}/docker-compose-${version}",
creates => "${install_path}/docker-compose-${version}",
require => Package['curl'],
}
file { "${install_path}/docker-compose-${version}":
owner => 'root',
mode => '0755',
require => Exec["Install Docker Compose ${version}"]
}
file { "${install_path}/docker-compose":
ensure => 'link',
target => "${install_path}/docker-compose-${version}",
require => File["${install_path}/docker-compose-${version}"]
}
} else {
file { [
"${install_path}/docker-compose-${version}",
"${install_path}/docker-compose"
]:
ensure => absent,
}
}
}