Browse code

add a new user stack with sudoers privileges (start of using sudo again)

Jesse Andrews authored on 2011/09/13 13:46:12
Showing 4 changed files
... ...
@@ -1,8 +1,6 @@
1 1
 dnsmasq-base
2 2
 kpartx
3 3
 mysql-server
4
-mysql-common # install mysql-common/client explicitly since mysql-server isn't bootstrapped
5
-mysql-client-5.1
6 4
 python-mysqldb
7 5
 kvm
8 6
 gawk
... ...
@@ -15,11 +13,6 @@ libvirt-bin
15 15
 vlan
16 16
 curl
17 17
 rabbitmq-server
18
-erlang-base # install erlang deps for rabbit explicitly since we don't install rabbit during bootstrap
19
-erlang-ssl 
20
-erlang-nox
21
-erlang-inets
22
-erlang-mnesia
23 18
 socat # used by ajaxterm
24 19
 python-mox
25 20
 python-paste
26 21
new file mode 100644
... ...
@@ -0,0 +1,12 @@
0
+# a collection of packages that speed up installation as they are dependencies
1
+# of packages we can't install during bootstraping (rabbitmq-server, 
2
+# mysql-server, libvirt-bin)
3
+#
4
+# NOTE: only add packages to this file that aren't needed directly
5
+mysql-common
6
+mysql-client-5.1
7
+erlang-base
8
+erlang-ssl 
9
+erlang-nox
10
+erlang-inets
11
+erlang-mnesia
... ...
@@ -51,5 +51,11 @@ if [ -f /root/.ssh/id_rsa.pub ]; then
51 51
 fi
52 52
 
53 53
 # set root password to password
54
-echo root:password | chroot $DEST chpasswd
54
+echo root:pass | chroot $DEST chpasswd
55 55
 
56
+# create a stack user
57
+chroot $DEST useradd stack -s /bin/bash -d /opt
58
+echo stack:pass | chroot $DEST chpasswd
59
+chroot $DEST chown -R stack /opt
60
+
61
+echo "stack ALL=(ALL) NOPASSWD: ALL" >> $DEST/etc/sudoers
... ...
@@ -44,17 +44,17 @@ SQL_CONN=${SQL_CONN:-mysql://root:$MYSQL_PASS@localhost/nova}
44 44
 # TODO: set rabbitmq conn string explicitly as well
45 45
 
46 46
 # seed configuration with mysql password
47
-cat <<MYSQL_PRESEED | debconf-set-selections
47
+cat <<MYSQL_PRESEED | sudo debconf-set-selections
48 48
 mysql-server-5.1 mysql-server/root_password password $MYSQL_PASS
49 49
 mysql-server-5.1 mysql-server/root_password_again password $MYSQL_PASS
50 50
 mysql-server-5.1 mysql-server/start_on_boot boolean true
51 51
 MYSQL_PRESEED
52 52
 
53 53
 # install apt requirements
54
-apt-get install -y -q `cat $DIR/apts/* | cut -d\# -f1`
54
+sudo apt-get install -y -q `cat $DIR/apts/* | cut -d\# -f1`
55 55
 
56 56
 # install python requirements
57
-pip install `cat $DIR/pips/*`
57
+sudo pip install `cat $DIR/pips/*`
58 58
 
59 59
 # git clone only if directory doesn't exist already
60 60
 function git_clone {
... ...
@@ -81,19 +81,19 @@ git_clone https://github.com/cloudbuilders/openstackx.git $API_DIR
81 81
 
82 82
 # setup our checkouts so they are installed into python path
83 83
 # allowing `import nova` or `import glance.client`
84
-cd $NOVACLIENT_DIR; python setup.py develop
85
-cd $KEYSTONE_DIR; python setup.py develop
86
-cd $GLANCE_DIR; python setup.py develop
87
-cd $API_DIR; python setup.py develop
88
-cd $DASH_DIR/django-openstack; python setup.py develop
89
-cd $DASH_DIR/openstack-dashboard; python setup.py develop
84
+cd $NOVACLIENT_DIR; sudo python setup.py develop
85
+cd $KEYSTONE_DIR; sudo python setup.py develop
86
+cd $GLANCE_DIR; sudo python setup.py develop
87
+cd $API_DIR; sudo python setup.py develop
88
+cd $DASH_DIR/django-openstack; sudo python setup.py develop
89
+cd $DASH_DIR/openstack-dashboard; sudo python setup.py develop
90 90
 
91 91
 # attempt to load modules: kvm (hardware virt) and nbd (network block 
92 92
 # device - used to manage qcow images)
93
-modprobe nbd || true
94
-modprobe kvm || true
93
+sudo modprobe nbd || true
94
+sudo modprobe kvm || true
95 95
 # if kvm wasn't running before we need to restart libvirt to enable it
96
-/etc/init.d/libvirt-bin restart
96
+sudo /etc/init.d/libvirt-bin restart
97 97
 
98 98
 # FIXME(ja): should LIBVIRT_TYPE be kvm if kvm module is loaded?
99 99
 
... ...
@@ -104,7 +104,7 @@ mkdir -p $NOVA_DIR/instances
104 104
 # can be labeled via e2label)
105 105
 # FIXME: if already mounted this blows up...
106 106
 if [ -L /dev/disk/by-label/nova-instances ]; then
107
-    mount -L nova-instances $NOVA_DIR/instances
107
+    sudo mount -L nova-instances $NOVA_DIR/instances
108 108
 fi
109 109
 
110 110
 # *Dashboard*: setup django application to serve via apache/wsgi
... ...
@@ -120,13 +120,18 @@ cd $DASH_DIR/openstack-dashboard
120 120
 cp local/local_settings.py.example local/local_settings.py
121 121
 dashboard/manage.py syncdb
122 122
 
123
-# ## Setup Apache
123
+# ---- Setup Apache ----
124 124
 # create an empty directory to use as our 
125 125
 mkdir $DASH_DIR/.blackhole
126 126
 
127 127
 # FIXME(ja): can't figure out how to make $DASH_DIR work in sed, also install to available/a2e it 
128
-cat $DIR/files/000-default.template | sed 's/%DASH_DIR%/\/opt\/dash/g' > /etc/apache2/sites-enabled/000-default
129
-chown -R www-data:www-data $DASH_DIR
128
+cat $DIR/files/000-default.template | sed 's/%DASH_DIR%/\/opt\/dash/g' > /tmp/000-default
129
+sudo mv /tmp/000-default /etc/apache2/sites-enabled
130
+
131
+# `python setup.py develop` left some files owned by root in $DASH_DIR and
132
+# others by the original owner.  We need to change the owner to apache so
133
+# dashboard can run
134
+sudo chown -R www-data:www-data $DASH_DIR
130 135
 
131 136
 mkdir -p /var/log/glance
132 137
 
... ...
@@ -175,8 +180,8 @@ rm -rf $NOVA_DIR/networks
175 175
 mkdir -p $NOVA_DIR/networks
176 176
 
177 177
 # (re)create nova database
178
-mysql -p$MYSQL_PASS -e 'DROP DATABASE nova;' || true
179
-mysql -p$MYSQL_PASS -e 'CREATE DATABASE nova;'
178
+mysql -uroot -p$MYSQL_PASS -e 'DROP DATABASE nova;' || true
179
+mysql -uroot -p$MYSQL_PASS -e 'CREATE DATABASE nova;'
180 180
 $NOVA_DIR/bin/nova-manage db sync
181 181
 
182 182
 # initialize keystone with default users/endpoints