Top Level Namespace
Defined Under Namespace
Classes: ChefRundeck, ChefRundeckCLI, MissingAttribute
Constant Summary
collapse
- REQUIRED_ATTRS =
[ :kernel, :fqdn, :platform, :platform_version ]
Instance Method Summary
collapse
Instance Method Details
#build_node(node, username, hostname, custom_attributes) ⇒ Object
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
# File 'lib/chef-rundeck.rb', line 105
def build_node (node, username, hostname, custom_attributes)
data = ''
os_family = node[:kernel][:os] =~ /winnt|windows/i ? 'winnt' : 'unix'
nodeexec = node[:kernel][:os] =~ /winnt|windows/i ? "node-executor=\"overthere-winrm\"" : ''
data << "<node name=\"\#{xml_escape(node[:fqdn])}\" \#{nodeexec} \n type=\"Node\" \n description=\"\#{xml_escape(node.name)}\"\n osArch=\"\#{xml_escape(node[:kernel][:machine])}\"\n osFamily=\"\#{xml_escape(os_family)}\"\n osName=\"\#{xml_escape(node[:platform])}\"\n osVersion=\"\#{xml_escape(node[:platform_version])}\"\n tags=\"\#{xml_escape(node.run_list.roles.concat(node.run_list.recipes).join(',') + ',' + node.chef_environment)}\"\n roles=\"\#{xml_escape(node.run_list.roles.join(','))}\"\n recipes=\"\#{xml_escape(node.run_list.recipes.join(','))}\"\n environment=\"\#{xml_escape(node.chef_environment)}\"\n username=\"\#{xml_escape(username)}\"\n hostname=\"\#{xml_escape(node[hostname])}\"\n editUrl=\"\#{xml_escape(ChefRundeck.web_ui_url)}/nodes/\#{xml_escape(node.name)}/edit\" \#{custom_attributes.nil? ? '/': ''}>\n"
if !custom_attributes.nil? then
custom_attributes.each do |attr|
attr_name = attr
attr_value = get_custom_attr(node, attr.split('.'))
data << " <attribute name=\"\#{attr_name}\"><![CDATA[\#{attr_value}]]></attribute>\n"
end
data << "</node>"
end
return data
end
|
#get_custom_attr(obj, params) ⇒ Object
142
143
144
145
146
147
148
149
150
151
152
|
# File 'lib/chef-rundeck.rb', line 142
def get_custom_attr (obj, params)
value = obj
Chef::Log.debug("loading custom attributes for node: #{obj} with #{params}")
params.each do |p|
value = value[p.to_sym]
if value.nil? then
break
end
end
return value.nil? ? "" : value.to_s
end
|
#node_is_valid?(node) ⇒ Boolean
154
155
156
157
158
159
160
161
162
163
|
# File 'lib/chef-rundeck.rb', line 154
def node_is_valid?(node)
node[:fqdn] and
node.name and
node[:kernel] and
node[:kernel][:machine] and
node[:kernel][:os] and
node[:platform] and
node[:platform_version] and
node.chef_environment
end
|