Revisions
-
ScottSturdivant revised this gist
Jun 4, 2013 . 2 changed files with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,6 @@ require_relative "plugins/provisioners/fabric/plugin.rb" Vagrant.configure("2") do |config| *snip* config.vm.provision :fabric do |fab| fab.tasks = ["setup_salt:kwarg=value"] end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -44,6 +44,7 @@ def validate(env) end for task in tasks task = task.split(":")[0] package_path = "#{fabfile_package}.#{task}".gsub(".__init__", "") packages = package_path.split(".") output = `#{python_path} -c "exec 'from #{packages[0..-2].join('.')} import #{packages[-1]}'" > /dev/null 2>&1` -
ScottSturdivant revised this gist
Jun 4, 2013 . 5 changed files with 99 additions and 76 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ require_relative "plugins/provisioners/fabric/plugin.rb" Vagrant.configure("2") do |config| *snip* config.vm.provision :fabric do |fab| fab.tasks = ["setup_salt"] end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,76 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ module VagrantPlugins module Fabric class Config < Vagrant.plugin("2", :config) attr_accessor :fabfile_path attr_accessor :fabric_path attr_accessor :python_path attr_accessor :tasks def initialize @fabfile_path = UNSET_VALUE @fabric_path = UNSET_VALUE @python_path = UNSET_VALUE @tasks = UNSET_VALUE end def finalize! @fabfile_path = "fabfile.py" if @fabfile_path == UNSET_VALUE @fabric_path = "fab" if @fabric_path == UNSET_VALUE @python_path = "python" if @python_path == UNSET_VALUE @tasks = [] if @tasks == UNSET_VALUE end def validate(env) errors = _detected_errors if not File.exist?(fabfile_path) errors << "No fabfile found." end which_fabric_path = `which #{fabric_path}` if not $?.success? errors << "fabric command does not exist." end which_python_path = `which #{python_path}` if not $?.success? errors << "python not found." end fabfile_package = fabfile_path.gsub(".py", "").gsub("/", ".") output = `#{python_path} -c "exec 'import #{fabfile_package}'" &> /dev/null` if not $?.success? errors << "#{fabfile_package} could not import." end for task in tasks package_path = "#{fabfile_package}.#{task}".gsub(".__init__", "") packages = package_path.split(".") output = `#{python_path} -c "exec 'from #{packages[0..-2].join('.')} import #{packages[-1]}'" > /dev/null 2>&1` if not $?.success? errors << "#{task} task does not exist." end end { "fabric provisioner" => errors } end end end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ require "vagrant" module VagrantPlugins module Fabric class Plugin < Vagrant.plugin("2") name "fabric" config(:fabric, :provisioner) do require File.expand_path("../config", __FILE__) Config end provisioner(:fabric) do require File.expand_path("../provisioner", __FILE__) Provisioner end end end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ module VagrantPlugins module Fabric class Provisioner < Vagrant.plugin("2", :provisioner) def provision ssh_info = machine.ssh_info user = ssh_info[:username] host = ssh_info[:host] port = ssh_info[:port] private_key = ssh_info[:private_key_path] system "#{config.fabric_path} -i #{private_key} --config=#{config.fabfile_path} --user=#{user} --hosts=#{host} --port=#{port} #{config.tasks.join(' ')}" end end end end -
Takahiro Fujiwara revised this gist
Jul 26, 2012 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,6 @@ def validate(env, errors) for task in tasks package_path = "#{fabfile_package}.#{task}".gsub(".__init__", "") packages = package_path.split(".") output = `#{python_path} -c "exec 'from #{packages[0..-2].join('.')} import #{packages[-1]}'" &> /dev/null` errors.add("#{task} task does not exist.") if not $?.success? end -
Takahiro Fujiwara revised this gist
Jul 26, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -33,7 +33,7 @@ def validate(env, errors) package_path = "#{fabfile_package}.#{task}".gsub(".__init__", "") packages = package_path.split(".") puts "exec 'from #{packages[0..-2].join('.')} import #{packages[-1]}'" output = `#{python_path} -c "exec 'from #{packages[0..-2].join('.')} import #{packages[-1]}'" &> /dev/null` errors.add("#{task} task does not exist.") if not $?.success? end end -
Takahiro Fujiwara revised this gist
Jul 26, 2012 . 1 changed file with 7 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,11 +29,13 @@ def validate(env, errors) output = `#{python_path} -c "exec 'import #{fabfile_package}'" &> /dev/null` errors.add("#{fabfile_package} could not import.") if not $?.success? for task in tasks package_path = "#{fabfile_package}.#{task}".gsub(".__init__", "") packages = package_path.split(".") puts "exec 'from #{packages[0..-2].join('.')} import #{packages[-1]}'" output = `#{python_path} -c "exec 'from #{packages[0..-2].join('.')} import # errors.add("#{task} task does not exist.") if not $?.success? end end def fabfile_path -
Takahiro Fujiwara revised this gist
Jul 26, 2012 . 1 changed file with 5 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,10 +29,11 @@ def validate(env, errors) output = `#{python_path} -c "exec 'import #{fabfile_package}'" &> /dev/null` errors.add("#{fabfile_package} could not import.") if not $?.success? #TODO: Fix a bug checking to execute tasks. #for task in tasks # output = `#{python_path} -c "exec 'from #{fabfile_package} import #{task}'" &> /dev/null` # errors.add("#{task} task does not exist.") if not $?.success? #end end def fabfile_path -
Takahiro Fujiwara revised this gist
Jul 13, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,7 +30,7 @@ def validate(env, errors) errors.add("#{fabfile_package} could not import.") if not $?.success? for task in tasks output = `#{python_path} -c "exec 'from #{fabfile_package} import #{task}'" &> /dev/null` errors.add("#{task} task does not exist.") if not $?.success? end end -
Takahiro Fujiwara created this gist
Jul 10, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,74 @@ module Vagrant module Provisioners class Fabric < Base class Config < Vagrant::Config::Base attr_accessor :fabfile_path attr_accessor :fabric_path attr_accessor :python_path attr_writer :tasks def _default_fabfile_path File.exist?("fabfile.py") ? "fabfile.py" : "fabfile/__init__.py" end def _default_fabric_path "fab" end def _default_python_path "/usr/bin/python" end def validate(env, errors) errors.add("fabfile does not exist.") if not File.exist?(fabfile_path) which_fabric_path = `which #{fabric_path}` errors.add("fabric command does not exist.") if not $?.success? fabfile_package = fabfile_path.gsub(".py", "").gsub("/", ".") output = `#{python_path} -c "exec 'import #{fabfile_package}'" &> /dev/null` errors.add("#{fabfile_package} could not import.") if not $?.success? for task in tasks output = `#{python_path} -c "exec 'from #{fabfile_package} import #{task}'" &> null` errors.add("#{task} task does not exist.") if not $?.success? end end def fabfile_path @fabfile_path || _default_fabfile_path end def fabric_path @fabric_path || _default_fabric_path end def python_path @python_path || _default_python_path end def tasks @tasks ||= [] end # Adds a recipe to the run list def add_task(name) tasks << name end end def self.config_class Config end def provision! ssh_info = env[:vm].ssh.info user = ssh_info[:username] host = ssh_info[:host] port = ssh_info[:port] private_key = ssh_info[:private_key_path] system "#{config.fabric_path} -i #{private_key} --config=#{config.fabfile_path} --user=#{user} --hosts=#{host} --port=#{port} #{config.tasks.join(' ')}" end end end end