From dc901c3b9998835acb1f284f0c5e34458ad3c562 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Fri, 27 Mar 2015 11:26:17 +0000 Subject: horizon: Move setup scripts to Ansible. Now horizon-setup also configures Apache, given that they will be in the same host. This can be split in different setup scripts. --- openstack-keystone.configure | 3 ++ openstack/etc/systemd/system/apache-httpd.service | 3 +- .../systemd/system/openstack-horizon-setup.service | 6 +-- .../usr/share/openstack/apache-httpd-server-setup | 47 ---------------------- openstack/usr/share/openstack/horizon.yml | 25 ++++++++++++ .../usr/share/openstack/openstack-horizon-setup | 40 ------------------ systems/openstack-server.morph | 1 - 7 files changed, 31 insertions(+), 94 deletions(-) delete mode 100755 openstack/usr/share/openstack/apache-httpd-server-setup create mode 100644 openstack/usr/share/openstack/horizon.yml delete mode 100644 openstack/usr/share/openstack/openstack-horizon-setup diff --git a/openstack-keystone.configure b/openstack-keystone.configure index fb37b3ac..8fd3fabd 100644 --- a/openstack-keystone.configure +++ b/openstack-keystone.configure @@ -24,6 +24,9 @@ ROOT="$1" ln -s "/etc/systemd/system/openstack-keystone-setup.service" \ "$ROOT/etc/systemd/system/multi-user.target.wants/openstack-keystone-setup.service" +ln -s "/etc/systemd/system/openstack-horizon-setup.service" \ + "$ROOT/etc/systemd/system/multi-user.target.wants/openstack-horizon-setup.service" + ########################################################################## # Check variables ########################################################################## diff --git a/openstack/etc/systemd/system/apache-httpd.service b/openstack/etc/systemd/system/apache-httpd.service index 01627e02..f1211ac9 100644 --- a/openstack/etc/systemd/system/apache-httpd.service +++ b/openstack/etc/systemd/system/apache-httpd.service @@ -1,7 +1,6 @@ [Unit] Description=Apache Web Server -Requires=apache-httpd-server-setup.service openstack-horizon-setup.service -After=network.target remote-fs.target nss-lookup.target apache-httpd-server-setup.service openstack-horizon-setup.service +After=network.target remote-fs.target nss-lookup.target [Service] Type=forking diff --git a/openstack/etc/systemd/system/openstack-horizon-setup.service b/openstack/etc/systemd/system/openstack-horizon-setup.service index 082ec372..9805a38f 100644 --- a/openstack/etc/systemd/system/openstack-horizon-setup.service +++ b/openstack/etc/systemd/system/openstack-horizon-setup.service @@ -1,11 +1,9 @@ [Unit] -Description=Run openstack-horizon-setup (once) +Description=Run horizon-setup Ansible scripts After=local-fs.target [Service] -Type=oneshot -ExecStart=/usr/share/openstack/openstack-horizon-setup -Restart=no +ExecStart=/usr/bin/ansible-playbook -v -M /usr/share/ansible/ansible-openstack-modules -i /usr/share/openstack/hosts /usr/share/openstack/horizon.yml [Install] WantedBy=multi-user.target diff --git a/openstack/usr/share/openstack/apache-httpd-server-setup b/openstack/usr/share/openstack/apache-httpd-server-setup deleted file mode 100755 index 8f8cdd60..00000000 --- a/openstack/usr/share/openstack/apache-httpd-server-setup +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2015 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 - -if [ -f /var/openstack/apache-http-setup ]; then - exit 0 -fi - -############################################################################### -# Move suexec to the directory where apache is configured to have it # -# Check configure in strata/apache-httpd-server/httpd-server.morph # -############################################################################### -mkdir -p /var/www -groupadd -r apache -useradd -c "Apache Server" -d /var/www -g apache \ - -s /bin/false apache - -############################################################################### -# Move suexec to the directory where apache is configured to have it # -# Check configure in strata/apache-httpd-server/httpd-server.morph # -############################################################################### -mkdir -p /usr/lib/httpd -mv -v /usr/sbin/suexec /usr/lib/httpd/suexec -chgrp apache /usr/lib/httpd/suexec -chmod 4754 /usr/lib/httpd/suexec -chown -R apache:apache /var/www - -install -D -m 644 /proc/self/fd/0 <<'EOF' /var/openstack/apache-http-setup -Apache http setup: success -EOF - -exit 0 diff --git a/openstack/usr/share/openstack/horizon.yml b/openstack/usr/share/openstack/horizon.yml new file mode 100644 index 00000000..b6113b6b --- /dev/null +++ b/openstack/usr/share/openstack/horizon.yml @@ -0,0 +1,25 @@ +--- +- hosts: localhost + tasks: + +# Setup apache, this may end up in apache.yml + - name: Create the apache user. + user: name=apache comment="Apache Server" shell=/sbin/nologin home=/var/www + + - file: path=/usr/sbin/suexec group=apache mode=4750 + +# Setup horizon + - name: Create the horizon user. + user: name=horizon comment="Openstack Horizon User" shell=/sbin/nologin home=/var/lib/horizon + + - name: Create the /var folders for horizon + file: path={{ item }} state=directory owner=horizon group=horizon + with_items: + - /var/lib/horizon + + - file: src=/etc/horizon/apache-horizon.conf dest=/etc/httpd/conf.d/apache-horizon.conf state=link + + - name: Enable and start apache services needed by horizon + service: name={{ item }} enabled=yes state=started + with_items: + - apache-httpd.service diff --git a/openstack/usr/share/openstack/openstack-horizon-setup b/openstack/usr/share/openstack/openstack-horizon-setup deleted file mode 100644 index af944477..00000000 --- a/openstack/usr/share/openstack/openstack-horizon-setup +++ /dev/null @@ -1,40 +0,0 @@ -#!/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 - -if [ -f /var/openstack/horizon-setup ]; then - exit 0 -fi - -# Create required system users and groups -getent group horizon >/dev/null || groupadd -r --gid 167 horizon -getent passwd neutron >/dev/null || \ - useradd --uid 167 -r -g horizon -d /var/lib/horizon -s /sbin/nologin \ - -c "Horizon user" horizon - -chown -R horizon:horizon /var/lib/horizon - -# Link horizon configuration file for apache to the directory where our apache load -# configurations files -ln -sf /etc/horizon/apache-horizon.conf /etc/httpd/conf.d/apache-horizon.conf - -install -D -m 644 /proc/self/fd/0 <<'EOF' /var/openstack/horizon-setup -Horizon setup: success -EOF - -exit 0 diff --git a/systems/openstack-server.morph b/systems/openstack-server.morph index 61c0e8fc..c1d345e7 100644 --- a/systems/openstack-server.morph +++ b/systems/openstack-server.morph @@ -69,4 +69,3 @@ configuration-extensions: - openstack-cinder - openstack-neutron - openvswitch -- apache-httpd-server -- cgit v1.2.1