Add code for deploying swift
add task and method for deploying/destroying a swift cluster. Add ability to perform parallel provisioning with vagrant.
This commit is contained in:
10
Rakefile
10
Rakefile
@@ -30,11 +30,21 @@ namespace :openstack do
|
||||
destroy_all_vms
|
||||
end
|
||||
|
||||
desc 'destroy all swift vms'
|
||||
task 'destroy_swift' do
|
||||
destroy_swift_vms
|
||||
end
|
||||
|
||||
desc 'deploys the entire environment'
|
||||
task :deploy_two_node do
|
||||
deploy_two_node
|
||||
end
|
||||
|
||||
desc 'deploy a swift cluster'
|
||||
task :deploy_swift do
|
||||
deploy_swift_cluster
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
6
Vagrantfile
vendored
6
Vagrantfile
vendored
@@ -194,12 +194,6 @@ Vagrant::Config.run do |config|
|
||||
end
|
||||
|
||||
end
|
||||
agent.vm.provision :puppet do |puppet|
|
||||
puppet.manifests_path = 'manifests'
|
||||
puppet.manifest_file = 'site.pp'
|
||||
puppet.module_path = 'modules'
|
||||
#puppet.options = ['--verbose', '--show_diff', "--certname=#{node_name}"]
|
||||
puppet.options = ["--certname=#{node_name}"]
|
||||
|
||||
# export a data directory that can be used by hiera
|
||||
agent.vm.share_folder("hiera_data", '/etc/puppet/hiera_data', './hiera_data/')
|
||||
|
||||
@@ -47,6 +47,16 @@ module Puppetlabs
|
||||
ssh_data
|
||||
end
|
||||
|
||||
def swift_nodes
|
||||
[
|
||||
'swift_storage_1',
|
||||
'swift_storage_2',
|
||||
'swift_storage_3',
|
||||
'swift_proxy',
|
||||
'swift_keystone'
|
||||
]
|
||||
end
|
||||
|
||||
# destroy all vagrant instances
|
||||
def destroy_all_vms
|
||||
puts "About to destroy all vms..."
|
||||
@@ -54,6 +64,16 @@ module Puppetlabs
|
||||
puts "Destroyed all vms"
|
||||
end
|
||||
|
||||
def destroy_swift_vms
|
||||
puts "About to destroy all swift vms..."
|
||||
swift_nodes.each do |x|
|
||||
cmd_system("vagrant destroy #{x} --force")
|
||||
end
|
||||
puts "Destroyed all swift vms"
|
||||
on_box('puppetmaster', 'export RUBYLIB=/etc/puppet/modules-0/ruby-puppetdb/lib/; puppet query node --only-active --deactivate --puppetdb_host=puppetmaster.puppetlabs.lan --puppetdb_port=8081 --config=/etc/puppet/puppet.conf --ssldir=/var/lib/puppet/ssl --certname=puppetmaster.puppetlabs.lan')
|
||||
on_box('puppetmaster', 'rm /var/lib/puppet/ssl/*/swift*;rm /var/lib/puppet/ssl/ca/signed/swift*;')
|
||||
end
|
||||
|
||||
# adds the specified remote name as a read/write remote
|
||||
def dev_setup(remote_name)
|
||||
each_repo do |module_name|
|
||||
@@ -128,6 +148,53 @@ module Puppetlabs
|
||||
def deploy_two_node
|
||||
vagrant_command('up', 'openstack_controller')
|
||||
vagrant_command('up', 'compute1')
|
||||
# provision a list of vms in parallel
|
||||
def parallel_provision(vms)
|
||||
require 'thread'
|
||||
results = {}
|
||||
threads = []
|
||||
queue = Queue.new
|
||||
vms.each {|vm| vagrant_command(['up', '--no-provision'], vm) }
|
||||
vms.each do |vm|
|
||||
threads << Thread.new do
|
||||
result = cmd_system("vagrant provision #{vm}")
|
||||
# I cant use a regular vagrant call
|
||||
#result = vagrant_command('provision', vm)
|
||||
queue.push({vm => {'result' => result}})
|
||||
end
|
||||
end
|
||||
threads.each do |aThread|
|
||||
begin
|
||||
aThread.join
|
||||
rescue Exception => spawn_err
|
||||
puts("Failed spawning vagrant provision thread: #{spawn_err}")
|
||||
end
|
||||
end
|
||||
until queue.empty?
|
||||
provision_results = queue.pop
|
||||
results.merge!(provision_results)
|
||||
end
|
||||
results
|
||||
end
|
||||
|
||||
# deploys a 3 node swift cluster in parallel
|
||||
def deploy_swift_cluster
|
||||
vagrant_command('up', 'swift_keystone')
|
||||
parallel_provision(
|
||||
[
|
||||
'swift_storage_1',
|
||||
'swift_storage_2',
|
||||
'swift_storage_3'
|
||||
]
|
||||
)
|
||||
vagrant_command('up', 'swift_proxy')
|
||||
parallel_provision(
|
||||
[
|
||||
'swift_storage_1',
|
||||
'swift_storage_2',
|
||||
'swift_storage_3'
|
||||
]
|
||||
)
|
||||
end
|
||||
|
||||
def refresh_modules
|
||||
|
||||
Reference in New Issue
Block a user