5

I need to add the docker source list to apt before installing docker.

I have

apt::source { 'debian-jessie':
  comment  => 'This is the docker Debian jessie mirror',
  location => 'http://apt.dockerproject.org/repo',
  release  => 'debian-jessie',
  repos    => 'main',
  key_content => '58118E89F3A912897C070ADBF76221572C52609D',
  key_server => 'keyserver.ubuntu.com',
  ensure => present,
  include_src  => false,
  include_deb => true,
}

which works, and also

package {'docker-engine':
  ensure => present,
  before => Class['docker'],
}

which works only after a second run (I use vagrant provision, but that's not relevant to the problem).

What I would like is making the whole thing work at the first provisioning by instructing puppet to execute apt::source before docker-engine, however adding it in require is not a valid syntax:

package {'docker-engine':
  ensure => present,
  before => Class['docker'],
  require => [
    Apt::source['debian-jessie'],
  ]
}

How to specify this dependency?

The rest of the file looks like this:

class { 'docker':
  dns                        => '192.168.1.1',
  manage_package             => false,
  use_upstream_package_source=> false,
# service_name   => 'docker',
  docker_command             => 'docker',
  package_name               => 'docker-engine',
  service_enable             => true,
  service_state              => 'running',
  extra_parameters           => ["--insecure-registry=192.168.1.0/24"],
}

include 'docker'

file { "/lib/systemd/system/docker.service":
  notify  => Service["docker"],
  ensure  => present,
  owner   => "root",
  group   => "root",
  mode    => 0600,
  source  =>"puppet:///modules/docker/etc/systemd/system/docker.service"
} ~> Exec['systemctl-daemon-reload']
Flavius
  • 13,566
  • 13
  • 80
  • 126
  • why the `require` is not a valid syntax, what is your error message ? – Frederic Henri Aug 27 '15 at 09:01
  • You may want to `require => Exec['apt_update']`. The apt module notifies that exec when adding an `Apt::Source`. This will ensure your package install happens after the package lists are updated, not just after adding the new list. – daxlerod Aug 29 '15 at 13:39

1 Answers1

4

Capitalize word source

require => Apt::Source['debian-jessie']

Puppet documentation states:

The general form of a resource reference is:

  • The resource type, capitalized (every segment must be capitalized if the resource type includes a namespace separator [::])
  • An opening square bracket
  • The title of the resource as a string, or a comma-separated list of titles
  • A closing square bracket
Konstantin
  • 24,271
  • 5
  • 48
  • 65