Browse code

Preinstall yum-utils; move sudo check before install

Some cloud images don't have yum-utils installed, so the call to
yum-config-manager fails. Pre-install it (I still think it's easier
than fiddling config files).

Also, these repo setup steps are using sudo, but the root/sudo checks
happen after this. Move them up before we start trying to do
repo/package installs.

Change-Id: I875e1f0663c9badc00278b2cc1a3b04ca3dde9fc

Ian Wienand authored on 2014/02/28 09:24:29
Showing 1 changed files
... ...
@@ -161,9 +161,42 @@ fi
161 161
 # Set up logging level
162 162
 VERBOSE=$(trueorfalse True $VERBOSE)
163 163
 
164
+# root Access
165
+# -----------
166
+
167
+# OpenStack is designed to be run as a non-root user; Horizon will fail to run
168
+# as **root** since Apache will not serve content from **root** user).
169
+# ``stack.sh`` must not be run as **root**.  It aborts and suggests one course of
170
+# action to create a suitable user account.
171
+
172
+if [[ $EUID -eq 0 ]]; then
173
+    echo "You are running this script as root."
174
+    echo "Cut it out."
175
+    echo "Really."
176
+    echo "If you need an account to run DevStack, do this (as root, heh) to create $STACK_USER:"
177
+    echo "$TOP_DIR/tools/create-stack-user.sh"
178
+    exit 1
179
+fi
180
+
181
+# We're not **root**, make sure ``sudo`` is available
182
+is_package_installed sudo || install_package sudo
183
+
184
+# UEC images ``/etc/sudoers`` does not have a ``#includedir``, add one
185
+sudo grep -q "^#includedir.*/etc/sudoers.d" /etc/sudoers ||
186
+    echo "#includedir /etc/sudoers.d" | sudo tee -a /etc/sudoers
187
+
188
+# Set up devstack sudoers
189
+TEMPFILE=`mktemp`
190
+echo "$STACK_USER ALL=(root) NOPASSWD:ALL" >$TEMPFILE
191
+# Some binaries might be under /sbin or /usr/sbin, so make sure sudo will
192
+# see them by forcing PATH
193
+echo "Defaults:$STACK_USER secure_path=/sbin:/usr/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin" >> $TEMPFILE
194
+chmod 0440 $TEMPFILE
195
+sudo chown root:root $TEMPFILE
196
+sudo mv $TEMPFILE /etc/sudoers.d/50_stack_sh
164 197
 
165 198
 # Additional repos
166
-# ================
199
+# ----------------
167 200
 
168 201
 # Some distros need to add repos beyond the defaults provided by the vendor
169 202
 # to pick up required packages.
... ...
@@ -196,45 +229,13 @@ if [[ is_fedora && $DISTRO =~ (rhel6) ]]; then
196 196
     fi
197 197
 
198 198
     # ... and also optional to be enabled
199
+    is_package_installed yum-utils || install_package yum-utils
199 200
     sudo yum-config-manager --enable rhel-6-server-optional-rpms
200 201
 
201 202
 fi
202 203
 
203
-
204
-# root Access
205
-# -----------
206
-
207
-# OpenStack is designed to be run as a non-root user; Horizon will fail to run
208
-# as **root** since Apache will not serve content from **root** user).
209
-# ``stack.sh`` must not be run as **root**.  It aborts and suggests one course of
210
-# action to create a suitable user account.
211
-
212
-if [[ $EUID -eq 0 ]]; then
213
-    echo "You are running this script as root."
214
-    echo "Cut it out."
215
-    echo "Really."
216
-    echo "If you need an account to run DevStack, do this (as root, heh) to create $STACK_USER:"
217
-    echo "$TOP_DIR/tools/create-stack-user.sh"
218
-    exit 1
219
-fi
220
-
221
-# We're not **root**, make sure ``sudo`` is available
222
-is_package_installed sudo || install_package sudo
223
-
224
-# UEC images ``/etc/sudoers`` does not have a ``#includedir``, add one
225
-sudo grep -q "^#includedir.*/etc/sudoers.d" /etc/sudoers ||
226
-    echo "#includedir /etc/sudoers.d" | sudo tee -a /etc/sudoers
227
-
228
-# Set up devstack sudoers
229
-TEMPFILE=`mktemp`
230
-echo "$STACK_USER ALL=(root) NOPASSWD:ALL" >$TEMPFILE
231
-# Some binaries might be under /sbin or /usr/sbin, so make sure sudo will
232
-# see them by forcing PATH
233
-echo "Defaults:$STACK_USER secure_path=/sbin:/usr/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin" >> $TEMPFILE
234
-chmod 0440 $TEMPFILE
235
-sudo chown root:root $TEMPFILE
236
-sudo mv $TEMPFILE /etc/sudoers.d/50_stack_sh
237
-
204
+# Filesystem setup
205
+# ----------------
238 206
 
239 207
 # Create the destination directory and ensure it is writable by the user
240 208
 # and read/executable by everybody for daemons (e.g. apache run for horizon)
... ...
@@ -252,6 +253,15 @@ if [ -z "`grep ^127.0.0.1 /etc/hosts | grep $LOCAL_HOSTNAME`" ]; then
252 252
     sudo sed -i "s/\(^127.0.0.1.*\)/\1 $LOCAL_HOSTNAME/" /etc/hosts
253 253
 fi
254 254
 
255
+# Destination path for service data
256
+DATA_DIR=${DATA_DIR:-${DEST}/data}
257
+sudo mkdir -p $DATA_DIR
258
+safe_chown -R $STACK_USER $DATA_DIR
259
+
260
+
261
+# Common Configuration
262
+# --------------------
263
+
255 264
 # Set ``OFFLINE`` to ``True`` to configure ``stack.sh`` to run cleanly without
256 265
 # Internet access. ``stack.sh`` must have been previously run with Internet
257 266
 # access to install prerequisites and fetch repositories.
... ...
@@ -265,15 +275,6 @@ ERROR_ON_CLONE=`trueorfalse False $ERROR_ON_CLONE`
265 265
 # Whether to enable the debug log level in OpenStack services
266 266
 ENABLE_DEBUG_LOG_LEVEL=`trueorfalse True $ENABLE_DEBUG_LOG_LEVEL`
267 267
 
268
-# Destination path for service data
269
-DATA_DIR=${DATA_DIR:-${DEST}/data}
270
-sudo mkdir -p $DATA_DIR
271
-safe_chown -R $STACK_USER $DATA_DIR
272
-
273
-
274
-# Common Configuration
275
-# ====================
276
-
277 268
 # Set fixed and floating range here so we can make sure not to use addresses
278 269
 # from either range when attempting to guess the IP to use for the host.
279 270
 # Note that setting FIXED_RANGE may be necessary when running DevStack