From 746d4065589271b8c3e08c6454d278c4cafb5ad3 Mon Sep 17 00:00:00 2001 From: Naoto TAKAHASHI Date: Fri, 13 Dec 2013 02:16:59 +0900 Subject: [PATCH] add docker for redhat --- .../cap/redhat/docker_configure_auto_start.rb | 15 ++++++++++++++ .../redhat/docker_configure_vagrant_user.rb | 13 ++++++++++++ .../docker/cap/redhat/docker_install.rb | 17 ++++++++++++++++ .../docker/cap/redhat/docker_start_service.rb | 16 +++++++++++++++ plugins/provisioners/docker/plugin.rb | 20 +++++++++++++++++++ 5 files changed, 81 insertions(+) create mode 100644 plugins/provisioners/docker/cap/redhat/docker_configure_auto_start.rb create mode 100644 plugins/provisioners/docker/cap/redhat/docker_configure_vagrant_user.rb create mode 100644 plugins/provisioners/docker/cap/redhat/docker_install.rb create mode 100644 plugins/provisioners/docker/cap/redhat/docker_start_service.rb diff --git a/plugins/provisioners/docker/cap/redhat/docker_configure_auto_start.rb b/plugins/provisioners/docker/cap/redhat/docker_configure_auto_start.rb new file mode 100644 index 000000000..696d946fc --- /dev/null +++ b/plugins/provisioners/docker/cap/redhat/docker_configure_auto_start.rb @@ -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 diff --git a/plugins/provisioners/docker/cap/redhat/docker_configure_vagrant_user.rb b/plugins/provisioners/docker/cap/redhat/docker_configure_vagrant_user.rb new file mode 100644 index 000000000..29441d990 --- /dev/null +++ b/plugins/provisioners/docker/cap/redhat/docker_configure_vagrant_user.rb @@ -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 diff --git a/plugins/provisioners/docker/cap/redhat/docker_install.rb b/plugins/provisioners/docker/cap/redhat/docker_install.rb new file mode 100644 index 000000000..98304f5ad --- /dev/null +++ b/plugins/provisioners/docker/cap/redhat/docker_install.rb @@ -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 diff --git a/plugins/provisioners/docker/cap/redhat/docker_start_service.rb b/plugins/provisioners/docker/cap/redhat/docker_start_service.rb new file mode 100644 index 000000000..263b2c3ed --- /dev/null +++ b/plugins/provisioners/docker/cap/redhat/docker_start_service.rb @@ -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 diff --git a/plugins/provisioners/docker/plugin.rb b/plugins/provisioners/docker/plugin.rb index 72bc8463d..e00a93a45 100644 --- a/plugins/provisioners/docker/plugin.rb +++ b/plugins/provisioners/docker/plugin.rb @@ -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