Skip to content
This repository has been archived by the owner on Jul 29, 2018. It is now read-only.

Commit

Permalink
Adds docker provisioner to plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
navidshaikh committed Feb 14, 2016
1 parent 108b5d6 commit f555375
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Vagrant.configure(2) do |config|
config.vm.box = "projectatomic/adb"

config.vm.network "private_network", type: "dhcp"

# provision docker when machine boots up
config.vm.provision :docker
end
1 change: 1 addition & 0 deletions lib/vagrant-service-manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require 'vagrant-service-manager/plugin'
require 'vagrant-service-manager/command'
require 'vagrant-service-manager/os'
require 'vagrant-service-manager/docker_provisioner'

module Vagrant
module DockerInfo
Expand Down
7 changes: 0 additions & 7 deletions lib/vagrant-service-manager/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,6 @@ def execute_docker_info
# First, get the TLS Certificates, if needed
if !File.directory?(secrets_path) then

# Regenerate the certs and restart docker daemon in case of the new ADB box and for VirtualBox provider
if machine.provider_name == :virtualbox then
# `test` checks if the file exists, and then regenerates the certs and restart the docker daemon, else do nothing.
command2 = "test ! -f /opt/adb/cert-gen.sh || (sudo rm /etc/docker/ca.pem && sudo systemctl restart docker)"
machine.communicate.execute(command2)
end

# Get the private key
hprivate_key_path = machine.ssh_info[:private_key_path][0]

Expand Down
21 changes: 21 additions & 0 deletions lib/vagrant-service-manager/docker_provisioner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Vagrant
module ServiceManagerProvisioner
class Provisioner < Vagrant.plugin("2", :provisioner)

def configure(root_config)
super(root_config)
end

def provision
command = "sudo rm /etc/docker/ca.pem && sudo systemctl restart docker"
@machine.communicate.execute(command) do |type, data|
if type == :stderr
@machine.ui.error(data)
else
@env.ui.info("# Provisioned docker provider")
end
end
end
end
end
end
10 changes: 9 additions & 1 deletion lib/vagrant-service-manager/plugin.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
require "vagrant"

module Vagrant
module ServiceManager
class Plugin < Vagrant.plugin('2')
class Plugin < Vagrant.plugin("2")
name "service-manager"
description "Service manager for services inside vagrant box."

command 'service-manager' do
require_relative 'command'
Command
end

provisioner "docker" do
require_relative "docker_provisioner"
Provisioner
end
end
end
end

0 comments on commit f555375

Please sign in to comment.