Module: Cuken::Api::Chef::Knife
Defined Under Namespace
Classes: CliTemplate, CommandFailed, CommandTimeout
Instance Method Summary
collapse
#clone_pull_error_check, #with_args
Instance Method Details
#ensure_node_presence(node_name, expect_presence = true) ⇒ Object
86
87
88
89
90
91
92
93
94
|
# File 'lib/cuken/api/chef/knife.rb', line 86
def ensure_node_presence(node_name, expect_presence = true)
nd = node_show(node_name)
unless nd.class.to_s == 'Chef::Node' && nd.name == node_name
node_create(node_name)
end
nd = node_show(node_name)
nd.should be_an_instance_of(::Chef::Node)
nd.name.should == node_name
end
|
#node_create(node_name) ⇒ Object
124
125
126
127
128
129
130
131
132
133
134
|
# File 'lib/cuken/api/chef/knife.rb', line 124
def node_create(node_name)
argv = ['node', 'create', node_name, '--no-editor', '--config', chef.knife_config_file.to_s]
if Pathname(chef.knife_config_file).exist?
with_args *argv do
::Chef::Application::Knife.new.run
end
else
end
::Chef::Knife.cuken
end
|
#node_role_load(hsh) ⇒ Object
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/cuken/api/chef/knife.rb', line 112
def node_role_load(hsh)
argv = ['node', 'run_list', 'add', hsh[:node], "role[#{hsh[:role]}]", '--no-editor', '--config', chef.knife_config_file.to_s]
if Pathname(chef.knife_config_file).exist?
with_args *argv do
::Chef::Application::Knife.new.run
end
else
end
::Chef::Knife.cuken
end
|
#node_show(node_name, attr = :all) ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/cuken/api/chef/knife.rb', line 96
def node_show(node_name, attr = :all)
Pathname(chef.knife_config_file).exist?.should be_true
argv = ['node', 'show', node_name, '--no-editor', '--config', chef.knife_config_file.to_s]
unless attr == :all
argv << '--attribute' << attr
end
if Pathname(chef.knife_config_file).exist?
with_args *argv do
::Chef::Application::Knife.new.run
end
else
end
::Chef::Knife.cuken
end
|
#set_cli_options_template(data) ⇒ Object
68
69
70
71
72
73
|
# File 'lib/cuken/api/chef/knife.rb', line 68
def set_cli_options_template(data)
conf = data[:config]||'/etc/chef/knife.rb'
CliTemplate.option(:config_file, :long => '--config CONFIG', :default => conf)
CliTemplate.option(:no_editor, :long => "--no-editor", :boolean => true, :default => true)
CliTemplate.option(:yes, :long => "--yes", :boolean => true, :default => true)
end
|
#show_client(client_name) ⇒ Object
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/cuken/api/chef/knife.rb', line 75
def show_client(client_name)
chef.client_private_key_path = chef.root_dir + "/.chef/#{client_name}.pem"
data = {:name => client_name,
:config_file => chef.knife_config_file}
argv = ['client', 'show', data[:name], '--config', data[:config_file],'--no-editor']
argv << '--admin' if data[:admin]
with_args *argv do
::Chef::Application::Knife.new.run
end
end
|