Problem scenario
You want to deploy Docker to Ubuntu Linux using Puppet. How do you write a manifest to install Docker an Ubuntu server?
Solution
This solution demonstrates transferring a file with Puppet.
1. Install Puppet master on an Ubuntu Server. See this link if you want directions.
2. Install Puppet agent on a different Ubuntu server. See this link if you want directions.
3. On the Puppet Master server, run this command (taken from this link):
puppet module install puppetlabs-docker_platform --version 2.2.1
4. On the Puppet Master server, go to /etc/puppet/module/docker/. Create a directory named "files".
5. Still on the Puppet Master server, in the "files" directory, create a file named "docker_inst.sh" with the following content:
#!/bin/bash
apt-get update
apt-get install apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo 'deb https://apt.dockerproject.org/repo ubuntu-trusty main' > /etc/apt/sources.list.d/docker.list
echo 'deb http://cz.archive.ubuntu.com/ubuntu trusty main' >> /etc/apt/sources.list.d/docker.list
apt-get update
apt-cache policy docker-engine
apt-get --assume-yes install linux-image-extra-$(uname -r) linux-image-extra-virtual
apt-get --assume-yes install docker-engine
sudo service docker start
sudo groupadd docker
sudo usermod -aG docker ubuntu
docker run hello-world
6. Still on the Puppet master server, go to /etc/puppet/manifests/. Modify site.pp to have these stanzas:
file { '/tmp/docker_inst.sh':
mode => '0644',
source => 'puppet:///modules/docker/docker_inst.sh',
}
exec { 'install_docker':
command => "/bin/bash /tmp/docker_inst.sh"
}
7. On the Puppet Agent server, run this:
puppet agent -t -d