通过木偶安装docker-ce

时间:2017-03-27 13:43:10

标签: docker puppet

我试图通过木偶安装docker-ce,我有几个问题。

1:之后apt :: key会自动执行'apt-get update'吗?

2:我如何使用apt:ppa模块添加docker-ce repository?  这是通过以下方式完成的:

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

但是我如何使用apt :: ppa来包含发布和发布?

这是整个木偶块:

class docker {

  $prerequisites = ['apt-transport-https', 'ca-certificates', 'curl']
  package { $prerequisites: ensure => installed}

  apt::key { 'docker-ce':
    ensure    => present,
    id        => '9DC858229FC7DD38854AE2D88D81803C0EBFCD88',
    options   => 'https://download.docker.com/linux/ubuntu/gpg',
  }

  apt::ppa {''}

  package {'docker-ce': ensure  => installed}
}

修改

使用apt :: source,硬编码版本的apt模块结束,因为我知道我的所有系统都会运行它。

class docker {
  include apt

  $prerequisites = ['apt-transport-https', 'ca-certificates']
  package { $prerequisites: ensure => installed} ->

  apt::key { 'docker-ce':
     ensure    => present,
     id        => '9DC858229FC7DD38854AE2D88D81803C0EBFCD88',
     options   => 'https://download.docker.com/linux/ubuntu/gpg',
  } ->

  apt::source {'docker-ce':
     location  => 'https://download.docker.com/linux/ubuntu',
     release   => 'xenial'
  } ->

  exec { 'apt-get-update':
     command   => '/usr/bin/apt-get update'
  } ->

  package {'docker-ce': ensure  => installed}
}

1 个答案:

答案 0 :(得分:2)

以下是我安装此内容的方法:

  apt::key { '9DC858229FC7DD38854AE2D88D81803C0EBFCD88':
    source => 'https://download.docker.com/linux/ubuntu/gpg',
  } ->
  apt::source { 'docker-ce':
    architecture => 'amd64',
    location     => 'https://download.docker.com/linux/ubuntu',
    repos        => 'stable',
    release      => $::lsbdistcodename,
  } ->
  package { 'docker-ce':
    ensure  => 'latest',
    require => Exec['apt_update'],
  }