Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
- remove the inventory action from the ddl we use the main mc inventory
Browse files Browse the repository at this point in the history
- optimise node provisioning by only calling to the inventory once
  • Loading branch information
ripienaar committed Feb 6, 2011
1 parent 402d7b6 commit b1a9fab
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 27 deletions.
12 changes: 0 additions & 12 deletions agent/provision.ddl
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@ metadata :name => "Server Provisioning Agent",
:timeout => 360


action "inventory", :description => "Get the server inventory" do
display :always

output :facts,
:description => "Node Facts",
:display_as => "Facts"

output :classes,
:description => "Classes on this node",
:display_as => "Classes"
end

action "set_puppet_host", :description => "Update /etc/hosts with the master IP" do
display :always

Expand Down
30 changes: 16 additions & 14 deletions lib/mcprovision/node.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
module MCProvision
class Node
attr_reader :hostname
attr_reader :hostname, :inventory

def initialize(hostname, config, agent)
@config = config
@hostname = hostname
@agent = agent

setup
end

# Gets the inventory from the discovery agent on the node
def inventory
result = {}

@node.client.req("inventory", "discovery", @node.client.options, 1) do |resp|
result[:agents] = resp[:body][:agents]
result[:facts] = resp[:body][:facts]
result[:classes] = resp[:body][:classes]
end

result
@inventory = fetch_inventory
end

# Do we already have a puppet cert?
Expand Down Expand Up @@ -74,6 +62,20 @@ def check_puppet_output(output)
end
end

# Gets the inventory from the discovery agent on the node
def fetch_inventory
result = {}

@node.client.req("inventory", "discovery", @node.client.options, 1) do |resp|
result[:agents] = resp[:body][:agents]
result[:facts] = resp[:body][:facts]
result[:classes] = resp[:body][:classes]
result[:has_cert] = resp[:body][:has_cert]
end

result
end

def setup
@node = rpcclient(@agent)
@node.identity_filter @hostname
Expand Down
2 changes: 1 addition & 1 deletion lib/mcprovision/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def provision(node)
node.set_puppet_host(master_ip) if @config.settings["steps"]["set_puppet_hostname"]

# Only do certificate management if the node is clean and doesnt already have a cert
unless node.has_cert?
unless node_inventory[:has_cert]
# calls clean on all puppetmasters
@master.clean_cert(node.hostname) if @config.settings["steps"]["clean_node_certname"]

Expand Down

0 comments on commit b1a9fab

Please sign in to comment.