diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index b844b14..0000000
--- a/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-Gemfile.lock
diff --git a/CHANGELOG b/CHANGELOG
index 705e1e4..7b459c0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,41 @@
CHANGELOG
=========
+2.6: 2017-07-14
+---------------
+New Features:
+- New kvm-control job: "KVM: Delete all guests".
+- New kvm-control job: "Docker: Restart chef-rundeck".
+- Can re-fetch the Knife admin keys if needed.
+- Rundeck-cli now usable by the Linux user that installed Mission_Control.
+- Using job "Source: Add Cloud Image or ISO" to get the first source image.
+- Using Rundeck "Source: Add Cloud Image or ISO" job to fetch first source image instead of separate script.
+
+Updates:
+- Merged chef-server-control and kvm-control_with-Chef projects into kvm-control.
+- Load Rundeck jobs everytime the install script runs.
+- Use new XML format for Rundeck jobs.
+- Don't use 'bundle_install' method anymore. Use 'gem install' instead.
+- Renamed 'third_octet' by 'third_byte'.
+- Cleanup the use of the 'check_vars' method.
+- Took out duplicate jobs in chef-rundeck_jobs.xml.erb.
+- Updated get_ip_host logic.
+- Use libvirt gem for KVM jobs.
+- Don't need to get mysql-connector-java-5.1.40.tar.gz anymore.
+- Don't use sudo command everywhere.
+- Updated README.
+
+Fixes:
+- Don't restart Rundeck while installing KVM.
+
+Removed:
+- scripts/create_rd_projects.sh
+- kvm/templates/get_images.rb.erb
+- kvm/get_first_cloud_image.rb
+- docker/template/rundeck_jobs-chef.xml.erb
+- scripts/templates/Gemfile.erb
+- scripts/get_interface_ip.rb
+
2.5: 2017-06-16
---------------
New Features:
@@ -10,7 +45,7 @@ New Features:
- Using chef-rundeck in a container.
Updates:
-- Using newer Docker image (v2.3).
+- Using newer chef-server Docker image (v2.3).
- Shell and Ruby lint.
- Output color for the bash scripts.
- New env variable for libvirt.
diff --git a/Gemfile b/Gemfile
deleted file mode 100644
index 018aa6b..0000000
--- a/Gemfile
+++ /dev/null
@@ -1,4 +0,0 @@
-source 'https://rubygems.org'
-
-gem 'colorize'
-gem 'json'
diff --git a/README.md b/README.md
index f3c5f1a..7a19282 100644
--- a/README.md
+++ b/README.md
@@ -1,91 +1,90 @@
-#Mission_Control
+# Mission_Control
-##Description
+## Description
Mission_Control is a set of Rundeck projects that lets you `create / start / shutdown / destroy` virtual machines and containers.
-##Installation
+## Installation
-You will need to execute the `install` script to install all the required packages, gems and lay down the configuration files.
+First, edit the `vars` file with your parameters. Then, you will need to execute the `install` script to install all the required packages, gems and lay down the configuration files.
+```bash
+ cbuisson@server:~/mission_control$ ./install
+```
+To update the current configuration, edit the `vars` file and execute the `install` script again. The script can be run anytime.
- ./install
+## Environment
-**Variables:** You can edit the `vars` file to reflect your current environment or what you want. You can paste your SSH public keys here.
+Mission_Control has been developed for a **brand new** install of **Ubuntu Xenial 16.04 LTS**.
-The install process will display a menu where you can choose to install any feature that you want.
+## Project: *kvm-control*
-##Environment
+Launch a new personalized KVM guest with:
+ - SSH public keys importation
+ - Automatic DNS entry creation
+ - Static IP assignment
+ - VNC accessibility
+ - Chef-client installed and configured
-Mission_Control has been developed for **Ubuntu Xenial 16.04 LTS**.
+kvm-control will launch the KVM guests with a fully qualified domain name `.local`. Bind9 will be installed/used by default to dynamically manage the DNS A and PTR records.
-#*kvm-control*
+kvm-control was designed to work with Class C IPs. The netmask is hard coded to: **255.255.255.0**.
-You can choose to start a new virtual machine with an ISO or an Ubuntu Cloud image.
+You can also choose to start a new virtual machine with an ISO or an Ubuntu Cloud image. When an Ubuntu Cloud image is used to launch a new instance, the KVM guest will get a static IP. ISO's on the other hand, will get a DHCP IP.
-When an Ubuntu Cloud image is used to launch a new instance, the vm will get a static IP. ISO's on the other hand, will get a DHCP ip.
+### Network setup (Floating IP / NAT IP)
-###Network types:
-*Netmask*: kvm-control was designed to work with Class C IPs, therefore the netmask is hard coded to: 255.255.255.0
+You can choose to assign a floating IP (public address accessible by external servers on the same local network) or a NAT IP (private address accessible by the hypervisor only) when launching a new KVM guest in Rundeck. The guest will be assigned a static IP and a VNC port.
-*Fqdn*: kvm-control will launch the KVM guests with a fully qualified domain name `.local`. Bind9 will be installed by default to dynamically manage the DNS A and PTR records. See `vars` file.
+Deleting the KVM guest will release both the IP (floating or NAT) and the VNC port.
-####Floating IPs
+### Floating IPs
-You will need to edit the `vars` file and add:
+You will need to edit the `vars` file and already have created a Linux bridge interface:
- - The interface out (**Must be br0** if using floating static IPs!)
- - A backend type (*MySQL or PostgreSQL*)
+ - Interface out (**Must be named**: `br0`!)
- Start IP (*i.e 192.168.0.1*)
- End IP (*i.e 192.168.0.100*)
- Gateway IP (*i.e 192.168.0.254*)
-Mission_Control will assign floating IPs to the KVM guests. Those floating IPs should be able to reach the hypervisor's IP and the gateway. You need to specify a floating IP range for the guests and a gateway to route out.
-
-**NAT IPs**:
-
-By default Libvirt will install a new interface `virbr0` that will be managed by a DNSmasq process. DNSmasq will assign IPs to the new KVM guest with DHCP. The default range is:
-
-- *192.168.122.2 to 192.168.122.254*
+The kvm-control's jobs will assign floating IPs to the KVM guests. These floating IPs should be able to reach the hypervisor and the gateway IPs.
-You can choose to assign a floating IP or a NAT IP when launching a new guest in Rundeck (i.e `Launch KVM guest`). Either way, the guest will be assigned a reserve static IP and a VNC port.
+### NAT IPs
-Deleting the KVM guest will release both the IP (floating or NAT) and the VNC port.
-
-#*chef_server-control*
+By default, Libvirt will configure a new interface (`virbr0`) that will be managed by a DNSmasq process. DNSmasq will assign IPs to the new KVM guest with DHCP. The default range is from **192.168.122.2** to **192.168.122.254**.
-This is a Docker container that come with Chef Server 11 already installed. Mission_Control will download and launch this container if you want to. It will also grab the Knife admin keys and configure the Rundeck user to be able to use Knife.
+### Chef-Server
-Also, the gem `chef-rundeck` will be installed and configure. This allows Rundeck to display Chef nodes directly in the "Nodes" panel. You can run command directly to the Chef nodes via Rundeck.
+You can optionally bootstrap the KVM guests to a Chef-Server at launch time.
+In order to use this feature, select the "Docker Chef container" option while running the `install` script. This option will appears after the installation of `kvm-control`.
-#*docker-control*
+Mission_Control will start the two following Docker instances:
-You can manage Docker containers and images with this project.
+**Chef-Server**: Comes with Chef Server 12 already installed and configured. Mission_Control will also grab the Knife admin keys and configure both your current user and the Rundeck user to be able to use the Knife command.
-Assumptions
------------
+**Chef-Rundeck**: Allows Rundeck to display the Chef client nodes directly in the "Nodes" tab. Once visible, you can run commands directly to the Chef client nodes from the Rundeck UI.
-###kvm-control:
+### Notes
- - VMs will reach the internet trough the hypervisor via `br0` if floating IP selected. While using NAT, `virbr0` will be used.
+ - KVM guests will reach the internet trough the hypervisor via `br0` when the floating IPs are selected.
- If a guest is launched with the NAT option, `virbr0` (192.168.122.1) will be used to route out.
-###chef_server-control:
-
- - The Docker Chef_Server will be accessible via HTTPS:$CHEF_PORT.
+ - The Chef-Server container will be accessible from the hypervisor via: HTTPS://$CHEF_SERVER_CONTAINER_NAME:$CHEF_PORT.
-Requirements
------------
-
-###KVM
+### KVM Requirements
The hypervisor should have `Virtual Technology` enabled. You can test this prior the installation by running:
-
- ubuntu@cbuisson:~$ egrep -c '(vmx|svm)' /proc/cpuinfo
+```bash
+ cbuisson@server:~$ egrep -c '(vmx|svm)' /proc/cpuinfo
#Anything but 0 is good.
-
+```
And after the installation:
-
- ubuntu@cbuisson:~$ kvm-ok
+```bash
+ cbuisson@server:~$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
+```
+
+## Project: *docker-control*
+
+You can manage Docker containers and images with this project.
diff --git a/docker/rundeck_jobs.xml b/docker/rundeck_jobs.xml
index 78a1f44..e166402 100644
--- a/docker/rundeck_jobs.xml
+++ b/docker/rundeck_jobs.xml
@@ -1,40 +1,47 @@
- 96a978e4-2e96-4b23-89c0-ff6d1d8ddad6
+ Stop and delete all Docker containers!
+ true
+ 09bfb40a-26b8-4c29-b342-9391bfea40b6INFO
+ Delete all containers
+ true
+ true
-
+
+
+
+
- Stop all Docker containers.
- Stop all containers
-
- docker-control
-
- 96a978e4-2e96-4b23-89c0-ff6d1d8ddad6
+ 09bfb40a-26b8-4c29-b342-9391bfea40b6
- f111f4ca-4ba4-4945-be86-bfe5b47a1114
+ Delete all Docker images.
+ true
+ e08a615e-9aac-4913-a831-468cd7fc7e0dINFO
+ Delete all images
+ true
+ true
-
+
- Delete all Docker images.
- Delete all images
-
- docker-control
-
- f111f4ca-4ba4-4945-be86-bfe5b47a1114
+ e08a615e-9aac-4913-a831-468cd7fc7e0d
- 416d8f91-f0c2-4603-9a70-1ad91242a51d
+ List them all!
+ true
+ 51726770-d6e5-4fbb-9287-b77461badfbcINFO
+ List all containers
+ true
+ true
-
-
-
-
-
+docker ps -a]]>
+
- Stop and delete all Docker containers!
- Delete all containers
-
- docker-control
-
- 416d8f91-f0c2-4603-9a70-1ad91242a51d
+ 51726770-d6e5-4fbb-9287-b77461badfbc
- cd820882-15bf-4f30-b7b3-ec4e60dd548a
+ List all local images
+ true
+ 0a718e02-5189-4dbf-8e19-300108561a87INFO
+ List all images
+ true
+ true
-
+docker images]]>
+
- List them all!
- List all containers
-
- docker-control
-
- cd820882-15bf-4f30-b7b3-ec4e60dd548a
+ 0a718e02-5189-4dbf-8e19-300108561a87
- bbf54c33-fc96-48eb-a61e-f887917e6abe
+ List only the running containers
+ true
+ 3d19b229-ebef-4fc7-9904-75efaa14621bINFO
+ List all running containers
+ true
+ true
-
+
- List only the running containers
- List all running containers
-
- docker-control
-
- bbf54c33-fc96-48eb-a61e-f887917e6abe
+ 3d19b229-ebef-4fc7-9904-75efaa14621b
- 0ad015fb-9883-4f11-850e-effd25517d37
+ Stop all Docker containers.
+ true
+ 86a67182-ffbf-4f17-9654-aa253f0e5355INFO
+ Stop all containers
+ true
+ true
-
-
+ sleep 5
+ system("docker ps -a")
+ puts "\nAll the Docker containers have been stopped!"
+end]]>
+
- List all local images
- List all images
-
- docker-control
-
- 0ad015fb-9883-4f11-850e-effd25517d37
+ 86a67182-ffbf-4f17-9654-aa253f0e5355
diff --git a/docker/template/rundeck_jobs-chef.xml.erb b/docker/template/rundeck_jobs-chef.xml.erb
deleted file mode 100644
index fd47f7d..0000000
--- a/docker/template/rundeck_jobs-chef.xml.erb
+++ /dev/null
@@ -1,81 +0,0 @@
-
-
- a37ea70a-b691-4fad-a78e-f049000850eb
- INFO
-
-
-
-
-
-
- Find <%= CHEF_SERVER_CONTAINER_NAME %> image and container ID then delete all the files.
- Remove <%= CHEF_SERVER_CONTAINER_NAME %> container
-
- chef_server-control
-
- a37ea70a-b691-4fad-a78e-f049000850eb
-
-
- a82e287f-e142-40d8-ad29-f065ac2e2893
- INFO
-
-
-
-
-
-
- Start container: <%= CHEF_SERVER_CONTAINER_NAME %>
- Start <%= CHEF_SERVER_CONTAINER_NAME %>
-
- chef_server-control
-
- a82e287f-e142-40d8-ad29-f065ac2e2893
-
-
- e6246fc8-9101-413c-a8e2-c2300b01aca8
- INFO
-
-
-
-
-
-
- Shutdown container: <%= CHEF_SERVER_CONTAINER_NAME %>
- Stop <%= CHEF_SERVER_CONTAINER_NAME %>
-
- chef_server-control
-
- e6246fc8-9101-413c-a8e2-c2300b01aca8
-
-
diff --git a/install b/install
index 1469387..a80b18e 100755
--- a/install
+++ b/install
@@ -1,4 +1,5 @@
#!/bin/bash -e
+
echo "Welcome to:"
echo "-----------"
echo " __ __ __ __ __ ___ __ __"
@@ -6,9 +7,6 @@ echo " |\/| | /__\` /__\` | / \\ |\\ | / \` / \\ |\\ | | |__) / \\ |"
echo " | | | .__/ .__/ | \\__/ | \\| ___ \\__, \\__/ | \\| | | \\ \\__/ |___"
echo -e "\n\nInstallation is progress...\n"
sudo apt-get -q update
-sudo apt-get -y install build-essential curl uuid-runtime ruby2.3 ruby2.3-dev
-echo "Installing: bundler"
-sudo gem install bundler --no-ri --no-rdoc
-bundle install
-ruby=`which ruby`
-sudo $ruby scripts/menu_main.rb
+sudo apt-get -y install build-essential curl uuid-runtime ruby2.3 ruby2.3-dev libxml2 libxml2-dev libxslt1-dev gcc make zlib1g-dev ruby-dev liblzma-dev
+sudo gem install json colorize ffi nokogiri --no-ri --no-rdoc --conservative
+sudo ruby scripts/menu_main.rb
diff --git a/kvm/chef_generate_scripts.rb b/kvm/chef_generate_scripts.rb
index ce6fea1..196603a 100644
--- a/kvm/chef_generate_scripts.rb
+++ b/kvm/chef_generate_scripts.rb
@@ -11,7 +11,7 @@ def chef_generate_scripts(backend, kvm_folder, floating, bind9)
file.puts xml_content
end
- system("#{dir}/../scripts/create_rd_projects.sh \"kvm-control_with-Chef\" #{kvm_folder}")
- system("sudo chown -R rundeck. #{kvm_folder}")
+ system("#{dir}/../scripts/rd_cmd.sh \"kvm-control_with-Chef\" #{kvm_folder}")
+ system("chown -R rundeck. #{kvm_folder}")
end
diff --git a/kvm/generate_scripts-floating.rb b/kvm/generate_scripts-floating.rb
index a6c751b..abf217d 100644
--- a/kvm/generate_scripts-floating.rb
+++ b/kvm/generate_scripts-floating.rb
@@ -4,11 +4,14 @@
def generate_scripts(backend, database_name, db_kvm_table, mysql_password, kvm_folder, start_ip, end_ip, gateway_ip, ssh_keys, floating, rundeck_key, bind9, ip_host)
dir=File.expand_path(File.dirname(__FILE__))
- #Generate ENV file
- template = ERB.new(File.read("#{dir}/templates/ENV.erb"))
- xml_content = template.result(binding)
- File.open("#{kvm_folder}/ENV", "w") do |file|
- file.puts xml_content
+ #Generate ENV and rundeck_jobs.xml files
+ misc_files = ["rundeck_jobs.xml", "ENV"]
+ misc_files.each do |misc|
+ template = ERB.new(File.read("#{dir}/templates/#{misc}.erb"))
+ xml_content = template.result(binding)
+ File.open("#{kvm_folder}/#{misc}", "w") do |file|
+ file.puts xml_content
+ end
end
#Generate lib files
@@ -21,17 +24,7 @@ def generate_scripts(backend, database_name, db_kvm_table, mysql_password, kvm_f
end
end
- #Generate misc files
- misc_files = ["rundeck_jobs.xml", "get_images.rb"]
- misc_files.each do |misc|
- template = ERB.new(File.read("#{dir}/templates/#{misc}.erb"))
- xml_content = template.result(binding)
- File.open("#{kvm_folder}/#{misc}", "w") do |file|
- file.puts xml_content
- end
- end
-
- system("#{dir}/../scripts/create_rd_projects.sh \"kvm-control\" #{kvm_folder}")
+ system("#{dir}/../scripts/rd_cmd.sh \"kvm-control\" #{kvm_folder}")
#Generate user-data template files
user_data_templates=["TEMPLATE-user-data", "TEMPLATE-user-data-nat"].each do |ud|
@@ -44,8 +37,8 @@ def generate_scripts(backend, database_name, db_kvm_table, mysql_password, kvm_f
end
end
- system("sudo cp #{dir}/templates/TEMPLATE.xml.erb #{kvm_folder}/templates/")
- system("sudo chown -R rundeck. #{kvm_folder}")
+ system("cp #{dir}/templates/TEMPLATE.xml.erb #{kvm_folder}/templates/")
+ system("chown -R rundeck. #{kvm_folder}")
puts "\nAll the scripts were generated!\n Mission_Control folder location: #{kvm_folder}\n Backend: #{backend}\n Floating IP Range: #{start_ip} to #{end_ip}"
end
diff --git a/kvm/generate_scripts.rb b/kvm/generate_scripts.rb
index 6d42b6d..306fa3c 100644
--- a/kvm/generate_scripts.rb
+++ b/kvm/generate_scripts.rb
@@ -4,11 +4,14 @@
def generate_scripts(backend, database_name, db_kvm_table, mysql_password, kvm_folder, ssh_keys, floating, rundeck_key, bind9, ip_host)
dir=File.expand_path(File.dirname(__FILE__))
- #Generate ENV file
- template = ERB.new(File.read("#{dir}/templates/ENV.erb"))
- xml_content = template.result(binding)
- File.open("#{kvm_folder}/ENV", "w") do |file|
- file.puts xml_content
+ #Generate ENV and rundeck_jobs.xml files
+ misc_files = ["rundeck_jobs.xml", "ENV"]
+ misc_files.each do |misc|
+ template = ERB.new(File.read("#{dir}/templates/#{misc}.erb"))
+ xml_content = template.result(binding)
+ File.open("#{kvm_folder}/#{misc}", "w") do |file|
+ file.puts xml_content
+ end
end
#Generate lib files
@@ -21,17 +24,7 @@ def generate_scripts(backend, database_name, db_kvm_table, mysql_password, kvm_f
end
end
- #Generate misc files
- misc_files = ["rundeck_jobs.xml", "get_images.rb"]
- misc_files.each do |misc|
- template = ERB.new(File.read("#{dir}/templates/#{misc}.erb"))
- xml_content = template.result(binding)
- File.open("#{kvm_folder}/#{misc}", "w") do |file|
- file.puts xml_content
- end
- end
-
- system("#{dir}/../scripts/create_rd_projects.sh \"kvm-control\" #{kvm_folder}")
+ system("#{dir}/../scripts/rd_cmd.sh \"kvm-control\" #{kvm_folder}")
#Generate user-data template file
var = "<%= ip %>"
@@ -42,8 +35,8 @@ def generate_scripts(backend, database_name, db_kvm_table, mysql_password, kvm_f
file.puts xml_content
end
- system("sudo cp #{dir}/templates/TEMPLATE.xml.erb #{kvm_folder}/templates/")
- system("sudo chown -R rundeck. #{kvm_folder}")
+ system("cp #{dir}/templates/TEMPLATE.xml.erb #{kvm_folder}/templates/")
+ system("chown -R rundeck. #{kvm_folder}")
puts "\nAll the scripts were generated!\n Mission_Control folder location: #{kvm_folder}\n Backend: #{backend}"
end
diff --git a/kvm/get_first_cloud_image.rb b/kvm/get_first_cloud_image.rb
deleted file mode 100644
index 4994967..0000000
--- a/kvm/get_first_cloud_image.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/ruby
-
-def get_first_cloud_image(kvm_folder, first_image_source)
- filename = first_image_source.split(/\?/).first.split(/\//).last
- if File.exist?(kvm_folder+"/sources/cloud_images/"+filename)
- puts "#{filename} is already in #{kvm_folder}/sources/cloud_images/ skipping..."
- elsif File.exist?(kvm_folder+"/sources/iso/"+filename)
- puts "#{filename} is already in #{kvm_folder}/sources/iso/ skipping..."
- else
- system("sudo ruby #{kvm_folder}/get_images.rb #{first_image_source}")
- end
-end
diff --git a/kvm/setup_db.rb b/kvm/setup_db.rb
index 3dfbc1a..14126dd 100644
--- a/kvm/setup_db.rb
+++ b/kvm/setup_db.rb
@@ -3,7 +3,7 @@
def setup_kvm_db(backend, database_name, db_kvm_table, mysql_password)
if backend == "mysql"
begin
- bundle_install "mysql2"
+ system("gem install mysql2 --no-ri --no-rdoc --conservative")
Gem.clear_paths
require 'mysql2'
client = Mysql2::Client.new(:host => "localhost", :username => "root", :password => mysql_password)
@@ -16,8 +16,9 @@ def setup_kvm_db(backend, database_name, db_kvm_table, mysql_password)
puts "\nDatabase \"#{database_name}\" created!"
elsif backend == "postgres"
begin
+ system("gem install pg --no-ri --no-rdoc --conservative")
+ Gem.clear_paths
system("createdb -p 5432 -O pguser -U pguser -E UTF8 #{database_name}")
- bundle_install "pg"
require 'pg'
conn = PG::Connection.open(:dbname => "#{database_name}", :user => "pguser")
conn.exec_params("CREATE TABLE IF NOT EXISTS #{db_kvm_table} (
@@ -26,5 +27,8 @@ def setup_kvm_db(backend, database_name, db_kvm_table, mysql_password)
puts e.error
end
puts "\nDatabase \"#{database_name}\" created!"
+ else
+ puts "BACKEND variable must be: 'mysql' OR 'postgres'! Please update 'vars' file!"
+ exit 1
end
end
diff --git a/kvm/templates/chef-rundeck_jobs.xml.erb b/kvm/templates/chef-rundeck_jobs.xml.erb
index 5acf328..c8fae99 100644
--- a/kvm/templates/chef-rundeck_jobs.xml.erb
+++ b/kvm/templates/chef-rundeck_jobs.xml.erb
@@ -1,355 +1,226 @@
-
-
- 0ecde969-5e0e-4911-a775-30e22b567ea6
+
+
+
+
+
+ Bootstrap a guest to the Docker Chef server.
+ true
+ cac7cc96-2721-4d2e-bd1c-7f5655a0dd11INFO
-
+ 4.Bootstrap guest
+ true
+ true
+
-
+puts "\n#{ENV['RD_OPTION_NAME']} is now bootstrapped to the Chef server!".cyan]]>
+
+
+
+
- Will use the guest's xml and start the vm with VIRSH.
- 3.Create VIRSH guest
-
- kvm-control_with-Chef
-
-
-
-
- 0ecde969-5e0e-4911-a775-30e22b567ea6
+ cac7cc96-2721-4d2e-bd1c-7f5655a0dd11
- eb389931-e126-45aa-9709-87e9d7c062fa
+ Delete both Chef containers.
+ true
+ a3a622f8-2e00-4942-bc6d-ce0f8f0b6088INFO
-
+ Docker: Delete chef-server and chef-rundeck containers
+ true
+ true
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+ a3a622f8-2e00-4942-bc6d-ce0f8f0b6088
+
+
+ Restart chef-rundeck container to have the lastest node list.
+ true
+ aafaf955-50c1-4db0-a1f0-06126fceb450
+ INFO
+ Docker: Restart chef-rundeck
+ false
+ true
+
+
+ docker restart chef-rundeck
+
+
+
+
+
+
+
+ aafaf955-50c1-4db0-a1f0-06126fceb450
+
+
+ Start both Chef containers.
+ true
+ 1732d47e-23bf-495b-969c-cb8d45b49c10
+ INFO
+ Docker: Start chef-server and chef-rundeck containers
+ true
+ true
+
+
+
+puts "Done!".bold]]>
+
+
+
+
+
+
- This will generate a guest XML.
- 2.Create guest XML
-
- kvm-control_with-Chef
-
-
- <% if floating == "yes" %>
- <% elsif floating == "no" %><% end %>
-
-
-
-
- eb389931-e126-45aa-9709-87e9d7c062fa
+ 1732d47e-23bf-495b-969c-cb8d45b49c10
- 340bfb41-a016-4664-b29e-1850525476a6
+ Stop both Chef containers.
+ true
+ 8a7a644c-3415-4db0-96b7-d7f30a395598INFO
-
+ Docker: Stop chef-server and chef-rundeck containers
+ true
+ true
+
-
-
-
-
-
-
+puts "Done!".bold]]>
+
- Create a QEMU file for KVM.
- 1.Create image disk
+ 8a7a644c-3415-4db0-96b7-d7f30a395598
+
+
- kvm-control_with-Chef
-
-
- 340bfb41-a016-4664-b29e-1850525476a6
-
-
- d178c0da-7b26-46dd-89ee-76f10b4adc09
+ Destroy a vm and remove all its files.
+ true
+ d19116c4-98a7-4153-8139-52c88a435953INFO
-
+ KVM: Delete guest
+ true
+ true
+
-
-
-
- Destroy a vm and remove all its files.
- Delete guest
-
- kvm-control_with-Chef
-
-
-
-
- 5a86aa1c-7ef2-4631-94e5-d5487ccb5414
+ 42d8f84b-ee23-4fac-bab9-2c07b6b422bd
- ad824dcf-169d-46eb-ba90-2eb39646518d
+ Destroy all vms and remove all their files.
+ true
+ eaa03caf-e741-4233-ab81-59425cb478dfINFO
+ KVM: Delete all guests
+ true
+ true
-
-
-
- Get a list of all the guests' info.
- List ALL guests info
-
- kvm-control_with-Chef
-
- ad824dcf-169d-46eb-ba90-2eb39646518d
-
-
- 3cbeda79-5d8f-4658-be67-a63fa62024e4
- INFO
-
-
-
-
-
-
- Starting all the guests.
- Start ALL non-running guests
-
- kvm-control_with-Chef
-
- 3cbeda79-5d8f-4658-be67-a63fa62024e4
-
-
- 3b2eb65d-00ef-47e6-bb93-64fbc6975768
- INFO
-
-
-
-
+
-
- Stopping all the guests.
- Stop ALL guests
-
- kvm-control_with-Chef
-
- 3b2eb65d-00ef-47e6-bb93-64fbc6975768
-
-
- eb6f541a-46ee-4a38-91e7-35e67ca8984e
- INFO
-
-
-
+
- Bootstrap a guest to the Docker Chef server.
- 4.Bootstrap guest
-
- kvm-control_with-Chef
-
-
- Guest's name
-
-
-
- eb6f541a-46ee-4a38-91e7-35e67ca8984e
+ eaa03caf-e741-4233-ab81-59425cb478df
diff --git a/kvm/templates/get_images.rb.erb b/kvm/templates/get_images.rb.erb
deleted file mode 100755
index 6872b37..0000000
--- a/kvm/templates/get_images.rb.erb
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/ruby
-
-guest=""
-eval File.read("<%= kvm_folder %>/ENV")
-require_relative "#{LIB}/lists.rb"
-
-if ARGV[0].nil?
- puts "This script will download and place any ISO or Cloud Image to the correct location"
- puts "For Ubuntu ISO, go to: http://mirror.anl.gov/pub/ubuntu-iso/DVDs/ubuntu/"
- puts "For Ubuntu Cloud Image, go to: https://cloud-images.ubuntu.com/"
- puts "\nUsage: get_images.rb URL"
- exit 1
-end
-
-url=ARGV[0]
-filename = ARGV[0].split(/\?/).first.split(/\//).last
-
-if url.end_with? "img"
- type="cloud_image"
- puts "\nDownloading #{filename}...\n"
- system("wget #{url} -P #{CLOUD_IMAGES}") or raise "Error while downloading that Cloud Image. Wrong URL maybe?"
-elsif url.end_with? "iso"
- type="iso"
- puts "\nDownloading #{filename}...\n"
- system("wget #{url} -P #{ISO}") or raise "Error while downloading that ISO. Wrong URL maybe?"
-else
- puts "\nDoesn't support this type of source"
- puts "Must be ISO or Cloud Image\n"
- exit 1
-end
-
- add_to_list "source", filename, type
- system("chown rundeck. <%= kvm_folder %>/lists/source_list.json")
- puts "Download completed!".cyan
diff --git a/kvm/templates/named.conf.local.erb b/kvm/templates/named.conf.local.erb
index 5a8ac4d..576d4b3 100644
--- a/kvm/templates/named.conf.local.erb
+++ b/kvm/templates/named.conf.local.erb
@@ -9,7 +9,7 @@ zone "122.168.192.in-addr.arpa" {
file "/etc/bind/db.1XX";
};
-<% unless floating == "no" %>zone "<%= third_octet %>.168.192.in-addr.arpa" {
+<% unless floating == "no" %>zone "<%= third_byte %>.168.192.in-addr.arpa" {
type master;
notify no;
file "/etc/bind/db.1XX";
diff --git a/kvm/templates/rundeck_jobs.xml.erb b/kvm/templates/rundeck_jobs.xml.erb
index b15f5c4..b4a5771 100644
--- a/kvm/templates/rundeck_jobs.xml.erb
+++ b/kvm/templates/rundeck_jobs.xml.erb
@@ -1,80 +1,108 @@
-
-
- 0ecde969-5e0e-4911-a775-30e22b567ea6
+
+
+
+ Guest's name
+
+
+ Disk space in Gb
+
+
+ Cloud Image or ISO
+
+
+
+ Create a QEMU file for KVM.
+ true
+ 41c655a6-4c98-4b9e-bdd5-3704ad7cbb92INFO
-
+ 1.Create image disk
+ true
+ true
+
-
+
+
+
+
+
+puts "\nNew image info:".underline
+system("qemu-img info #{KVM_GUEST_IMAGE}/#{guest}.img")
+puts ""]]>
+
- Will use the guest's xml and start the vm with VIRSH.
- 3.Create VIRSH guest
+ 41c655a6-4c98-4b9e-bdd5-3704ad7cbb92
+
+
- kvm-control
-
-
+
+
+ Number of cores
+
+
+ Guest's name
+
<% if floating == "yes" %>
+
+ NAT or Floating IP?
+
<% elsif floating == "no" %>
+ NAT IP
+
<% end %>
+
+ in Mb
+
+
+ Cloud Image or ISO
+
- 0ecde969-5e0e-4911-a775-30e22b567ea6
-
-
- eb389931-e126-45aa-9709-87e9d7c062fa
+ This will generate a guest XML.
+ true
+ c36ab893-f554-4d05-991a-b2ffbb3cabdeINFO
-
+ 2.Create guest XML
+ true
+ true
+
-
+
-
+
- This will generate a guest XML.
- 2.Create guest XML
+ c36ab893-f554-4d05-991a-b2ffbb3cabde
+
+
- kvm-control
-
-
- Number of cores
-
-
- Guest's name
-
<% if floating == "yes" %>
-
- NAT or Floating IP?
-
<% elsif floating == "no" %>
- NAT IP
-
<% end %>
-
- in Mb
-
-
- Cloud Image or ISO
-
+
+
- eb389931-e126-45aa-9709-87e9d7c062fa
-
-
- 340bfb41-a016-4664-b29e-1850525476a6
+ Will use the guest's xml and start the vm with VIRSH.
+ true
+ e5208703-0365-474e-a037-f2633f4c3b5fINFO
-
+ 3.Create VIRSH guest
+ true
+ true
+
-
-
-
-
-
-
+<% if backend == "mysql" %>
+require_relative "#{LIB}/mysql_backend.rb"<% elsif backend == "postgres" %>
+require_relative "#{LIB}/postgres_backend.rb"<% end %>
+ip = guest_ip guest
+
+puts "Wait while #{guest} comes up".bold
+system("
+IP=\"#{ip}\"
+CODE=1
+TIMEOUT=200
+TRIES=0
+echo \"Blocking until ${IP} responds...\"
+echo \"Number of tries: ${TIMEOUT}\"
+echo \"\"
+while [ $CODE -ne 0 ]; do
+ echo \"Try number: $TRIES/$TIMEOUT\"
+ ping -c 1 $IP >/dev/null
+ CODE=$?
+ TRIES=$(( $TRIES + 1 ))
+ if [ $TRIES -ge $TIMEOUT ]; then
+ echo \"$IP is not available after $TRIES seconds...stopping the install!\"
+ exit 1
+ fi
+done;
+echo \"#{guest} is ready, you can now SSH in with: ubuntu@$IP\"")
+
+with_chef=ENV['RD_OPTION_WITH_CHEF']
+unless with_chef.nil?
+ if with_chef == "yes"
+ puts "\nBootstrapping #{guest} with 'chef-server'!\n".bold
+ system("rd run -p kvm-control -j \"4.Bootstrap guest\" -f -- -name #{guest}") or raise "Couldn't bootstrap #{guest} on chef-server...".red
+ end
+end
+]]>
+
- Create a QEMU file for KVM.
- 1.Create image disk
+ e5208703-0365-474e-a037-f2633f4c3b5f
+
+
- kvm-control
-
-
+
+
Guest's name
-
- Disk space in Gb
-
-
- Cloud Image or ISO
-
- 340bfb41-a016-4664-b29e-1850525476a6
-
-
- d178c0da-7b26-46dd-89ee-76f10b4adc09
+ Destroy a vm and remove all its files.
+ true
+ d19116c4-98a7-4153-8139-52c88a435953INFO
-
+ KVM: Delete guest
+ true
+ true
+
-
+
- Destroy a vm and remove all its files.
- Delete guest
-
- kvm-control
-
-
- Guest's name
-
-
-
- d178c0da-7b26-46dd-89ee-76f10b4adc09
+ d19116c4-98a7-4153-8139-52c88a435953
- 89f2efe8-2091-430a-88a6-07a992c77862
+ Get a list of all the guests' info.
+ true
+ b164cd29-0676-4901-adf0-920a00162aa1INFO
-
-
-
-
-
-
-
-
-
-
-
+ KVM: List all guests info
+ true
+ true
+
-
-
-
+
+
- Launch a new instance!
- .Launch KVM guest
-
- kvm-control
-
-
- Number of cores
-
-
- Guest's name
-
<% if floating == "yes" %>
-
- NAT or Floating IP?
-
<% elsif floating == "no" %>
- NAT IP
-
<% end %>
-
- in Mb
-
-
- Disk space in Gb
-
-
- Cloud image or ISO
-
-
-
- 89f2efe8-2091-430a-88a6-07a992c77862
+ b164cd29-0676-4901-adf0-920a00162aa1
- 50fefa5d-7344-40b3-93d2-07e8ec34e56d
+ Starting all the guests.
+ true
+ 324882e4-242d-4a68-8221-828c1a64fcc9INFO
+ KVM: Start all guests
+ true
+ true
-
+sleep 3
+system("virsh list --all")]]>
+
- Deleting a source file. Ubuntu Cloud Image or ISO.
- Delete source file
+ 324882e4-242d-4a68-8221-828c1a64fcc9
+
+
- kvm-control
-
-