Commit af1df47c authored by Adam Lewenberg's avatar Adam Lewenberg
Browse files

first real commit

parents
Loading
Loading
Loading
Loading

manifests/init.pp

0 → 100644
+101 −0
Original line number Diff line number Diff line
# Install the packages necessary to run docker.
#
# $ensure: must be one of present or absent.
# Default: present
#
# $use_docker_repo: if true (the default), use docker.com's repository as
#   the source for the docker packages. For Debian this is currently the better
#   option as the version of docker in the Debian official repository is old
#   and docker changes frequently.
#
#   Note that the name of the package in the official Debian repository is
#   "docker.io" to avoid conflicting with an existing package that already
#   has the name "docker". The name of the package from docker.com is
#   "docker-engine".
# Default: true

# https://apt.dockerproject.org/repo

class package_docker (
  $ensure          = present,
  $use_docker_repo = true,
){

$complement_ensure

  case $ensure {
    'present': {
      $complement_ensure = 'absent'
    }
    'present', 'absent': {
      $complement_ensure = 'present'
    }
    default: {
      fail "ensure must be one of 'present' or 'absent'"
    }
  }

  if ($::osfamily == 'Debian') {
    if ($use_docker_repo) {

      # If installing, make sure we get rid of docker.io.
      if ($ensure == 'present') {
        package { 'docker.io':
          ensure => absent,
          before => Package['docker-engine'],
        }
      }

      file {'/etc/apt/sources.list.d/docker.list':
        ensure  => $ensure,
        content => template('package_docker/etc/apt/sources.list.d/docker.list.erb'),
        notify  => Exec['dockerproject.org apt-key'],
      }

      # Install/un-install dockerproject.org's public GPG key
      $keyserver = 'hkp://p80.pool.sks-keyservers.net:80'
      $pubkey    = '58118E89F3A912897C070ADBF76221572C52609D'
      $keyid     = '2C52609D'
      if ($ensure == 'present') {
        $command = "apt-key adv --keyserver $keyserver --recv-keys $pubkey"
      } else {
        $command = "apt-key del $keyid"
      }
      exec { 'dockerproject.org apt-key':
        path        => '/usr/bin:/bin',
        command     => $command,
        refreshonly => true,
        notify      => Exec['aptitude update after dockerproject change'],
      }

      # Do an aptitude update
      exec { 'aptitude update after dockerproject change':
        path        => '/usr/bin',
        command     => 'aptitude update',
        refreshonly => true,
      }

      # Install or uninstall the package
      package { 'docker-engine':
        ensure  => $ensure,
        require => Exec['aptitude update after dockerproject change'],
      }

    } else {
      # Using official Debian packages
      package { 'docker.io':
        ensure => $ensure,
      }

      if ($ensure == 'present') {
        package { 'docker-ensure':
          ensure => absent,
        }
      }
    }
  } else {
    crit "do not yet know how to handle ${::osfamily}"
  }


}
+6 −0
Original line number Diff line number Diff line
<%-
  archive = @operatingsystem + '-' + @lsbdistcodename
  archive = archive.downcase()
-%>
# Use dockerproject.org's repository for the docker project
deb https://apt.dockerproject.org/repo <%= archive %> main