Class: Provider::ChefServer

Inherits:
Object
  • Object
show all
Defined in:
lib/providers/chefserver/client.rb,
lib/providers/chefserver/instance.rb,
lib/providers/chefserver/chefserver.rb

Defined Under Namespace

Classes: Client, Instance

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ChefServer

Returns a new instance of ChefServer.



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/providers/chefserver/chefserver.rb', line 27

def initialize(config)
	@path                                  = File.dirname($0)
	@config                                = config
	Chef::Config[:environment]             = config[:environment]
	Chef::Config[:node_name]               = config[:node_name]
	Chef::Config[:client_key]              = config[:client_key]
	Chef::Config[:validation_client_name]  = config[:validation_client_name]
	Chef::Config[:validation_key]          = config[:validation_key]
	Chef::Config[:chef_server_url]         = config[:chef_server_url] if config[:chef_server_url]
	Chef::Config[:ssl_version]             = config[:ssl_version]
	Chef::Config[:log_level]               = config[:verbose]
end

Instance Method Details

#clientObject



64
65
66
# File 'lib/providers/chefserver/chefserver.rb', line 64

def client
	node = Provider::ChefServer::Client.new(@config)
end

#instanceObject



60
61
62
# File 'lib/providers/chefserver/chefserver.rb', line 60

def instance
	node = Provider::ChefServer::Instance.new(@config)
end

#instances(query) ⇒ Object



44
45
46
47
48
# File 'lib/providers/chefserver/chefserver.rb', line 44

def instances(query)
	q = Chef::Search::Query.new
	nodes = q.search(:node, query).first
	nodes
end

#knifeObject



40
41
42
# File 'lib/providers/chefserver/chefserver.rb', line 40

def knife
	@knife = @knife || Provider::ChefServer::Instance.new(@config)	
end

#search(query) ⇒ Object



50
51
52
53
54
# File 'lib/providers/chefserver/chefserver.rb', line 50

def search(query)
	q = Chef::Search::Query.new
	nodes = q.search(:node, query).first
	nodes
end

#ssh(query, deploy_cmd, manual) ⇒ Object



56
57
58
# File 'lib/providers/chefserver/chefserver.rb', line 56

def ssh(query, deploy_cmd, manual)
	knife.ssh(query, deploy_cmd, manual)
end