Merge "Added snap configuration."

This commit is contained in:
Zuul 2019-07-25 18:21:32 +00:00 committed by Gerrit Code Review
commit de77b4a426
26 changed files with 148 additions and 85 deletions

View File

@ -2,6 +2,8 @@
set -e
source $SNAP_COMMON/etc/microstack.rc
if [ -z "$1" ]; then
echo "Please specify a name for the server."
exit 1
@ -64,4 +66,4 @@ while :; do
fi
done
echo "You can also visit the openstack dashboard at 'http://10.20.20.1/'"
echo "You can also visit the openstack dashboard at 'http://$extgateway/'"

View File

@ -9,13 +9,15 @@
set -ex
extcidr=$(snapctl get extcidr)
# Create external integration bridge
ovs-vsctl --retry --may-exist add-br br-ex
# Configure br-ex
ip address add 10.20.20.1/24 dev br-ex || :
ip address add $extcidr dev br-ex || :
ip link set br-ex up || :
sudo iptables -t nat -A POSTROUTING -s 10.20.20.1/24 ! -d 10.20.20.1/24 -j MASQUERADE
sudo iptables -t nat -A POSTROUTING -s $extcidr ! -d $extcidr -j MASQUERADE
exit 0

View File

@ -1,2 +0,0 @@
[database]
connection = mysql+pymysql://glance:glance@10.20.20.1/glance

View File

@ -1,2 +0,0 @@
[database]
connection = mysql+pymysql://keystone:keystone@10.20.20.1/keystone

View File

@ -1,2 +0,0 @@
[database]
connection = mysql+pymysql://neutron:neutron@10.20.20.1/neutron

View File

@ -1,5 +0,0 @@
[database]
connection = mysql+pymysql://nova:nova@10.20.20.1/nova
[api_database]
connection = mysql+pymysql://nova_api:nova_api@10.20.20.1/nova_api

View File

@ -1,2 +0,0 @@
[glance]
api_servers = http://10.20.20.1:9292

View File

@ -1,2 +0,0 @@
[DEFAULT]
transport_url = rabbit://openstack:rabbitmq@10.20.20.1

View File

@ -38,8 +38,28 @@ setup:
horizon-nginx.conf.j2: "{snap_common}/etc/nginx/snap/sites-enabled/horizon.conf"
libvirtd.conf.j2: "{snap_common}/libvirt/libvirtd.conf"
virtlogd.conf.j2: "{snap_common}/libvirt/virtlogd.conf"
microstack.rc.j2: "{snap_common}/etc/microstack.rc"
glance.conf.d.keystone.conf.j2: "{snap_common}/etc/glance/glance.conf.d/keystone.conf"
nova.conf.d.keystone.conf.j2: "{snap_common}/etc/nova/nova.conf.d/keystone.conf"
nova.conf.d.database.conf.j2: "{snap_common}/etc/nova/nova.conf.d/database.conf"
nova.conf.d.rabbitmq.conf.j2: "{snap_common}/etc/nova/nova.conf.d/rabbitmq.conf"
nova.conf.d.nova-placement.conf.j2: "{snap_common}/etc/nova/nova.conf.d/nova-placement.conf"
nova.conf.d.glance.conf.j2: "{snap_common}/etc/nova/nova.conf.d/glance.conf"
nova.conf.d.neutron.conf.j2: "{snap_common}/etc/nova/nova.conf.d/neutron.conf"
keystone.database.conf.j2: "{snap_common}/etc/keystone/keystone.conf.d/database.conf"
glance.database.conf.j2: "{snap_common}/etc/glance/glance.conf.d/database.conf"
neutron.keystone.conf.j2: "{snap_common}/etc/neutron/neutron.conf.d/keystone.conf"
neutron.nova.conf.j2: "{snap_common}/etc/neutron/neutron.conf.d/nova.conf"
neutron.database.conf.j2: "{snap_common}/etc/neutron/neutron.conf.d/database.conf"
chmod:
"{snap_common}/instances": 0755
"{snap_common}/etc/microstack.rc": 0644
snap-config-keys:
- ospassword
- extgateway
- extcidr
- dns
entry_points:
keystone-manage:
binary: "{snap}/bin/keystone-manage"

View File

@ -1,7 +1,7 @@
[keystone_authtoken]
auth_uri = http://10.20.20.1:5000
auth_url = http://10.20.20.1:5000
memcached_servers = 10.20.20.1:11211
auth_uri = http://{{ extgateway }}:5000
auth_url = http://{{ extgateway }}:5000
memcached_servers = {{ extgateway }}:11211
auth_type = password
project_domain_name = default
user_domain_name = default

View File

@ -0,0 +1,2 @@
[database]
connection = mysql+pymysql://glance:glance@{{ extgateway }}/glance

View File

@ -0,0 +1,2 @@
[database]
connection = mysql+pymysql://keystone:keystone@{{ extgateway }}/keystone

View File

@ -0,0 +1,9 @@
export OS_PROJECT_DOMAIN_NAME=default
export OS_USER_DOMAIN_NAME=default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD={{ ospassword }}
export OS_AUTH_URL=http://{{ extgateway }}:5000
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2

View File

@ -0,0 +1,2 @@
[database]
connection = mysql+pymysql://neutron:neutron@{{ extgateway }}/neutron

View File

@ -2,9 +2,9 @@
auth_strategy = keystone
[keystone_authtoken]
auth_uri = http://10.20.20.1:5000
auth_url = http://10.20.20.1:5000
memcached_servers = 10.20.20.1:11211
auth_uri = http://{{ extgateway }}:5000
auth_url = http://{{ extgateway }}:5000
memcached_servers = {{ extgateway }}:11211
auth_type = password
project_domain_name = default
user_domain_name = default

View File

@ -3,7 +3,7 @@ notify_nova_on_port_status_changes = True
notify_nova_on_port_data_changes = True
[nova]
auth_url = http://10.20.20.1:5000
auth_url = http://{{ extgateway }}:5000
auth_type = password
project_domain_name = default
user_domain_name = default

View File

@ -0,0 +1,5 @@
[database]
connection = mysql+pymysql://nova:nova@{{ extgateway }}/nova
[api_database]
connection = mysql+pymysql://nova_api:nova_api@{{ extgateway }}/nova_api

View File

@ -0,0 +1,2 @@
[glance]
api_servers = http://{{ extgateway }}:9292

View File

@ -1,7 +1,7 @@
[keystone_authtoken]
auth_uri = http://10.20.20.1:5000
auth_url = http://10.20.20.1:5000
memcached_servers = 10.20.20.1:11211
auth_uri = http://{{ extgateway }}:5000
auth_url = http://{{ extgateway }}:5000
memcached_servers = {{ extgateway }}:11211
auth_type = password
project_domain_name = default
user_domain_name = default

View File

@ -1,7 +1,7 @@
[neutron]
url = http://10.20.20.1:9696
auth_url = http://10.20.20.1:5000
memcached_servers = 10.20.20.1:11211
url = http://{{ extgateway }}:9696
auth_url = http://{{ extgateway }}:5000
memcached_servers = {{ extgateway }}:11211
auth_type = password
project_domain_name = default
user_domain_name = default

View File

@ -4,6 +4,6 @@ project_domain_name = default
project_name = service
auth_type = password
user_domain_name = default
auth_url = http://10.20.20.1:5000
auth_url = http://{{ extgateway }}:5000
username = placement
password = placement

View File

@ -0,0 +1,2 @@
[DEFAULT]
transport_url = rabbit://openstack:rabbitmq@{{ extgateway }}

View File

@ -0,0 +1,7 @@
#!/bin/bash
set -e
source $SNAP_COMMON/etc/microstack.rc
exec $@

38
snap/hooks/configure vendored
View File

@ -1,4 +1,20 @@
#!/bin/bash -e
#!/bin/bash
set -ex
ospassword=$(snapctl get ospassword)
extgateway=$(snapctl get extgateway)
extcidr=$(snapctl get extcidr)
dns=$(snapctl get dns)
if [ -z "$ospassword" -o -z "$extgateway" -o -z "$dns" -o -z "$extcidr"]; then
echo "Missing required config value."
snapctl get microstack
exit 1
fi
snap-openstack setup # Write out templates
source $SNAP_COMMON/etc/microstack.rc
# Open up networking so that instances can route to the Internet (see
# bin/setup-br-ex for more networking setup, executed on microstack
@ -9,25 +25,25 @@ sudo sysctl net.ipv4.ip_forward=1
echo "Creating OpenStack Databases"
# Wait for MySQL to startup
while ! nc -z 10.20.20.1 3306; do sleep 0.1; done;
while ! nc -z $extgateway 3306; do sleep 0.1; done;
sleep 5
# Wait for rabbitmq to start
while ! nc -z 10.20.20.1 5672; do sleep 0.1; done;
while ! nc -z $extgateway 5672; do sleep 0.1; done;
for db in neutron nova nova_api nova_cell0 cinder glance keystone; do
echo "CREATE DATABASE IF NOT EXISTS ${db}; GRANT ALL PRIVILEGES ON ${db}.* TO '${db}'@'10.20.20.1' IDENTIFIED BY '${db}';" \
echo "CREATE DATABASE IF NOT EXISTS ${db}; GRANT ALL PRIVILEGES ON ${db}.* TO '${db}'@'$extgateway' IDENTIFIED BY '${db}';" \
| mysql-start-client -u root
done
# Grant nova user access to cell0
echo "GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'10.20.20.1' IDENTIFIED BY 'nova';" | mysql-start-client -u root
echo "GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'$extgateway' IDENTIFIED BY 'nova';" | mysql-start-client -u root
# Endpoints from localhost -> 10.20.20.1
# TODO Rebuild database so that these are already set to 10.20.20.1,
# Endpoints from localhost -> $extgateway
# TODO Rebuild database so that these are already set to $extgateway,
# after lp:1824176 is addressed, and the process of building a new
# mysql.tar.xz is less fraught.
openstack endpoint list | grep localhost | while read line; do openstack endpoint set `echo $line | cut -d" " -f2` --url `echo $line | cut -d" " -f14 | sed 's/localhost/10.20.20.1/'`; done
openstack endpoint list | grep localhost | while read line; do openstack endpoint set `echo $line | cut -d" " -f2` --url `echo $line | cut -d" " -f14 | sed "s/localhost/$extgateway/"`; done
# RabbitMQ
echo "Configuring RabbitMQ"
@ -45,12 +61,12 @@ HOME=$SNAP_COMMON/lib/rabbitmq rabbitmqctl set_permissions openstack ".*" ".*" "
# Glance
echo "Waiting for glance to start."
while ! nc -z 10.20.20.1 9292; do sleep 0.1; done;
while ! nc -z $extgateway 9292; do sleep 0.1; done;
sleep 5
# Wait for identity service
while ! nc -z 10.20.20.1 5000; do sleep 0.1; done;
while ! nc -z $extgateway 5000; do sleep 0.1; done;
# Setup the cirros image, which is used by the launch app
openstack image show cirros || {
@ -70,7 +86,7 @@ openstack image show cirros || {
systemctl restart snap.microstack.*virt*
# Wait for horizon
while ! nc -z 10.20.20.1 80; do sleep 0.1; done;
while ! nc -z $extgateway 80; do sleep 0.1; done;
# Restart Placement API
# Workaround for issue w/ base:core18, where the Placement API throws

View File

@ -1,5 +1,11 @@
#!/bin/sh
set -e
#!/bin/bash
set -ex
snapctl set \
ospassword=keystone \
extgateway=10.20.20.1 \
extcidr=10.20.20.1/24 \
dns=1.1.1.1
# MySQL snapshot for speedy install
# snapshot is a mysql data dir with
@ -11,8 +17,10 @@ tar -xJf ${SNAP}/data/mysql.tar.xz -C ${SNAP_COMMON}/lib
echo "Installing configuration for OpenStack Services"
for project in neutron nova keystone glance; do
mkdir -p ${SNAP_COMMON}/etc/${project}/${project}.conf.d
cp -r ${SNAP}/etc/${project}/${project}.conf.d/* ${SNAP_COMMON}/etc/${project}/${project}.conf.d
cp -r ${SNAP}/etc/${project}/${project}.conf.d/* ${SNAP_COMMON}/etc/${project}/${project}.conf.d || true # Skip conf files that have been moved into templates
done
snap-openstack setup # Sets up templates for the first time.
# Configure Keystone Fernet Keys
snap-openstack keystone-manage fernet_setup --keystone-user root --keystone-group root
snap-openstack launch keystone-manage fernet_setup --keystone-user root --keystone-group root

View File

@ -12,20 +12,11 @@ environment:
PATH: $SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:/snap/core18/current/bin:$PATH
LC_ALL: C
OS_PLACEMENT_CONFIG_DIR: $SNAP/etc/nova/
# admin rc (TODO: put this someplace more sensible)
OS_PROJECT_DOMAIN_NAME: default
OS_USER_DOMAIN_NAME: default
OS_PROJECT_NAME: admin
OS_USERNAME: admin
OS_PASSWORD: keystone
OS_AUTH_URL: http://10.20.20.1:5000
OS_IDENTITY_API_VERSION: 3
OS_IMAGE_API_VERSION: 2
apps:
# Openstack
openstack:
command: openstack
command: openstack-wrapper openstack
# plugs:
# - network
@ -37,38 +28,38 @@ apps:
# Keystone
keystone-uwsgi:
command: snap-openstack keystone-uwsgi
command: snap-openstack launch keystone-uwsgi
daemon: simple
# plugs:
# - network-bind
keystone-manage:
command: snap-openstack keystone-manage
command: snap-openstack launch keystone-manage
# plugs:
# - network
# Nova
nova-uwsgi:
command: snap-openstack nova-uwsgi
command: snap-openstack launch nova-uwsgi
daemon: simple
# plugs:
# - network-bind
nova-api:
command: snap-openstack nova-api-os-compute
command: snap-openstack launch nova-api-os-compute
daemon: simple
# plugs:
# - network-bind
nova-conductor:
command: snap-openstack nova-conductor
command: snap-openstack launch nova-conductor
daemon: simple
# plugs:
# - network
nova-scheduler:
command: snap-openstack nova-scheduler
command: snap-openstack launch nova-scheduler
daemon: simple
# plugs:
# - network
nova-compute:
command: snap-openstack nova-compute
command: snap-openstack launch nova-compute
daemon: simple
# plugs:
# - network-bind
@ -78,24 +69,24 @@ apps:
# - libvirt
# - openvswitch
nova-api-metadata:
command: snap-openstack nova-api-metadata
command: snap-openstack launch nova-api-metadata
daemon: simple
# plugs:
# - network-bind
# - firewall-control
nova-manage:
command: snap-openstack nova-manage
command: snap-openstack launch nova-manage
# plugs:
# - network
# Neutron
neutron-api:
command: snap-openstack neutron-server
command: snap-openstack launch neutron-server
daemon: simple
# plugs:
# - network-bind
neutron-openvswitch-agent:
command: snap-openstack neutron-openvswitch-agent
command: snap-openstack launch neutron-openvswitch-agent
daemon: simple
# plugs:
# - network-bind
@ -106,7 +97,7 @@ apps:
# - system-observe
# - openvswitch
neutron-l3-agent:
command: snap-openstack neutron-l3-agent
command: snap-openstack launch neutron-l3-agent
daemon: simple
# plugs:
# - network-bind
@ -117,7 +108,7 @@ apps:
# - system-observe
# - openvswitch
neutron-dhcp-agent:
command: snap-openstack neutron-dhcp-agent
command: snap-openstack launch neutron-dhcp-agent
daemon: simple
# plugs:
# - network
@ -128,48 +119,48 @@ apps:
# - system-observe
# - openvswitch
neutron-metadata-agent:
command: snap-openstack neutron-metadata-agent
command: snap-openstack launch neutron-metadata-agent
daemon: simple
# plugs:
# - network
# - network-bind
# - network-control
neutron-ovs-cleanup:
command: snap-openstack neutron-ovs-cleanup
command: snap-openstack launch neutron-ovs-cleanup
# plugs:
# - network
# - network-control
# - openvswitch
neutron-netns-cleanup:
command: snap-openstack neutron-netns-cleanup
command: snap-openstack launch neutron-netns-cleanup
# plugs:
# - network
# - network-control
neutron-db-manage:
command: snap-openstack neutron-db-manage
command: snap-openstack launch neutron-db-manage
# plugs:
# - network
# Glance
glance-api:
command: snap-openstack glance-api
command: snap-openstack launch glance-api
daemon: simple
# plugs:
# - network-bind
registry:
command: snap-openstack glance-registry
command: snap-openstack launch glance-registry
daemon: simple
# plugs:
# - network
# - network-bind
glance-manage:
command: snap-openstack glance-manage
command: snap-openstack launch glance-manage
# plugs:
# - network
# Openstack Shared Services
nginx:
command: snap-openstack nginx
command: snap-openstack launch nginx
daemon: forking
# plugs:
# - network-bind
@ -278,33 +269,33 @@ apps:
# Cinder
cinder-uwsgi:
command: snap-openstack cinder-uwsgi
command: snap-openstack launch cinder-uwsgi
# daemon: simple
# plugs:
# - network-bind
cinder-backup:
command: snap-openstack cinder-backup
command: snap-openstack launch cinder-backup
# daemon: simple
# plugs:
# - network
cinder-manage:
command: snap-openstack cinder-manage
command: snap-openstack launch cinder-manage
# plugs:
# - network
cinder-scheduler:
command: snap-openstack cinder-scheduler
command: snap-openstack launch cinder-scheduler
# daemon: simple
# plugs:
# - network
cinder-volume:
command: snap-openstack cinder-volume
command: snap-openstack launch cinder-volume
# daemon: simple
# plugs:
# - network
# Horizon
horizon-uwsgi:
command: snap-openstack horizon-uwsgi
command: snap-openstack launch horizon-uwsgi
daemon: simple
# plugs:
# - network-bind
@ -329,7 +320,7 @@ parts:
- oslo.cache[dogpile]
- pymysql
- uwsgi
- git+https://github.com/openstack/snap.openstack#egg=snap.openstack
- git+https://opendev.org/x/snap.openstack#egg=snap.openstack
- http://tarballs.openstack.org/nova/nova-stable-rocky.tar.gz
- http://tarballs.openstack.org/neutron/neutron-stable-rocky.tar.gz
- http://tarballs.openstack.org/glance/glance-stable-rocky.tar.gz
@ -377,6 +368,14 @@ parts:
stage: [$etc]
prime: [$etc]
openstack-wrapper:
source: ./snap-wrappers/openstack
plugin: dump
after:
- openstack-projects
organize:
openstack-wrapper: bin/openstack-wrapper
nova-config:
after: [openstack-projects]
plugin: dump