add docker for redhat

This commit is contained in:
Naoto TAKAHASHI 2013-12-13 02:16:59 +09:00
parent d321b9199e
commit 746d406558
5 changed files with 81 additions and 0 deletions

View File

@ -0,0 +1,15 @@
module VagrantPlugins
module Docker
module Cap
module Redhat
module DockerConfigureAutoStart
def self.docker_configure_auto_start(machine)
if ! machine.communicate.test('grep -q \'\-r=true\' /etc/sysconfig/docker')
machine.communicate.sudo("sed -i.bak 's/docker -d/docker -d -r=true/' /etc/sysconfig/docker ")
end
end
end
end
end
end
end

View File

@ -0,0 +1,13 @@
module VagrantPlugins
module Docker
module Cap
module Redhat
module DockerConfigureVagrantUser
def self.docker_configure_vagrant_user(machine)
machine.communicate.sudo("usermod -a -G docker #{machine.config.ssh.username || "vagrant"}")
end
end
end
end
end
end

View File

@ -0,0 +1,17 @@
module VagrantPlugins
module Docker
module Cap
module Redhat
module DockerInstall
def self.docker_install(machine, version)
machine.communicate.tap do |comm|
comm.sudo("rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm")
comm.sudo("yum -y upgrade")
comm.sudo("yum -y install docker-io")
end
end
end
end
end
end
end

View File

@ -0,0 +1,16 @@
module VagrantPlugins
module Docker
module Cap
module Redhat
module DockerStartService
def self.docker_start_service(machine)
machine.communicate.sudo("service docker start")
# TODO :: waiting to start
sleep 5
machine.communicate.sudo("chkconfig docker on")
end
end
end
end
end
end

View File

@ -34,6 +34,26 @@ module VagrantPlugins
Cap::Debian::DockerStartService
end
guest_capability("redhat", "docker_install") do
require_relative "cap/redhat/docker_install"
Cap::Redhat::DockerInstall
end
guest_capability("redhat", "docker_configure_auto_start") do
require_relative "cap/redhat/docker_configure_auto_start"
Cap::Redhat::DockerConfigureAutoStart
end
guest_capability("redhat", "docker_configure_vagrant_user") do
require_relative "cap/redhat/docker_configure_vagrant_user"
Cap::Redhat::DockerConfigureVagrantUser
end
guest_capability("redhat", "docker_start_service") do
require_relative "cap/redhat/docker_start_service"
Cap::Redhat::DockerStartService
end
guest_capability("linux", "docker_installed") do
require_relative "cap/linux/docker_installed"
Cap::Linux::DockerInstalled