Module: Cuken::Api::Chef::Role

Includes:
Cuken::Api::Common
Defined in:
lib/cuken/api/chef/role.rb

Instance Method Summary collapse

Methods included from Cuken::Api::Common

#clone_pull_error_check, #with_args

Instance Method Details

#check_role_table_presence(table, expect_presence = true) ⇒ Object



56
57
58
59
60
61
62
63
64
65
# File 'lib/cuken/api/chef/role.rb', line 56

def check_role_table_presence(table, expect_presence = true)
  roles = role_list
  table.hashes.each do |hsh|
    if expect_presence
      roles.should include(hsh['role'])
    else
      roles.should_not include(hsh['role'])
    end
  end
end

#load_role_table(table) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cuken/api/chef/role.rb', line 24

def load_role_table(table)
  in_chef_root do
    table.hashes.each do |hsh|
      case
        when !(hsh['cookbook'].nil? || hsh['cookbook'].empty?)
          src = "cookbooks/#{hsh['cookbook']}/roles/#{hsh['role']}"
        when !(hsh['site-cookbook'].nil? || hsh['site-cookbook'].empty?)
          src = "site-cookbooks/#{hsh['site-cookbook']}/roles/#{hsh['role']}"
        else
          src =""
      end
      role_load(::File.expand_path(src))
    end
  end
end

#role_listObject



48
49
50
51
52
53
54
# File 'lib/cuken/api/chef/role.rb', line 48

def role_list

  knife_config_file_error_handling()

  argv = ['role', 'list']
  run_knife(argv)
end

#role_load(src) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/cuken/api/chef/role.rb', line 40

def role_load(src)

  knife_config_file_error_handling()

  argv = ['role', 'from', 'file', src]
  run_knife(argv)
end