Skip to content

Commit

Permalink
Virsh console is accessible
Browse files Browse the repository at this point in the history
 * Added a few variables to handle different Ubuntu versions
 * Using 'ens3' interface instead of 'eth0'
  • Loading branch information
c-buisson committed Jul 17, 2017
1 parent 7785ec4 commit 766d537
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 12 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
CHANGELOG
=========

2.8: 2017-07-17
---------------
New Feature:
- The virsh console is accessible.

Updates:
- Ubuntu Xenial 16.04 LTS is now the default cloud image.
- Defaulting user-data templates to use 'ens3' instead of 'eth0' because of "Ubuntu predictable network interface" feature.
- Get Libvirt group from config file. It can change between Ubuntu versions.
- Get Mysql and PostgreSQL candidate versions to install and configure them.

2.7: 2017-07-16
---------------
New Features:
Expand Down
4 changes: 2 additions & 2 deletions kvm/templates/TEMPLATE-user-data-nat.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ write_files:
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
auto ens3
iface ens3 inet static
address <%= var %>
netmask 255.255.255.0
gateway 192.168.122.1
Expand Down
4 changes: 2 additions & 2 deletions kvm/templates/TEMPLATE-user-data.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ write_files:
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
auto ens3
iface ens3 inet static
address <%= var %>
netmask 255.255.255.0
gateway <%= gateway_ip %>
Expand Down
6 changes: 6 additions & 0 deletions kvm/templates/TEMPLATE.xml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,11 @@
</interface>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='<%= vnc_port %>' autoport="no" listen='0.0.0.0'/>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
</devices>
</domain>
6 changes: 4 additions & 2 deletions scripts/install_kvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ apt-get -y install qemu-utils cloud-utils kvm libvirt-bin libvirt-dev
gem install ruby-libvirt --no-ri --no-rdoc --conservative
mkdir -p "$1"/{kvm_guests,lib,templates,lists,sources/{iso,cloud_images}}
grep -q "export LIBVIRT_DEFAULT_URI=qemu:///system" /etc/environment || echo "export LIBVIRT_DEFAULT_URI=qemu:///system" | tee -a /etc/environment
echo "Add rundeck user to libvirtd and kvm groups"
adduser rundeck libvirtd && adduser rundeck kvm
# Get Libvirt group name from file, it can change between Ubuntu versions.
libvirt_group=$(grep unix_sock_group /etc/libvirt/libvirtd.conf |awk '{print $3}' |cut -d '"' -f 2)
echo "Add rundeck user to $libvirt_group and kvm groups"
adduser rundeck $libvirt_group && adduser rundeck kvm
kvm_guests=$(virsh list)
if [[ -z "$kvm_guests" ]]; then
echo "Restart libvirtd..."
Expand Down
9 changes: 5 additions & 4 deletions scripts/install_rundeck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ cp /etc/rundeck/framework.properties.backup /etc/rundeck/framework.properties

# Install database
if [[ $3 == "mysql" ]]; then
echo "mysql-server-5.7 mysql-server/root_password password $4
mysql-server-5.7 mysql-server/root_password seen true
mysql-server-5.7 mysql-server/root_password_again password $4
mysql-server-5.7 mysql-server/root_password_again seen true
mysql_version=`apt-cache policy mysql-server |grep Candidate |grep -o "[0-9]\.[0-9]" |head -n 1`
echo "mysql-server-$mysql_version mysql-server/root_password password $4
mysql-server-$mysql_version mysql-server/root_password seen true
mysql-server-$mysql_version mysql-server/root_password_again password $4
mysql-server-$mysql_version mysql-server/root_password_again seen true
" | debconf-set-selections
export DEBIAN_FRONTEND=noninteractive
apt-get install -q -y mysql-server mysql-client libmysqlclient-dev
Expand Down
3 changes: 2 additions & 1 deletion scripts/setup_rundeck_db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
begin
system("gem install pg --no-ri --no-rdoc --conservative")
system("su - postgres -c \"createuser pguser -s\"")
%x[/bin/bash -c 'echo -e \"local all postgres peer\nlocal all pguser trust\nlocal all rduser trust\nlocal all all peer\nhost all all 127.0.0.1/32 md5\" | tee /etc/postgresql/9.5/main/pg_hba.conf']
postgres_version=`apt-cache policy postgresql |grep Candidate |grep -o -P "[0-9]\\.[0-9]"`.chomp
%x[/bin/bash -c 'echo -e \"local all postgres peer\nlocal all pguser trust\nlocal all rduser trust\nlocal all all peer\nhost all all 127.0.0.1/32 md5\" | tee /etc/postgresql/#{postgres_version}/main/pg_hba.conf']
system("systemctl restart postgresql && sleep 5")
system("createdb -p 5432 -O pguser -U pguser -E UTF8 #{database_name}")
system("createuser -p 5432 -U pguser rduser")
Expand Down
2 changes: 1 addition & 1 deletion vars
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ INTERFACE_OUT="enp0s25"
#-------------
# Backend: mysql OR postgres
BACKEND="mysql"
FIRST_IMAGE_SOURCE="https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img"
FIRST_IMAGE_SOURCE="https://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img"
SSH_KEYS=["PASTE YOUR SSH PUBLIC KEYS HERE", "ADD THE SECOND ONE HERE", "AND SO ON..."]

# Install Bind9 to manage KVM guests' DNS entries.
Expand Down

0 comments on commit 766d537

Please sign in to comment.