Skip to content

Commit 7da5ab8

Browse files
committed
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: hashicorp/vagrant#1043 )
1 parent b037f27 commit 7da5ab8

5 files changed

Lines changed: 204 additions & 16 deletions

File tree

‎tools/devcloud/puppet/fileserver.conf‎

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
#!/bin/sh
2+
### BEGIN INIT INFO
3+
# Provides: xend
4+
# Required-Start: $remote_fs
5+
# Required-Stop: $remote_fs
6+
# Default-Start: 2 3 4 5
7+
# Default-Stop: 0 1 6
8+
# Short-Description: XEN control daemon
9+
# Description: XEN control daemon
10+
### END INIT INFO
11+
12+
PATH=/usr/lib/xen-common/bin:/sbin:/bin:/usr/sbin:/usr/bin
13+
DESC="Xen daemons"
14+
15+
VERSION=$(xen-version)
16+
ROOT=/usr/lib/xen-$VERSION
17+
18+
XEND="$ROOT"/bin/xend
19+
XENCONSOLED="$ROOT"/bin/xenconsoled
20+
XENCONSOLED_PIDFILE="/var/run/xenconsoled.pid"
21+
XENSTORED="$ROOT"/bin/xenstored
22+
XENSTORED_DIR="/var/run/xenstored"
23+
XENSTORED_PIDFILE="/var/run/xenstore.pid"
24+
25+
[ "$VERSION" ] || exit 0
26+
[ -x "$XEND" ] || exit 0
27+
28+
[ -r /etc/default/xend ] && . /etc/default/xend
29+
30+
. /lib/init/vars.sh
31+
. /lib/lsb/init-functions
32+
33+
modules_setup()
34+
{
35+
modprobe xenfs 2>/dev/null
36+
modprobe xen-evtchn 2>/dev/null
37+
modprobe xen_blkback 2>/dev/null
38+
modprobe xen_netback 2>/dev/null
39+
modprobe xen_gntdev 2>/dev/null
40+
}
41+
42+
xenfs_setup()
43+
{
44+
[ -e "/proc/xen/capabilities" ] && return 0
45+
log_progress_msg "xenfs"
46+
[ -d "/proc/xen" ] || return 1
47+
mount -t xenfs xenfs /proc/xen || return 1
48+
return 0
49+
}
50+
51+
capability_check()
52+
{
53+
[ -e "/proc/xen/capabilities" ] || return 1
54+
grep -q "control_d" /proc/xen/capabilities || return 1
55+
return 0
56+
}
57+
58+
xend_start()
59+
{
60+
log_progress_msg "xend"
61+
$XEND status && return 1
62+
$XEND start || return 2
63+
64+
i=0
65+
while [ $i -lt 10 ]; do
66+
$XEND status && return 0 || true
67+
i=$(($i + 1))
68+
sleep 1
69+
done
70+
return 2
71+
}
72+
73+
xend_stop()
74+
{
75+
log_progress_msg "xend"
76+
$XEND status || return 0
77+
$XEND stop || return 1
78+
}
79+
80+
xenconsoled_start()
81+
{
82+
log_progress_msg "xenconsoled"
83+
start-stop-daemon --start --quiet --pidfile "$XENCONSOLED_PIDFILE" --exec "$XENCONSOLED" --test > /dev/null \
84+
|| return 1
85+
start-stop-daemon --start --quiet --pidfile "$XENCONSOLED_PIDFILE" --exec "$XENCONSOLED" -- \
86+
$XENCONSOLED_ARGS --pid-file="$XENCONSOLED_PIDFILE" \
87+
|| return 2
88+
}
89+
90+
xenstored_start()
91+
{
92+
log_progress_msg "xenstored"
93+
start-stop-daemon --start --quiet --pidfile "$XENSTORED_PIDFILE" --exec "$XENSTORED" --test > /dev/null \
94+
|| return 1
95+
[ -d "$XENSTORED_DIR" ] || mkdir -p "$XENSTORED_DIR"
96+
export XENSTORED_ROOTDIR="$XENSTORED_DIR"
97+
start-stop-daemon --start --quiet --pidfile "$XENSTORED_PIDFILE" --exec "$XENSTORED" -- \
98+
$XENSTORED_ARGS --pid-file="$XENSTORED_PIDFILE" \
99+
|| return 2
100+
}
101+
102+
case "$1" in
103+
start)
104+
log_daemon_msg "Starting $DESC"
105+
modules_setup
106+
xenfs_setup
107+
case "$?" in
108+
0) ;;
109+
*) log_end_msg 1; exit ;;
110+
esac
111+
capability_check
112+
case "$?" in
113+
0) ;;
114+
*) log_end_msg 255; exit ;;
115+
esac
116+
xenstored_start
117+
case "$?" in
118+
0|1) ;;
119+
*) log_end_msg 1; exit ;;
120+
esac
121+
xenconsoled_start
122+
case "$?" in
123+
0|1) ;;
124+
*) log_end_msg 1; exit ;;
125+
esac
126+
#xend_start
127+
case "$?" in
128+
0|1) ;;
129+
*) log_end_msg 1; exit ;;
130+
esac
131+
log_end_msg 0
132+
;;
133+
stop)
134+
capability_check
135+
case "$?" in
136+
0) ;;
137+
*) exit ;;
138+
esac
139+
log_daemon_msg "Stopping $DESC"
140+
#xend_stop
141+
case "$?" in
142+
0|1) log_end_msg 0 ;;
143+
*) log_end_msg 1 ;;
144+
esac
145+
;;
146+
restart|force-reload)
147+
capability_check
148+
case "$?" in
149+
0) ;;
150+
*) exit ;;
151+
esac
152+
log_daemon_msg "Restarting $DESC"
153+
#xend_stop
154+
case "$?" in
155+
0|1)
156+
#xend_start
157+
case "$?" in
158+
0) log_end_msg 0 ;;
159+
*) log_end_msg 1 ;;
160+
esac
161+
;;
162+
*) log_end_msg 1 ;;
163+
esac
164+
;;
165+
*)
166+
echo "Usage: $0 {start|stop|restart|force-reload}" >&2
167+
exit 3
168+
;;
169+
esac
170+
171+
exit 0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include puppet-devcloudinitial

‎tools/devcloud/puppet/puppet-devcloudinitial/manifests/init.pp‎

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,59 @@
99
}
1010

1111
package { 'xcp-xapi':
12-
ensure => latest,
12+
require => Package['xen-hypervisor-4.1-amd64'],
13+
ensure => latest,
1314
}
1415

1516
file { '/etc/xcp/network.conf':
17+
require => Package['xcp-xapi'],
1618
ensure => 'file',
17-
source => 'puppet:///files/puppet-devcloudinitial/files/network.conf',
19+
source => 'puppet:///modules/puppet-devcloudinitial/network.conf',
1820
group => '0',
1921
mode => '644',
2022
owner => '0',
2123
}
2224

23-
exec { "/bin/sed -i -e 's/xend_start$/#xend_start/' -e 's/xend_stop$/#xend_stop/' /etc/init.d/xend":
24-
cwd => '/etc/init.d',
25+
file { '/etc/init.d/xend':
26+
require => Package['xcp-xapi'],
27+
ensure => 'file',
28+
source => 'puppet:///modules/puppet-devcloudinitial/xend',
29+
group => '0',
30+
owner => '0',
31+
mode => '755',
2532
}
2633

2734
service { 'xendomains':
28-
ensure => 'stopped',
29-
enable => 'false',
35+
require => Package['xcp-xapi'],
36+
ensure => 'stopped',
37+
enable => 'false',
3038
}
3139

3240
file { '/etc/default/grub':
41+
require => Package['xen-hypervisor-4.1-amd64'],
3342
ensure => 'file',
34-
source => 'puppet:///files/puppet-devcloudinitial/files/grub',
43+
source => 'puppet:///modules/puppet-devcloudinitial/grub',
3544
group => '0',
3645
mode => '644',
3746
owner => '0',
3847
}
3948

4049
exec { "/usr/sbin/update-grub":
41-
cwd => '/',
50+
subscribe => File['/etc/default/grub'],
51+
refreshonly => true,
52+
cwd => '/',
4253
}
4354

4455
file { '/usr/share/qemu':
56+
require => Package['xen-hypervisor-4.1-amd64'],
4557
ensure => 'directory',
4658
group => '0',
4759
mode => '755',
4860
owner => '0',
4961
}
5062

5163
file { '/usr/share/qemu/keymaps':
64+
require => File['/usr/share/qemu'],
5265
ensure => 'link',
5366
group => '0',
5467
mode => '777',
@@ -58,15 +71,16 @@
5871

5972
file { '/etc/network/interfaces':
6073
ensure => 'file',
61-
source => 'puppet:///files/puppet-devcloudinitial/files/interfaces',
74+
source => 'puppet:///modules/puppet-devcloudinitial/interfaces',
6275
group => '0',
6376
mode => '644',
6477
owner => '0',
6578
}
6679

6780
file { '/etc/default/xen':
81+
require => Package['xen-hypervisor-4.1-amd64'],
6882
ensure => 'file',
69-
source => 'puppet:///files/puppet-devcloudinitial/files/xen-defaults',
83+
source => 'puppet:///modules/puppet-devcloudinitial/xen-defaults',
7084
group => '0',
7185
mode => '644',
7286
owner => '0',

‎tools/devcloud/vagrant/Vagrantfile‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Vagrant::Config.run do |config|
2525

2626
# Uncomment this line to enable the console for debugging the
2727
# build process.
28-
config.vm.boot_mode = :gui
28+
#config.vm.boot_mode = :gui
2929

3030
# Setup port forwarding
3131
config.vm.forward_port 22, 2222
@@ -38,7 +38,13 @@ Vagrant::Config.run do |config|
3838
# Ensure the VM has the right virtual resources
3939
#config.vm.
4040

41-
#config.vm.provision :shell, :inline => "/vagrant/devcloudsetup.sh -p -v"
41+
config.vm.provision :puppet do |puppet|
42+
puppet.manifests_path = "puppet-devcloudinitial"
43+
puppet.manifest_file = "init.pp"
44+
puppet.with_ssh = true
45+
puppet.pp_path = "/etc/puppet"
46+
puppet.module_path = "puppet-devcloudinitial"
47+
end
4248

4349
# Enable provisioning with Puppet stand alone. Puppet manifests
4450
# are contained in a directory path relative to this Vagrantfile.

0 commit comments

Comments
 (0)