From 067904bb900e3c8fcead1cb98b91147d36ad853a Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Tue, 17 Mar 2015 16:42:04 +0000 Subject: neutron: start ansible --- openstack/usr/share/openstack/neutron.yml | 78 ++++++++++++++++++ .../usr/share/openstack/openstack-neutron-setup | 95 ---------------------- openstack/usr/share/openstack/openvswitch.yml | 5 +- 3 files changed, 82 insertions(+), 96 deletions(-) create mode 100644 openstack/usr/share/openstack/neutron.yml delete mode 100644 openstack/usr/share/openstack/openstack-neutron-setup diff --git a/openstack/usr/share/openstack/neutron.yml b/openstack/usr/share/openstack/neutron.yml new file mode 100644 index 00000000..c0ccd532 --- /dev/null +++ b/openstack/usr/share/openstack/neutron.yml @@ -0,0 +1,78 @@ +--- +- hosts: localhost + vars_files: + - "/etc/openstack/neutron.conf" + tasks: + + - name: Create the neutron user. + user: name=neutron comment="Openstack Neutron Daemons" shell=/sbin/nologin home=/var/lib/neutron + + - name: Create the /var folders for neutron + file: path={{ item }} state=directory owner=neutron group=neutron + with_items: + - /var/run/neutron + - /var/lock/neutron + - /var/log/neutron + + - name: Get service tenant id needed in neutron.conf + shell: | + keystone \ + --os-endpoint http://{{ CONTROLLER_HOST_ADDRESS }}:35357/v2.0 \ + --os-token {{ KEYSTONE_TEMPORARY_ADMIN_TOKEN }} \ + tenant-get service | grep id | tr -d " " | cut -d"|" -f3 + register: tenant_service_id + + - set_fact: SERVICE_TENANT_ID={{ tenant_service_id.stdout }} + + - name: Create the directories needed for Neutron configuration files. + file: path=/etc/{{ item }} state=directory + with_lines: + - (cd /usr/share/openstack && find neutron -type d) + + - name: Add configuration needed for neutron using templates + template: src=/usr/share/openstack/{{ item }} dest=/etc/{{ item }} + with_lines: + - (cd /usr/share/openstack && find neutron -type f) + + - keystone_user: > + user={{ NEUTRON_SERVICE_USER }} + password={{ NEUTRON_SERVICE_PASSWORD }} + tenant=service + token={{ KEYSTONE_TEMPORARY_ADMIN_TOKEN }} + + - keystone_user: > + role=admin + user={{ NEUTRON_SERVICE_USER }} + tenant=service + token={{ KEYSTONE_TEMPORARY_ADMIN_TOKEN }} + + - keystone_service: > + name=neutron + type=network + description="Openstack Compute Networking" + publicurl=http://{{ CONTROLLER_HOST_ADDRESS }}:9696 + internalurl=http://{{ CONTROLLER_HOST_ADDRESS }}:9696 + adminurl=http://{{ CONTROLLER_HOST_ADDRESS }}:9696 + region='regionOne' + token={{ KEYSTONE_TEMPORARY_ADMIN_TOKEN }} + + - postgresql_user: name={{ NEUTRON_DB_USER }} password={{ NEUTRON_DB_PASSWORD }} + sudo: yes + sudo_user: neutron + - postgresql_db: name=neutron owner={{ NEUTRON_DB_USER }} + sudo: yes + sudo_user: neutron + + - shell: | + neutron neutron-db-manage \ + --config-file /etc/neutron/neutron.conf \ + --config-file /etc/neutron/plugins/ml2/ml2_conf.ini \ + upgrade juno + sudo: yes + sudo_user: neutron + + +## SERVICES + - name: Enable and start openstack-keystone service + service: name=openstack-keystone.service enabled=yes state=started + diff --git a/openstack/usr/share/openstack/openstack-neutron-setup b/openstack/usr/share/openstack/openstack-neutron-setup deleted file mode 100644 index ff6496a0..00000000 --- a/openstack/usr/share/openstack/openstack-neutron-setup +++ /dev/null @@ -1,95 +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 -xe - -if [ -f /var/openstack/openstack-neutron-setup ]; then - exit 0 -fi - -# Create required system users and groups - -getent group neutron >/dev/null || groupadd -r --gid 166 neutron -getent passwd neutron >/dev/null || \ - useradd --uid 166 -r -g neutron -d /var/lib/neutron -s /sbin/nologin \ - -c "OpenStack Neutron Daemons" neutron - -chown -R neutron:neutron /var/lib/neutron - -# 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 ##NEUTRON_SERVICE_USER## --pass ##NEUTRON_SERVICE_PASSWORD## -keystone user-role-add --tenant service --user ##NEUTRON_SERVICE_USER## --role admin - -keystone service-create --name neutron --type network --description "OpenStack Networking" -keystone endpoint-create --service-id $(keystone service-list | awk '/ network / {print $2}') \ - --publicurl ##NEUTRON_PUBLIC_URL## \ - --internalurl ##NEUTRON_INTERNAL_URL## \ - --adminurl ##NEUTRON_ADMIN_URL## \ - --region regionOne - -# neutron.conf configuration -service_tenant_id=$(keystone tenant-get service | grep id | tr -d " " | cut -d"|" -f3) -sed -i "s/##SERVICE_TENANT_ID##/$service_tenant_id/g" /etc/neutron/neutron.conf - -# Neutron compute configuration -if [ ! -d /var/run/neutron ]; then - mkdir -p /var/run/neutron - chown -R neutron:neutron /var/run/neutron -fi - -if [ ! -d /var/lock/neutron ]; then - mkdir -p /var/lock/neutron - chown -R neutron:neutron /var/lock/neutron -fi - -if [ ! -d /var/log/neutron ]; then - mkdir -p /var/log/neutron - chown -R neutron:neutron /var/log/neutron -fi - -# Setup the neutron database -if ! sudo -u postgres psql -lqt | grep -q neutron; then - # Create postgresSQL user - sudo -u postgres createuser \ - --pwprompt --encrypted \ - --no-adduser --no-createdb \ - --no-password \ - ##NEUTRON_DB_USER## - sudo -u postgres createdb \ - --owner=##NEUTRON_DB_USER## \ - neutron - # Stamp neutron database with the latest stamped version available, - # in this case "icehouse" - sudo -u neutron neutron-db-manage \ - --config-file /etc/neutron/neutron.conf \ - --config-file /etc/neutron/plugins/ml2/ml2_conf.ini \ - stamp icehouse - # Upgrade database to "juno" - sudo -u neutron neutron-db-manage \ - --config-file /etc/neutron/neutron.conf \ - --config-file /etc/neutron/plugins/ml2/ml2_conf.ini \ - upgrade juno -fi - -install -D -m 644 /proc/self/fd/0 <<'EOF' /var/openstack/openstack-neutron-setup -Openstack neutron setup: success -EOF - -exit 0 diff --git a/openstack/usr/share/openstack/openvswitch.yml b/openstack/usr/share/openstack/openvswitch.yml index 80c7f9f8..4407005c 100644 --- a/openstack/usr/share/openstack/openvswitch.yml +++ b/openstack/usr/share/openstack/openvswitch.yml @@ -34,4 +34,7 @@ when: openvswitch-db-enable.changed - name: Enable and start openstack-keystone service - service: name=openvswitch.service enabled=yes state=started + service: name={{ item }} enabled=yes state=started + with_items: + - openvswitch.service + - openstack-neutron-setup.service -- cgit v1.2.1