mirror of https://github.com/apache/cloudstack.git
First commit of the devcloud pre-configuration puppet module.
Using this via Vagrant assumes that Vagrant is patched with the changes made by Edison. The pull request to upstream these changes into the Vagrant project are here: https://github.com/mitchellh/vagrant/pull/1043 )
This commit is contained in:
parent
b037f2749d
commit
7da5ab8aca
|
|
@ -1,4 +0,0 @@
|
|||
[files]
|
||||
path /vagrant
|
||||
allow *
|
||||
|
||||
|
|
@ -0,0 +1,171 @@
|
|||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: xend
|
||||
# Required-Start: $remote_fs
|
||||
# Required-Stop: $remote_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: XEN control daemon
|
||||
# Description: XEN control daemon
|
||||
### END INIT INFO
|
||||
|
||||
PATH=/usr/lib/xen-common/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
DESC="Xen daemons"
|
||||
|
||||
VERSION=$(xen-version)
|
||||
ROOT=/usr/lib/xen-$VERSION
|
||||
|
||||
XEND="$ROOT"/bin/xend
|
||||
XENCONSOLED="$ROOT"/bin/xenconsoled
|
||||
XENCONSOLED_PIDFILE="/var/run/xenconsoled.pid"
|
||||
XENSTORED="$ROOT"/bin/xenstored
|
||||
XENSTORED_DIR="/var/run/xenstored"
|
||||
XENSTORED_PIDFILE="/var/run/xenstore.pid"
|
||||
|
||||
[ "$VERSION" ] || exit 0
|
||||
[ -x "$XEND" ] || exit 0
|
||||
|
||||
[ -r /etc/default/xend ] && . /etc/default/xend
|
||||
|
||||
. /lib/init/vars.sh
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
modules_setup()
|
||||
{
|
||||
modprobe xenfs 2>/dev/null
|
||||
modprobe xen-evtchn 2>/dev/null
|
||||
modprobe xen_blkback 2>/dev/null
|
||||
modprobe xen_netback 2>/dev/null
|
||||
modprobe xen_gntdev 2>/dev/null
|
||||
}
|
||||
|
||||
xenfs_setup()
|
||||
{
|
||||
[ -e "/proc/xen/capabilities" ] && return 0
|
||||
log_progress_msg "xenfs"
|
||||
[ -d "/proc/xen" ] || return 1
|
||||
mount -t xenfs xenfs /proc/xen || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
capability_check()
|
||||
{
|
||||
[ -e "/proc/xen/capabilities" ] || return 1
|
||||
grep -q "control_d" /proc/xen/capabilities || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
xend_start()
|
||||
{
|
||||
log_progress_msg "xend"
|
||||
$XEND status && return 1
|
||||
$XEND start || return 2
|
||||
|
||||
i=0
|
||||
while [ $i -lt 10 ]; do
|
||||
$XEND status && return 0 || true
|
||||
i=$(($i + 1))
|
||||
sleep 1
|
||||
done
|
||||
return 2
|
||||
}
|
||||
|
||||
xend_stop()
|
||||
{
|
||||
log_progress_msg "xend"
|
||||
$XEND status || return 0
|
||||
$XEND stop || return 1
|
||||
}
|
||||
|
||||
xenconsoled_start()
|
||||
{
|
||||
log_progress_msg "xenconsoled"
|
||||
start-stop-daemon --start --quiet --pidfile "$XENCONSOLED_PIDFILE" --exec "$XENCONSOLED" --test > /dev/null \
|
||||
|| return 1
|
||||
start-stop-daemon --start --quiet --pidfile "$XENCONSOLED_PIDFILE" --exec "$XENCONSOLED" -- \
|
||||
$XENCONSOLED_ARGS --pid-file="$XENCONSOLED_PIDFILE" \
|
||||
|| return 2
|
||||
}
|
||||
|
||||
xenstored_start()
|
||||
{
|
||||
log_progress_msg "xenstored"
|
||||
start-stop-daemon --start --quiet --pidfile "$XENSTORED_PIDFILE" --exec "$XENSTORED" --test > /dev/null \
|
||||
|| return 1
|
||||
[ -d "$XENSTORED_DIR" ] || mkdir -p "$XENSTORED_DIR"
|
||||
export XENSTORED_ROOTDIR="$XENSTORED_DIR"
|
||||
start-stop-daemon --start --quiet --pidfile "$XENSTORED_PIDFILE" --exec "$XENSTORED" -- \
|
||||
$XENSTORED_ARGS --pid-file="$XENSTORED_PIDFILE" \
|
||||
|| return 2
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
log_daemon_msg "Starting $DESC"
|
||||
modules_setup
|
||||
xenfs_setup
|
||||
case "$?" in
|
||||
0) ;;
|
||||
*) log_end_msg 1; exit ;;
|
||||
esac
|
||||
capability_check
|
||||
case "$?" in
|
||||
0) ;;
|
||||
*) log_end_msg 255; exit ;;
|
||||
esac
|
||||
xenstored_start
|
||||
case "$?" in
|
||||
0|1) ;;
|
||||
*) log_end_msg 1; exit ;;
|
||||
esac
|
||||
xenconsoled_start
|
||||
case "$?" in
|
||||
0|1) ;;
|
||||
*) log_end_msg 1; exit ;;
|
||||
esac
|
||||
#xend_start
|
||||
case "$?" in
|
||||
0|1) ;;
|
||||
*) log_end_msg 1; exit ;;
|
||||
esac
|
||||
log_end_msg 0
|
||||
;;
|
||||
stop)
|
||||
capability_check
|
||||
case "$?" in
|
||||
0) ;;
|
||||
*) exit ;;
|
||||
esac
|
||||
log_daemon_msg "Stopping $DESC"
|
||||
#xend_stop
|
||||
case "$?" in
|
||||
0|1) log_end_msg 0 ;;
|
||||
*) log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
restart|force-reload)
|
||||
capability_check
|
||||
case "$?" in
|
||||
0) ;;
|
||||
*) exit ;;
|
||||
esac
|
||||
log_daemon_msg "Restarting $DESC"
|
||||
#xend_stop
|
||||
case "$?" in
|
||||
0|1)
|
||||
#xend_start
|
||||
case "$?" in
|
||||
0) log_end_msg 0 ;;
|
||||
*) log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
*) log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|force-reload}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1 @@
|
|||
include puppet-devcloudinitial
|
||||
|
|
@ -9,39 +9,51 @@ class puppet-devcloudinitial {
|
|||
}
|
||||
|
||||
package { 'xcp-xapi':
|
||||
ensure => latest,
|
||||
require => Package['xen-hypervisor-4.1-amd64'],
|
||||
ensure => latest,
|
||||
}
|
||||
|
||||
file { '/etc/xcp/network.conf':
|
||||
require => Package['xcp-xapi'],
|
||||
ensure => 'file',
|
||||
source => 'puppet:///files/puppet-devcloudinitial/files/network.conf',
|
||||
source => 'puppet:///modules/puppet-devcloudinitial/network.conf',
|
||||
group => '0',
|
||||
mode => '644',
|
||||
owner => '0',
|
||||
}
|
||||
|
||||
exec { "/bin/sed -i -e 's/xend_start$/#xend_start/' -e 's/xend_stop$/#xend_stop/' /etc/init.d/xend":
|
||||
cwd => '/etc/init.d',
|
||||
file { '/etc/init.d/xend':
|
||||
require => Package['xcp-xapi'],
|
||||
ensure => 'file',
|
||||
source => 'puppet:///modules/puppet-devcloudinitial/xend',
|
||||
group => '0',
|
||||
owner => '0',
|
||||
mode => '755',
|
||||
}
|
||||
|
||||
service { 'xendomains':
|
||||
ensure => 'stopped',
|
||||
enable => 'false',
|
||||
require => Package['xcp-xapi'],
|
||||
ensure => 'stopped',
|
||||
enable => 'false',
|
||||
}
|
||||
|
||||
file { '/etc/default/grub':
|
||||
require => Package['xen-hypervisor-4.1-amd64'],
|
||||
ensure => 'file',
|
||||
source => 'puppet:///files/puppet-devcloudinitial/files/grub',
|
||||
source => 'puppet:///modules/puppet-devcloudinitial/grub',
|
||||
group => '0',
|
||||
mode => '644',
|
||||
owner => '0',
|
||||
}
|
||||
|
||||
exec { "/usr/sbin/update-grub":
|
||||
cwd => '/',
|
||||
subscribe => File['/etc/default/grub'],
|
||||
refreshonly => true,
|
||||
cwd => '/',
|
||||
}
|
||||
|
||||
file { '/usr/share/qemu':
|
||||
require => Package['xen-hypervisor-4.1-amd64'],
|
||||
ensure => 'directory',
|
||||
group => '0',
|
||||
mode => '755',
|
||||
|
|
@ -49,6 +61,7 @@ class puppet-devcloudinitial {
|
|||
}
|
||||
|
||||
file { '/usr/share/qemu/keymaps':
|
||||
require => File['/usr/share/qemu'],
|
||||
ensure => 'link',
|
||||
group => '0',
|
||||
mode => '777',
|
||||
|
|
@ -58,15 +71,16 @@ class puppet-devcloudinitial {
|
|||
|
||||
file { '/etc/network/interfaces':
|
||||
ensure => 'file',
|
||||
source => 'puppet:///files/puppet-devcloudinitial/files/interfaces',
|
||||
source => 'puppet:///modules/puppet-devcloudinitial/interfaces',
|
||||
group => '0',
|
||||
mode => '644',
|
||||
owner => '0',
|
||||
}
|
||||
|
||||
file { '/etc/default/xen':
|
||||
require => Package['xen-hypervisor-4.1-amd64'],
|
||||
ensure => 'file',
|
||||
source => 'puppet:///files/puppet-devcloudinitial/files/xen-defaults',
|
||||
source => 'puppet:///modules/puppet-devcloudinitial/xen-defaults',
|
||||
group => '0',
|
||||
mode => '644',
|
||||
owner => '0',
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ Vagrant::Config.run do |config|
|
|||
|
||||
# Uncomment this line to enable the console for debugging the
|
||||
# build process.
|
||||
config.vm.boot_mode = :gui
|
||||
#config.vm.boot_mode = :gui
|
||||
|
||||
# Setup port forwarding
|
||||
config.vm.forward_port 22, 2222
|
||||
|
|
@ -38,7 +38,13 @@ Vagrant::Config.run do |config|
|
|||
# Ensure the VM has the right virtual resources
|
||||
#config.vm.
|
||||
|
||||
#config.vm.provision :shell, :inline => "/vagrant/devcloudsetup.sh -p -v"
|
||||
config.vm.provision :puppet do |puppet|
|
||||
puppet.manifests_path = "puppet-devcloudinitial"
|
||||
puppet.manifest_file = "init.pp"
|
||||
puppet.with_ssh = true
|
||||
puppet.pp_path = "/etc/puppet"
|
||||
puppet.module_path = "puppet-devcloudinitial"
|
||||
end
|
||||
|
||||
# Enable provisioning with Puppet stand alone. Puppet manifests
|
||||
# are contained in a directory path relative to this Vagrantfile.
|
||||
|
|
|
|||
Loading…
Reference in New Issue