lib/gogetit/util.rb in gogetit-0.14.0 vs lib/gogetit/util.rb in gogetit-0.15.0
- old
+ new
@@ -63,11 +63,11 @@
logger.error("Unable to reach the server: #{uri.host} or port: #{uri.port}.")
false
end
end
- def knife_bootstrap(name, provider, config)
+ def knife_bootstrap_chef(name, provider, config)
logger.info("Calling <#{__method__.to_s}>")
config[:chef][:target_environment] ||= '_default'
if find_executable 'knife'
if system('knife ssl check')
install_cmd = "curl \
@@ -77,17 +77,32 @@
--node-name #{name} \
--ssh-user ubuntu \
--sudo \
--environment #{config[:chef][:target_environment]} \
--bootstrap-install-command \"#{install_cmd}\"".gsub(/ * /, ' ')
- puts 'Bootstrapping..'
- puts knife_cmd
+ puts 'Bootstrapping with chef-server..'
+ logger.info(knife_cmd)
system(knife_cmd)
end
end
end
+ def knife_bootstrap_zero(name, provider, config)
+ logger.info("Calling <#{__method__.to_s}>")
+ config[:chef][:target_environment] ||= '_default'
+ if find_executable 'knife'
+ knife_cmd = "knife zero bootstrap #{name} \
+ --node-name #{name} \
+ --ssh-user ubuntu \
+ --sudo \
+ --environment #{config[:chef][:target_environment]}".gsub(/ * /, ' ')
+ puts 'Bootstrapping with chef-zero..'
+ logger.info(knife_cmd)
+ system(knife_cmd)
+ end
+ end
+
def update_databags(config)
logger.info("Calling <#{__method__.to_s}>")
data_bags_dir = "#{config[:chef][:chef_repo_root]}/data_bags"
puts 'Listing databags..'
@@ -144,16 +159,31 @@
end
end
end
end
- def knife_remove(name)
+ def knife_remove(name, options)
logger.info("Calling <#{__method__.to_s}>")
if find_executable 'knife'
- if system('knife ssl check')
+ if options['chef']
+ if system('knife ssl check')
+ logger.info("With chef-server..")
+ puts "Deleting node #{name}.."
+ logger.info("knife node delete -y #{name}")
+ system("knife node delete -y #{name}")
+ puts "Deleting client #{name}.."
+ logger.info("knife client delete -y #{name}")
+ system("knife client delete -y #{name}")
+ else
+ abort('knife is not configured properly.')
+ end
+ elsif options['zero']
+ logger.info("With chef-zero..")
puts "Deleting node #{name}.."
+ logger.info("knife node delete -y #{name}")
system("knife node delete -y #{name}")
puts "Deleting client #{name}.."
+ logger.info("knife client delete -y #{name}")
system("knife client delete -y #{name}")
end
end
end