Class: Root
- Inherits:
-
ShadowPuppet::Manifest
- Object
- ShadowPuppet::Manifest
- Root
- Includes:
- Blender::Manifest::Nodes, Blender::Manifest::Roles
- Defined in:
- lib/blender/manifest/root.rb
Overview
FIXME: this whole setup/regular execution is ugly. need to think of a better scheme Motivation behind the ‘setup’ thing:
-
on some platforms we need to do stuff before any of the real recipes are running an example is Darwin where you need to change the default package provider to ‘ports’ BEFORE you define any package resources
-
so we create 2 manifests. one that executes the ‘setup’ recipes, and another one that executes the rest.
Constant Summary collapse
- @@mixed_recipes =
[]
Class Method Summary collapse
Instance Method Summary collapse
-
#apply(bucket = nil) ⇒ Object
Create a catalog of all contained Puppet Resources and apply that catalog to the currently running system.
-
#execute(force = false) ⇒ Object
Execute this manifest, applying all resources defined.
- #execute_user_recipe ⇒ Object
-
#initialize(stage = :execute) ⇒ Root
constructor
A new instance of Root.
-
#os ⇒ String
Currently running operating system.
Methods included from Blender::Manifest::Roles
#current_roles, included, #role, #roles
Methods included from Blender::Manifest::Nodes
#addr, #addr!, #current_node, #current_node?, #host_ip, #hostname, included, #node, #resolv, #set_host_ip
Constructor Details
#initialize(stage = :execute) ⇒ Root
Returns a new instance of Root.
65 66 67 68 |
# File 'lib/blender/manifest/root.rb', line 65 def initialize(stage = :execute) super() @stage = stage end |
Class Method Details
.mixed_recipes ⇒ Object
29 30 31 |
# File 'lib/blender/manifest/root.rb', line 29 def self.mixed_recipes @@mixed_recipes end |
Instance Method Details
#apply(bucket = nil) ⇒ Object
Create a catalog of all contained Puppet Resources and apply that catalog to the currently running system
72 73 74 75 76 77 78 |
# File 'lib/blender/manifest/root.rb', line 72 def apply(bucket = nil) bucket ||= export() catalog = bucket.to_catalog res = catalog.apply catalog.clear res end |
#execute(force = false) ⇒ Object
Execute this manifest, applying all resources defined. Execute returns true if successfull, and false if unsucessfull. By default, this will only execute a manifest that has not already been executed?. The force
argument, if true, removes this check.
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/blender/manifest/root.rb', line 84 def execute(force=false) return false if executed? && !force evaluate_recipes ! apply.any_failed? rescue Exception => e STDERR.puts "\n\nException: #{e}\n#{e.backtrace * "\n"}" false ensure @executed = true end |
#execute_user_recipe ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/blender/manifest/root.rb', line 40 def execute_user_recipe mix "os/#{os.downcase}" if :setup == @stage # run OS specific setup recipe. m = "#{os.downcase}_setup" send(m) if respond_to?(m) # run gemeric setup send(:setup) if respond_to?(:setup) return end raise "no RECIPE to execute" unless recipe = ENV['RECIPE'] # run OS specific recipe. m = os.downcase send m if respond_to?(m) # load user's recipe code = open(recipe).read instance_eval(code, recipe) end |
#os ⇒ String
Currently running operating system
36 37 38 |
# File 'lib/blender/manifest/root.rb', line 36 def os Facter.value(:operatingsystem) end |