summaryrefslogtreecommitdiff
path: root/openstack/usr/share/openstack/openstack-ironic-setup
diff options
context:
space:
mode:
Diffstat (limited to 'openstack/usr/share/openstack/openstack-ironic-setup')
-rw-r--r--openstack/usr/share/openstack/openstack-ironic-setup81
1 files changed, 81 insertions, 0 deletions
diff --git a/openstack/usr/share/openstack/openstack-ironic-setup b/openstack/usr/share/openstack/openstack-ironic-setup
new file mode 100644
index 00000000..b19edb04
--- /dev/null
+++ b/openstack/usr/share/openstack/openstack-ironic-setup
@@ -0,0 +1,81 @@
+#!/bin/sh
+#
+# Copyright (C) 2014 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+set -e
+
+# Create required system users and groups
+getent group ironic >/dev/null || groupadd -r --gid 168 ironic
+getent passwd ironic >/dev/null || \
+ useradd --uid 168 -r -g ironic -d /var/lib/ironic -s /sbin/nologin \
+ -c "OpenStack Ironic Daemons" ironic
+
+# Create the keystone user and services
+export OS_SERVICE_TOKEN=##KEYSTONE_TEMPORARY_ADMIN_TOKEN##
+export OS_SERVICE_ENDPOINT='http://onenode:35357/v2.0'
+
+keystone user-create --name ##IRONIC_SERVICE_USER## --pass ##IRONIC_SERVICE_PASSWORD##
+keystone user-role-add --user ##IRONIC_SERVICE_USER## --tenant service --role admin
+
+keystone service-create --name ironic --type baremetal \
+ --description "OpenStack Ironic bare metal provisioning service"
+keystone endpoint-create --service-id $(keystone service-list | awk '/ baremetal / {print $2}') \
+ --publicurl ##IRONIC_PUBLIC_URL## \
+ --internalurl ##IRONIC_INTERNAL_URL## \
+ --adminurl ##IRONIC_ADMIN_URL## \
+ --region=RegionOne # https://bugs.launchpad.net/keystone/+bug/1400589
+
+# Create run directory for ironic
+if [ ! -d /var/run/ironic ]; then
+ mkdir -p /var/run/ironic
+ chown -R ironic:ironic /var/run/ironic
+fi
+
+# Create the lock directory for ironic
+if [ ! -d /var/lock/ironic ]; then
+ mkdir -p /var/lock/ironic
+ chown -R ironic:ironic /var/lock/ironic
+fi
+
+# Create the log directory for ironic
+if [ ! -d /var/log/ironic ]; then
+ mkdir -p /var/log/ironic
+ chown -R ironic:ironic /var/log/ironic
+fi
+
+# Setup the ironic database
+if ! sudo -u postgres psql -lqt | grep -q ironic; then
+ # Create posgreSQL user
+ sudo -u postgres createuser \
+ --pwprompt --encrypted \
+ --no-adduser --no-createdb \
+ --no-password \
+ ##IRONIC_DB_USER##
+
+ sudo -u postgres createdb \
+ --owner=##IRONIC_DB_USER## \
+ ironic
+
+ sudo -u ironic ironic-dbsync --config-file /etc/ironic/ironic.conf create_schema
+fi
+
+chown -R ironic:ironic /var/lib/ironic
+chown -R ironic:ironic /srv/nfsboot/tftp/
+
+# Remove the one-shot setup service
+rm /etc/systemd/system/multi-user.target.wants/openstack-ironic-setup.service
+
+exit 0