Skip to content

Commit

Permalink
knife solo bootstrap for each node
Browse files Browse the repository at this point in the history
  • Loading branch information
Iman Tung committed May 4, 2018
1 parent d10ca76 commit 4b282fe
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/models/blueprint.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class Blueprint
attr_accessor :provisioning, :vagrant, :chef_repo_dir, :nodes
attr_accessor :provisioning, :vagrant, :chef_repo, :nodes

def initialize args
@provisioning = args['provisioning']
@chef_repo_dir = args['chef_repo_dir']
@chef_repo = args['chef_repo']
@vagrant = BlueprintVagrant.new(args['vagrant'])
@nodes = []
args['nodes'].each do |node|
Expand Down
2 changes: 1 addition & 1 deletion app/models/blueprint_node.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class BlueprintNode
attr_accessor :name, :chef_config_file
attr_accessor :name, :chef_node_config

def initialize args
args.each do |k,v|
Expand Down
11 changes: 4 additions & 7 deletions lib/tasks/blueprint.rake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ namespace :blueprint do
node_cnt = 0

blueprint.nodes.each do |node|
puts "\n\n[#{node.name}] Start provision"

node_dir = "#{blueprint.vagrant.work_dir}/#{node.name}"

id = BlueprintHelper::get_id(node_dir)
Expand All @@ -28,7 +30,7 @@ namespace :blueprint do

FileUtils::mkdir_p node_dir

puts "\n\n[#{node.name}] Write the #{node_dir}/Vagrantfile"
puts "[#{node.name}] Write the #{node_dir}/Vagrantfile"
vagrantfile = BlueprintHelper::vagrantfile({
:name => node.name,
:ip_address => "172.10.0.#{2 + node_cnt}",
Expand All @@ -52,17 +54,12 @@ namespace :blueprint do
end

puts "[#{node.name}] Vagrant ID: #{id}"
system "cd #{blueprint.chef_repo} && bundle exec knife solo bootstrap default nodes/#{node.chef_node_config} -F ../#{node_dir}/#{SSH_CONFIG}"

node_cnt += 1
end

end

# TODO: run chef bootstrap for each node
# nodes.each do |node|
# node = node.symbolize_keys
# puts "cd #{chef_repo_dir}"
# end
end


Expand Down
2 changes: 1 addition & 1 deletion sample.blueprint.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"provisioning":"vagrant",
"chef_repo_dir": ".",
"chef_repo": "./chef-repo",
"vagrant":{
"work_dir": "vagrant_work_dir"
},
Expand Down

0 comments on commit 4b282fe

Please sign in to comment.