Search code examples
dockervagrantpuppet

Vagrant install docker with puppet


I am trying to install docker on the trusty64 vagrant image:

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.hostname = "apps.local"
  config.vm.provision "shell", inline: <<-SHELL
    puppet module install garethr-docker
  SHELL

  config.vm.provision "puppet"
end

manifests/default.pp

include 'docker'

docker::image { 'ubuntu':
  image_tag => 'trusty'
}

And the output of vagrant up :

==> default: Running provisioner: shell...
    default: Running: inline script
==> default: Notice: Preparing to install into /etc/puppet/modules ...
==> default: Notice: Downloading from https://forge.puppetlabs.com ...
==> default: Notice: Installing -- do not interrupt ...
==> default: /etc/puppet/modules
==> default: └─┬ garethr-docker (v5.3.0)
==> default:   ├── puppetlabs-apt (v3.0.0)
==> default:   ├── puppetlabs-stdlib (v4.17.0)
==> default:   └── stahnma-epel (v1.2.2)
==> default: Running provisioner: puppet...
==> default: Running Puppet with default.pp...
==> default: Warning: Config file /etc/puppet/hiera.yaml not found, using Hiera defaults
==> default: Error: Syntax error at 'Variant'; expected ')' at /etc/puppet/modules/apt/manifests/init.pp:6 on node carcosa.local
==> default: Error: Syntax error at 'Variant'; expected ')' at /etc/puppet/modules/apt/manifests/init.pp:6 on node carcosa.local
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

Can someone tell me what am I doing wrong ?


Solution

  • If your goal is just to have docker installed on the VM, the easiest is to let vagrant install it. Vagrant has docker provisioner and if not installed it will try to install

    This simple Vagrantfile

    # -*- mode: ruby -*-
    # vi: set ft=ruby :
    
    Vagrant.configure("2") do |config|
      config.vm.box = "ubuntu/trusty64"
      config.vm.provision "docker"
    end
    

    will install docker on trusty64 - the provisioner has after many advantages if you want to work with docker images etc ...