|
42 | 42 | Optional[String] $raw_url = undef,
|
43 | 43 | Optional[Boolean] $curl_ensure = $docker::params::curl_ensure,
|
44 | 44 | ) inherits docker::params {
|
45 |
| - if $facts['os']['family'] == 'windows' { |
46 |
| - $file_extension = '.exe' |
47 |
| - $file_owner = 'Administrator' |
48 |
| - } else { |
49 |
| - $file_extension = '' |
50 |
| - $file_owner = 'root' |
51 |
| - } |
52 | 45 |
|
53 |
| - $docker_compose_location = "${install_path}/${symlink_name}${file_extension}" |
54 |
| - $docker_compose_location_versioned = "${install_path}/docker-compose-${version}${file_extension}" |
55 |
| - $docker_plugins_path = '/usr/local/lib/docker/cli-plugins' |
56 |
| - |
57 |
| - if $ensure == 'present' { |
58 |
| - if $raw_url != undef { |
59 |
| - $docker_compose_url = $raw_url |
60 |
| - } else { |
61 |
| - if $version =~ /2[.]\d+[.]\d+$/ { |
62 |
| - $version_prepath = 'v' |
| 46 | + if $facts['kernel'] == 'Linux' { |
| 47 | + case $facts['os']['family'] { |
| 48 | + 'Debian': { |
| 49 | + ensure_packages('docker-compose-plugin', { ensure => pick($version,$ensure), require => defined(bool2str($docker::use_upstream_package_source)) ? { true => Apt::Source['docker'], false => undef } }) #lint:ignore:140chars |
63 | 50 | }
|
64 |
| - |
65 |
| - $docker_compose_url = "${base_url}/${version_prepath}${version}/docker-compose-${facts['kernel']}-${facts['os']['hardware']}${file_extension}" |
| 51 | + 'RedHat': { |
| 52 | + ensure_packages('docker-compose-plugin', { ensure => pick($version,$ensure), require => defined(bool2str($docker::use_upstream_package_source)) ? { true => Yumrepo['docker'], false => undef } }) #lint:ignore:140chars lint:ignore:unquoted_string_in_selector |
| 53 | + } |
| 54 | + default: {} |
66 | 55 | }
|
67 |
| - |
68 |
| - if $proxy != undef { |
69 |
| - $proxy_opt = "--proxy ${proxy}" |
| 56 | + } else { |
| 57 | + # mac & Windows OS |
| 58 | + if $facts['os']['family'] == 'windows' { |
| 59 | + $file_extension = '.exe' |
| 60 | + $file_owner = 'Administrator' |
70 | 61 | } else {
|
71 |
| - $proxy_opt = '' |
| 62 | + $file_extension = '' |
| 63 | + $file_owner = 'root' |
72 | 64 | }
|
73 | 65 |
|
74 |
| - if $facts['os']['family'] == 'windows' { |
75 |
| - $docker_download_command = "if (Invoke-WebRequest ${docker_compose_url} ${proxy_opt} -UseBasicParsing -OutFile \"${docker_compose_location_versioned}\") { exit 0 } else { exit 1}" # lint:ignore:140chars |
| 66 | + $docker_compose_location = "${install_path}/${symlink_name}${file_extension}" |
76 | 67 |
|
77 |
| - $parameters = { |
78 |
| - 'proxy' => $proxy, |
79 |
| - 'docker_compose_url' => $docker_compose_url, |
80 |
| - 'docker_compose_location_versioned' => $docker_compose_location_versioned, |
81 |
| - } |
| 68 | + if $version == 'latest' { |
| 69 | + $version = "2.20.2" |
| 70 | + } |
82 | 71 |
|
83 |
| - exec { "Install Docker Compose ${version}": |
84 |
| - command => epp('docker/windows/download_docker_compose.ps1.epp', $parameters), |
85 |
| - provider => powershell, |
86 |
| - creates => $docker_compose_location_versioned, |
87 |
| - } |
| 72 | + $docker_compose_location_versioned = "${install_path}/docker-compose-${version}${file_extension}" |
88 | 73 |
|
89 |
| - file { $docker_compose_location: |
90 |
| - ensure => 'link', |
91 |
| - target => $docker_compose_location_versioned, |
92 |
| - require => Exec["Install Docker Compose ${version}"], |
93 |
| - } |
94 |
| - } else { |
95 |
| - if $curl_ensure { |
96 |
| - stdlib::ensure_packages(['curl']) |
97 |
| - } |
| 74 | + if $ensure == 'present' { |
| 75 | + if $raw_url != undef { |
| 76 | + $docker_compose_url = $raw_url |
| 77 | + } else { |
| 78 | + if $version =~ /2[.]\d+[.]\d+$/ { |
| 79 | + $version_prepath = 'v' |
| 80 | + } |
98 | 81 |
|
99 |
| - exec { "Install Docker Compose ${version}": |
100 |
| - path => '/usr/bin/', |
101 |
| - cwd => '/tmp', |
102 |
| - command => "curl -s -S -L ${proxy_opt} ${docker_compose_url} -o ${docker_compose_location_versioned}", |
103 |
| - creates => $docker_compose_location_versioned, |
104 |
| - require => Package['curl'], |
| 82 | + $docker_compose_url = "${base_url}/${version_prepath}${version}/docker-compose-${facts['kernel']}-${facts['os']['hardware']}${file_extension}" |
105 | 83 | }
|
106 | 84 |
|
107 |
| - file { '/usr/local/lib/docker': |
108 |
| - ensure => directory, |
| 85 | + if $proxy != undef { |
| 86 | + $proxy_opt = "--proxy ${proxy}" |
| 87 | + } else { |
| 88 | + $proxy_opt = '' |
109 | 89 | }
|
110 | 90 |
|
111 |
| - file { $docker_plugins_path: |
112 |
| - ensure => directory, |
113 |
| - require => File['/usr/local/lib/docker'], |
114 |
| - } |
| 91 | + if $facts['os']['family'] == 'windows' { |
| 92 | + $docker_download_command = "if (Invoke-WebRequest ${docker_compose_url} ${proxy_opt} -UseBasicParsing -OutFile \"${docker_compose_location_versioned}\") { exit 0 } else { exit 1}" # lint:ignore:140chars |
115 | 93 |
|
| 94 | + $parameters = { |
| 95 | + 'proxy' => $proxy, |
| 96 | + 'docker_compose_url' => $docker_compose_url, |
| 97 | + 'docker_compose_location_versioned' => $docker_compose_location_versioned, |
| 98 | + } |
| 99 | + |
| 100 | + exec { "Install Docker Compose ${version}": |
| 101 | + command => epp('docker/windows/download_docker_compose.ps1.epp', $parameters), |
| 102 | + provider => powershell, |
| 103 | + creates => $docker_compose_location_versioned, |
| 104 | + } |
| 105 | + |
| 106 | + file { $docker_compose_location: |
| 107 | + ensure => 'link', |
| 108 | + target => $docker_compose_location_versioned, |
| 109 | + require => Exec["Install Docker Compose ${version}"], |
| 110 | + } |
| 111 | + } else { |
| 112 | + if $curl_ensure { |
| 113 | + stdlib::ensure_packages(['curl']) |
| 114 | + } |
| 115 | + |
| 116 | + exec { "Install Docker Compose ${version}": |
| 117 | + path => '/usr/bin/', |
| 118 | + cwd => '/tmp', |
| 119 | + command => "curl -s -S -L ${proxy_opt} ${docker_compose_url} -o ${docker_compose_location_versioned}", |
| 120 | + creates => $docker_compose_location_versioned, |
| 121 | + require => Package['curl'], |
| 122 | + } |
| 123 | + |
| 124 | + file { $docker_compose_location_versioned: |
| 125 | + owner => $file_owner, |
| 126 | + mode => '0755', |
| 127 | + seltype => 'container_runtime_exec_t', |
| 128 | + require => Exec["Install Docker Compose ${version}"], |
| 129 | + } |
| 130 | + |
| 131 | + file { $docker_compose_location: |
| 132 | + ensure => 'link', |
| 133 | + target => $docker_compose_location_versioned, |
| 134 | + require => File[$docker_compose_location_versioned], |
| 135 | + } |
| 136 | + } |
| 137 | + |
| 138 | + } else { |
116 | 139 | file { $docker_compose_location_versioned:
|
117 |
| - owner => $file_owner, |
118 |
| - mode => '0755', |
119 |
| - seltype => 'container_runtime_exec_t', |
120 |
| - require => Exec["Install Docker Compose ${version}"], |
| 140 | + ensure => absent, |
121 | 141 | }
|
122 |
| - |
| 142 | + |
123 | 143 | file { $docker_compose_location:
|
124 |
| - ensure => 'link', |
125 |
| - target => $docker_compose_location_versioned, |
126 |
| - require => File[$docker_compose_location_versioned], |
| 144 | + ensure => absent, |
127 | 145 | }
|
128 |
| - |
129 |
| - file { "${docker_plugins_path}/docker-compose": |
130 |
| - ensure => 'link', |
131 |
| - target => $docker_compose_location_versioned, |
132 |
| - require => File[$docker_plugins_path], |
133 |
| - } |
134 |
| - } |
135 |
| - } else { |
136 |
| - file { $docker_compose_location_versioned: |
137 |
| - ensure => absent, |
138 |
| - } |
139 |
| - |
140 |
| - file { $docker_compose_location: |
141 |
| - ensure => absent, |
142 | 146 | }
|
143 | 147 | }
|
144 | 148 | }
|
0 commit comments