Search code examples
dockervagrantpuppet

Requiring apt::source as a dependency gives a syntax error


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']

Solution

  • 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