[cookbooks/cobbler] Added agent to slave node

This commit is contained in:
Vladimir Kozhukalov 2012-07-17 20:29:18 +04:00
parent ddb783cc72
commit aea7a5ab3e
3 changed files with 36 additions and 9 deletions

View File

@ -1,21 +1,29 @@
require "base64"
class LateFile
def initialize(source_file)
@source_file = source_file
def initialize(source, opts={})
default_opts = {
:method => :file
}
@source = source
@opts = default_opts.merge(opts)
@content = ""
@content64 = base64(@content)
end
def init
open(@source_file , 'r') do |file|
lines = []
while line = file.gets
lines << line
if @opts[:method] == :file
open(@source , 'r') do |file|
lines = []
while line = file.gets
lines << line
end
@content = lines.to_s
end
@content = lines.to_s
@content64 = base64(@content)
elsif @opts[:method] == :content
@content = @source
end
@content64 = base64(@content)
return self
end

View File

@ -10,7 +10,18 @@ template "#{node.cobbler.preseed_dir}/centos-6.2-x86_64.ks" do
mode "0644"
variables(
:late_authorized_keys => LateFile.new("#{node.nailgun.root}/.ssh/id_rsa.pub"),
:late_deploy => LateFile.new("/opt/nailgun/bin/deploy")
:late_deploy => LateFile.new("/opt/nailgun/bin/deploy"),
:late_agent => LateFile.new("/opt/nailgun/bin/agent"),
:late_agent_config => LateFile.new("
NodeAgentConfig.define do |config|
config.api = \"http://#{node.cobbler.repoaddr}:8000/api\"
end
", :method => :content),
:late_rclocal => LateFile.new("
#!/bin/sh
flock -w 0 -o /var/lock/agent.lock -c \"/opt/nailgun/bin/agent -c /opt/nailgun/bin/agent_config.rb > /var/log/agent.log 2>&1\" || true
", :method => :content)
)
end

View File

@ -64,10 +64,18 @@ chmod 700 /root/.ssh
mkdir -p /opt/nailgun/bin
<%= @late_deploy.init.cobbler_late_file("/opt/nailgun/bin/deploy", "755") %>
# agent script
mkdir -p /opt/nailgun/bin
<%= @late_agent.init.cobbler_late_file("/opt/nailgun/bin/agent", "755") %>
<%= @late_agent_config.init.cobbler_late_file("/opt/nailgun/bin/agent_config.rb", "644") %>
# install chef
# gem sources -l | grep -v "*** CURRENT SOURCES ***\|^$" | while read repo; do gem sources -r \${repo}; done
# gem sources -a http://<%= node.cobbler.repoaddr %>/gems/gems
gem install ohai --source http://<%= node.cobbler.repoaddr %>/gems/ --no-ri --no-rdoc
gem install chef --source http://<%= node.cobbler.repoaddr %>/gems/ --no-ri --no-rdoc
gem install httpclient --source http://<%= node.cobbler.repoaddr %>/gems/ --no-ri --no-rdoc
%post --log=/root/nopxe.log
# nopxe