OLD | NEW |
(Empty) | |
| 1 # == Class: docker |
| 2 # |
| 3 # Install docker (https://www.docker.com/) |
| 4 # |
| 5 # == Parameters: |
| 6 # |
| 7 # [*source*] |
| 8 # Overwrite the default apt::source used (given Class['apt'] is defined). |
| 9 # |
| 10 # [*package*] |
| 11 # Overwrite the default package options, to fine-tune the target version (i.e. |
| 12 # ensure => 'latest') or remove docker (ensure => 'absent' or 'purged') |
| 13 # |
| 14 # === Examples: |
| 15 # |
| 16 # class {'docker': |
| 17 # package => { |
| 18 # ensure => 'latest', |
| 19 # }, |
| 20 # source => { |
| 21 # location => 'https://apt.dockerproject.org/repo', |
| 22 # release => downcase("$::osfamily-$::lsbdistcodename"), |
| 23 # include_src => false, |
| 24 # key => '58118E89F3A912897C070ADBF76221572C52609D', |
| 25 # key_server => 'hkp://ha.pool.sks-keyservers.net:80', |
| 26 # } |
| 27 # } |
| 28 # |
| 29 class docker( |
| 30 $source = hiera('docker::source', {}), |
| 31 $package = hiera('docker::package', {}), |
| 32 ) { |
| 33 |
| 34 include stdlib |
| 35 |
| 36 ensure_resource('package', $title, merge({ |
| 37 name => 'docker-engine', |
| 38 }, $package)) |
| 39 |
| 40 # Used as default $ensure parameter for most resources below |
| 41 $ensure = getparam(Package[$title], 'ensure') ? { |
| 42 /^(absent|purged|held)$/ => 'absent', |
| 43 default => 'present', |
| 44 } |
| 45 |
| 46 # Using ensure_*state functions |
| 47 if ensure_state($ensure) { |
| 48 |
| 49 service {'docker': |
| 50 ensure => running, |
| 51 require => Package['docker-engine'], |
| 52 } |
| 53 |
| 54 } |
| 55 |
| 56 # The only package provider recognized implicitly |
| 57 if getparam(Package[$title], 'provider') == 'apt' { |
| 58 |
| 59 ensure_resource('apt::source', $title, merge({ |
| 60 before => Package['docker-engine'], |
| 61 location => 'https://apt.dockerproject.org/repo', |
| 62 release => downcase("$::osfamily-$::lsbdistcodename"), |
| 63 include_src => false, |
| 64 key => '58118E89F3A912897C070ADBF76221572C52609D', |
| 65 key_server => 'hkp://ha.pool.sks-keyservers.net:80', |
| 66 }, $source)) |
| 67 |
| 68 Apt::Source[$title] -> Package[$title] |
| 69 } |
| 70 } |
| 71 |
OLD | NEW |