Class: Rake::RemoteChef::Core::AttributesTemplate
- Inherits:
-
Object
- Object
- Rake::RemoteChef::Core::AttributesTemplate
- Defined in:
- lib/rake/remote_chef/core.rb
Instance Attribute Summary collapse
-
#target_host ⇒ Object
readonly
Returns the value of attribute target_host.
Instance Method Summary collapse
- #all_roles ⇒ Object
- #index_of_role(role) ⇒ Object
-
#initialize(target_host) ⇒ AttributesTemplate
constructor
A new instance of AttributesTemplate.
- #load ⇒ Object
- #load_attributes_for(role) ⇒ Object
- #roles ⇒ Object
Constructor Details
#initialize(target_host) ⇒ AttributesTemplate
25 26 27 |
# File 'lib/rake/remote_chef/core.rb', line 25 def initialize(target_host) @target_host = target_host end |
Instance Attribute Details
#target_host ⇒ Object (readonly)
Returns the value of attribute target_host.
23 24 25 |
# File 'lib/rake/remote_chef/core.rb', line 23 def target_host @target_host end |
Instance Method Details
#all_roles ⇒ Object
37 38 39 |
# File 'lib/rake/remote_chef/core.rb', line 37 def all_roles Rake::RemoteTask.roles end |
#index_of_role(role) ⇒ Object
41 42 43 |
# File 'lib/rake/remote_chef/core.rb', line 41 def index_of_role role Rake::RemoteTask.roles[role].keys.index(target_host) end |
#load ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/rake/remote_chef/core.rb', line 45 def load attributes = load_attributes_for(:default) roles.each do |role| attributes.deep_merge!(load_attributes_for(role) || {}) end attributes.update('run_list' => Rake::RemoteChef.run_list_for(*roles)) unless attributes.has_key?('run_list') attributes end |
#load_attributes_for(role) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rake/remote_chef/core.rb', line 54 def load_attributes_for(role) role_file = "#{attributes_dir}/#{role.to_s}.yml.erb" if File.file?(role_file) open(role_file) do |io| YAML.load(ERB.new(io.read).result(binding)) end else puts "attributes template not found at: #{role_file}" {} end end |
#roles ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/rake/remote_chef/core.rb', line 29 def roles roles = [] Rake::RemoteTask.roles.each do |k, v| roles << k if v.keys.include?(target_host) end roles end |