Run $TOP_DIR/local.sh at the end of stack.sh if it exists and is executable.
This allows the user to automatically perform local actions on every re-stack,
such as creating custom flavors or specific tenants/users. Like localrc, this
file is not distributed with DevStack so user modifications will be undisturbed.
Add local.sh to .gitignore
Examples of local.sh and localrc are in the samples/ directory.
Change-Id: I0be6b4d80ce084981cac8a3a8f1dc9bc8c3bbd4e
6 | 7 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,59 @@ |
0 |
+#!/usr/bin/env bash |
|
1 |
+ |
|
2 |
+# Sample ``local.sh`` for user-configurable tasks to run automatically |
|
3 |
+# at the sucessful conclusion of ``stack.sh``. |
|
4 |
+ |
|
5 |
+# NOTE: Copy this file to the root ``devstack`` directory for it to |
|
6 |
+# work properly. |
|
7 |
+ |
|
8 |
+# This is a collection of some of the things we have found to be useful to run |
|
9 |
+# after stack.sh to tweak the OpenStack configuration that DevStack produces. |
|
10 |
+# These should be considered as samples and are unsupported DevStack code. |
|
11 |
+ |
|
12 |
+# Keep track of the devstack directory |
|
13 |
+TOP_DIR=$(cd $(dirname "$0") && pwd) |
|
14 |
+ |
|
15 |
+# Use openrc + stackrc + localrc for settings |
|
16 |
+source $TOP_DIR/stackrc |
|
17 |
+ |
|
18 |
+# Destination path for installation ``DEST`` |
|
19 |
+DEST=${DEST:-/opt/stack} |
|
20 |
+ |
|
21 |
+ |
|
22 |
+# Import ssh keys |
|
23 |
+# --------------- |
|
24 |
+ |
|
25 |
+# Import keys from the current user into the default OpenStack user (usually |
|
26 |
+# ``demo``) |
|
27 |
+ |
|
28 |
+# Get OpenStack auth |
|
29 |
+source $TOP_DIR/openrc |
|
30 |
+ |
|
31 |
+# Add first keypair found in localhost:$HOME/.ssh |
|
32 |
+for i in $HOME/.ssh/id_rsa.pub $HOME/.ssh/id_dsa.pub; do |
|
33 |
+ if [[ -f $i ]]; then |
|
34 |
+ nova keypair-add --pub_key=$i `hostname` |
|
35 |
+ break |
|
36 |
+ fi |
|
37 |
+done |
|
38 |
+ |
|
39 |
+ |
|
40 |
+# Create A Flavor |
|
41 |
+# --------------- |
|
42 |
+ |
|
43 |
+# Get OpenStack admin auth |
|
44 |
+source $TOP_DIR/openrc admin admin |
|
45 |
+ |
|
46 |
+# Name of new flavor |
|
47 |
+# set in ``localrc`` with ``DEFAULT_INSTANCE_TYPE=m1.micro`` |
|
48 |
+MI_NAME=m1.micro |
|
49 |
+ |
|
50 |
+# Create micro flavor if not present |
|
51 |
+if [[ -z $(nova flavor-list | grep $MI_NAME) ]]; then |
|
52 |
+ nova flavor-create $MI_NAME 6 128 0 1 |
|
53 |
+fi |
|
54 |
+# Other Uses |
|
55 |
+# ---------- |
|
56 |
+ |
|
57 |
+# Add tcp/22 to default security group |
|
58 |
+ |
0 | 59 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,77 @@ |
0 |
+# Sample ``localrc`` for user-configurable variables in ``stack.sh`` |
|
1 |
+ |
|
2 |
+# NOTE: Copy this file to the root ``devstack`` directory for it to work properly. |
|
3 |
+ |
|
4 |
+# ``localrc`` is a user-maintained setings file that is sourced at the end of |
|
5 |
+# ``stackrc``. This gives it the ability to override any variables set in ``stackrc``. |
|
6 |
+# Also, most of the settings in ``stack.sh`` are written to only be set if no |
|
7 |
+# value has already been set; this lets ``localrc`` effectively override the |
|
8 |
+# default values. |
|
9 |
+ |
|
10 |
+# This is a collection of some of the settings we have found to be useful |
|
11 |
+# in our DevStack development environments. Additional settings are described |
|
12 |
+# in http://devstack.org/localrc.html |
|
13 |
+# These should be considered as samples and are unsupported DevStack code. |
|
14 |
+ |
|
15 |
+ |
|
16 |
+# Minimal Contents |
|
17 |
+# ---------------- |
|
18 |
+ |
|
19 |
+# While ``stack.sh`` is happy to run without ``localrc``, devlife is better when |
|
20 |
+# there are a few minimal variables set: |
|
21 |
+ |
|
22 |
+# If the ``*_PASSWORD`` variables are not set here you will be prompted to enter |
|
23 |
+# values for them by ``stack.sh``. |
|
24 |
+ADMIN_PASSWORD=nomoresecrete |
|
25 |
+MYSQL_PASSWORD=stackdb |
|
26 |
+RABBIT_PASSWORD=stackqueue |
|
27 |
+SERVICE_PASSWORD=$ADMIN_PASSWORD |
|
28 |
+ |
|
29 |
+# HOST_IP should be set manually for best results. It is auto-detected during the |
|
30 |
+# first run of ``stack.sh`` but often is indeterminate on later runs due to the IP |
|
31 |
+# being moved from an Ethernet interface to a bridge on the host. Setting it here |
|
32 |
+# also makes it available for ``openrc`` to include when setting ``OS_AUTH_URL``. |
|
33 |
+# ``HOST_IP`` is not set by default. |
|
34 |
+HOST_IP=w.x.y.z |
|
35 |
+ |
|
36 |
+ |
|
37 |
+# Set DevStack Install Directory |
|
38 |
+# ------------------------------ |
|
39 |
+ |
|
40 |
+# The DevStack install directory is set by the ``DEST`` variable. By setting it |
|
41 |
+# early in ``localrc`` you can reference it in later variables. The default value |
|
42 |
+# is ``/opt/stack``. It can be useful to set it even though it is not changed from |
|
43 |
+# the default value. |
|
44 |
+DEST=/opt/stack |
|
45 |
+ |
|
46 |
+ |
|
47 |
+# Using milestone-proposed branches |
|
48 |
+# --------------------------------- |
|
49 |
+ |
|
50 |
+# Uncomment these to grab the milestone-proposed branches from the repos: |
|
51 |
+#GLANCE_BRANCH=milestone-proposed |
|
52 |
+#HORIZON_BRANCH=milestone-proposed |
|
53 |
+#KEYSTONE_BRANCH=milestone-proposed |
|
54 |
+#KEYSTONECLIENT_BRANCH=milestone-proposed |
|
55 |
+#NOVA_BRANCH=milestone-proposed |
|
56 |
+#NOVACLIENT_BRANCH=milestone-proposed |
|
57 |
+#SWIFT_BRANCH=milestone-proposed |
|
58 |
+ |
|
59 |
+ |
|
60 |
+# Swift |
|
61 |
+# ----- |
|
62 |
+ |
|
63 |
+# Swift is now used as the back-end for the S3-like object store. If Nova's |
|
64 |
+# objectstore (``n-obj`` in ``ENABLED_SERVICES``) is enabled, it will NOT |
|
65 |
+# run if Swift is enabled. Setting the hash value is required and you will |
|
66 |
+# be prompted for it if Swift is enabled so just set it to something already: |
|
67 |
+SWIFT_HASH=66a3d6b56c1f479c8b4e70ab5c2000f5 |
|
68 |
+ |
|
69 |
+# For development purposes the default of 3 replicas is usually not required. |
|
70 |
+# Set this to 1 to save some resources: |
|
71 |
+SWIFT_REPLICAS=1 |
|
72 |
+ |
|
73 |
+# The data for Swift is stored in the source tree by default (``$DEST/swift/data``) |
|
74 |
+# and can be moved by setting ``SWIFT_DATA_DIR``. The directory will be created |
|
75 |
+# if it does not exist. |
|
76 |
+SWIFT_DATA_DIR=$DEST/data |
... | ... |
@@ -1706,6 +1706,16 @@ if is_service_enabled g-reg; then |
1706 | 1706 |
fi |
1707 | 1707 |
|
1708 | 1708 |
|
1709 |
+# Run local script |
|
1710 |
+# ================ |
|
1711 |
+ |
|
1712 |
+# Run ``local.sh`` if it exists to perform user-managed tasks |
|
1713 |
+if [[ -x $TOP_DIR/local.sh ]]; then |
|
1714 |
+ echo "Running user script $TOP_DIR/local.sh" |
|
1715 |
+ $TOP_DIR/local.sh |
|
1716 |
+fi |
|
1717 |
+ |
|
1718 |
+ |
|
1709 | 1719 |
# Fin |
1710 | 1720 |
# === |
1711 | 1721 |
|