Added set_endpoints_by_interface recipe & attributes to support 'bind_interface'
Added set_endpoints_by_interface recipe to enable iterating over the contents of the node['openstack']['endpoints'] hash and finding any non-nil `bind_interface` to set the IP address. For example node['openstack']['endpoints']['identity']['bind_interface'] = 'eth0' would set node['openstack']['endpoints']['identity']['host'] to whatever IP address was on 'eth0' rather than hard-code the IP addresses in an Environment. Change-Id: Ic07626d4e3b3fb743191077f95c5bdd04a5504cd
This commit is contained in:
parent
162b497957
commit
a463d12204
|
@ -2,6 +2,11 @@
|
|||
|
||||
This file is used to list changes made in each version of cookbook-openstack-common.
|
||||
|
||||
## 0.4.5:
|
||||
* Added `openstack-common::set_endpoints_by_interface` to enable using
|
||||
`bind_interface` with endpoints rather than hard-code the IP addresses in an
|
||||
Environment.
|
||||
|
||||
## 0.4.4:
|
||||
* Add support for openstack-common::sysctl and managing sysctl settings via the
|
||||
node['openstack']['sysctl'] hash, written out to /etc/sysctl.d/60-openstack.conf
|
||||
|
|
15
README.md
15
README.md
|
@ -49,6 +49,21 @@ Installs/Configures common logging
|
|||
]
|
||||
```
|
||||
|
||||
set_endpoints_by_interface
|
||||
----
|
||||
|
||||
Iterates over the contents of the `node['openstack']['endpoints']` hash and
|
||||
finds any occurrence of `bind_interface` to set the IP address
|
||||
(`node['openstack']['endpoints']['identity']['bind_interface'] = 'eth0'` for
|
||||
example, overriding `node['openstack']['endpoints']['identity']['host']`). If
|
||||
`bind_interface` isn't set, the value of `host` is not modified.
|
||||
|
||||
```json
|
||||
"run_list": [
|
||||
"recipe[openstack-common::set_endpoints_by_interface]"
|
||||
]
|
||||
```
|
||||
|
||||
sysctl
|
||||
----
|
||||
|
||||
|
|
|
@ -102,13 +102,16 @@ default["openstack"]["zypp"]["uri"] = "http://download.opensuse.org/repositories
|
|||
# - host
|
||||
# - port
|
||||
# - path
|
||||
# - bind_interface
|
||||
#
|
||||
# If the uri key is set, its value is used as the full URI for the endpoint.
|
||||
# If the uri key is not set, the endpoint's full URI is constructed from the
|
||||
# component parts. This allows setups that use some standardized DNS names for
|
||||
# OpenStack service endpoints in a deployment zone as well as setups that
|
||||
# instead assign IP addresses (for an actual node or a load balanced virtual
|
||||
# IP) in a network to a particular OpenStack service endpoint.
|
||||
# IP) in a network to a particular OpenStack service endpoint. If the
|
||||
# bind_interface is set, it will set the host IP in the
|
||||
# set_endpoints_by_interface recipe.
|
||||
|
||||
# ******************** OpenStack Identity Endpoints ***************************
|
||||
|
||||
|
@ -118,12 +121,14 @@ default['openstack']['endpoints']['identity-api']['host'] = "127.0.0.1"
|
|||
default['openstack']['endpoints']['identity-api']['scheme'] = "http"
|
||||
default['openstack']['endpoints']['identity-api']['port'] = "5000"
|
||||
default['openstack']['endpoints']['identity-api']['path'] = "/v2.0"
|
||||
default['openstack']['endpoints']['identity-api']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Identity (Keystone) Admin API endpoint
|
||||
default['openstack']['endpoints']['identity-admin']['host'] = "127.0.0.1"
|
||||
default['openstack']['endpoints']['identity-admin']['scheme'] = "http"
|
||||
default['openstack']['endpoints']['identity-admin']['port'] = "35357"
|
||||
default['openstack']['endpoints']['identity-admin']['path'] = "/v2.0"
|
||||
default['openstack']['endpoints']['identity-admin']['bind_interface'] = nil
|
||||
|
||||
# ****************** OpenStack Compute Endpoints ******************************
|
||||
|
||||
|
@ -132,30 +137,35 @@ default['openstack']['endpoints']['compute-api']['host'] = "127.0.0.1"
|
|||
default['openstack']['endpoints']['compute-api']['scheme'] = "http"
|
||||
default['openstack']['endpoints']['compute-api']['port'] = "8774"
|
||||
default['openstack']['endpoints']['compute-api']['path'] = "/v2/%(tenant_id)s"
|
||||
default['openstack']['endpoints']['compute-api']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Compute (Nova) EC2 API endpoint
|
||||
default['openstack']['endpoints']['compute-ec2-api']['host'] = "127.0.0.1"
|
||||
default['openstack']['endpoints']['compute-ec2-api']['scheme'] = "http"
|
||||
default['openstack']['endpoints']['compute-ec2-api']['port'] = "8773"
|
||||
default['openstack']['endpoints']['compute-ec2-api']['path'] = "/services/Cloud"
|
||||
default['openstack']['endpoints']['compute-ec2-api']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Compute (Nova) EC2 Admin API endpoint
|
||||
default['openstack']['endpoints']['compute-ec2-admin']['host'] = "127.0.0.1"
|
||||
default['openstack']['endpoints']['compute-ec2-admin']['scheme'] = "http"
|
||||
default['openstack']['endpoints']['compute-ec2-admin']['port'] = "8773"
|
||||
default['openstack']['endpoints']['compute-ec2-admin']['path'] = "/services/Admin"
|
||||
default['openstack']['endpoints']['compute-ec2-admin']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Compute (Nova) XVPvnc endpoint
|
||||
default['openstack']['endpoints']['compute-xvpvnc']['host'] = "127.0.0.1"
|
||||
default['openstack']['endpoints']['compute-xvpvnc']['scheme'] = "http"
|
||||
default['openstack']['endpoints']['compute-xvpvnc']['port'] = "6081"
|
||||
default['openstack']['endpoints']['compute-xvpvnc']['path'] = "/console"
|
||||
default['openstack']['endpoints']['compute-xvpvnc']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Compute (Nova) novnc endpoint
|
||||
default['openstack']['endpoints']['compute-novnc']['host'] = "127.0.0.1"
|
||||
default['openstack']['endpoints']['compute-novnc']['scheme'] = "http"
|
||||
default['openstack']['endpoints']['compute-novnc']['port'] = "6080"
|
||||
default['openstack']['endpoints']['compute-novnc']['path'] = "/vnc_auto.html"
|
||||
default['openstack']['endpoints']['compute-novnc']['bind_interface'] = nil
|
||||
|
||||
# ******************** OpenStack Network Endpoints ****************************
|
||||
|
||||
|
@ -166,6 +176,7 @@ default['openstack']['endpoints']['network-api']['port'] = "9696"
|
|||
# quantumclient appends the protocol version to the endpoint URL, so the
|
||||
# path needs to be empty
|
||||
default['openstack']['endpoints']['network-api']['path'] = ""
|
||||
default['openstack']['endpoints']['network-api']['bind_interface'] = nil
|
||||
|
||||
# ******************** OpenStack Image Endpoints ******************************
|
||||
|
||||
|
@ -174,12 +185,14 @@ default['openstack']['endpoints']['image-api']['host'] = "127.0.0.1"
|
|||
default['openstack']['endpoints']['image-api']['scheme'] = "http"
|
||||
default['openstack']['endpoints']['image-api']['port'] = "9292"
|
||||
default['openstack']['endpoints']['image-api']['path'] = "/v2"
|
||||
default['openstack']['endpoints']['image-api']['bind_interface'] = nil
|
||||
|
||||
# The OpenStack Image (Glance) Registry API endpoint
|
||||
default['openstack']['endpoints']['image-registry']['host'] = "127.0.0.1"
|
||||
default['openstack']['endpoints']['image-registry']['scheme'] = "http"
|
||||
default['openstack']['endpoints']['image-registry']['port'] = "9191"
|
||||
default['openstack']['endpoints']['image-registry']['path'] = "/v2"
|
||||
default['openstack']['endpoints']['image-registry']['bind_interface'] = nil
|
||||
|
||||
# ******************** OpenStack Volume Endpoints *****************************
|
||||
|
||||
|
@ -188,6 +201,7 @@ default['openstack']['endpoints']['volume-api']['host'] = "127.0.0.1"
|
|||
default['openstack']['endpoints']['volume-api']['scheme'] = "http"
|
||||
default['openstack']['endpoints']['volume-api']['port'] = "8776"
|
||||
default['openstack']['endpoints']['volume-api']['path'] = "/v1/%(tenant_id)s"
|
||||
default['openstack']['endpoints']['volume-api']['bind_interface'] = nil
|
||||
|
||||
# ******************** OpenStack Metering Endpoints ***************************
|
||||
|
||||
|
@ -196,6 +210,7 @@ default['openstack']['endpoints']['metering-api']['host'] = "127.0.0.1"
|
|||
default['openstack']['endpoints']['metering-api']['scheme'] = "http"
|
||||
default['openstack']['endpoints']['metering-api']['port'] = "8777"
|
||||
default['openstack']['endpoints']['metering-api']['path'] = "/v1"
|
||||
default['openstack']['endpoints']['metering-api']['bind_interface'] = nil
|
||||
|
||||
# Alternately, if you used some standardized DNS naming scheme, you could
|
||||
# do something like this, which would override any part-wise specifications above.
|
||||
|
@ -314,7 +329,7 @@ default['openstack']['logging']['ignore'] = {'nova.api.openstack.wsgi' => 'WARNI
|
|||
|
||||
default['openstack']['memcached_servers'] = nil
|
||||
|
||||
# Default database attributes
|
||||
# Default messaging attributes
|
||||
default["openstack"]["mq"]["server_role"] = "os-ops-messaging"
|
||||
default["openstack"]["mq"]["service_type"] = "rabbitmq"
|
||||
default["openstack"]["mq"]["port"] = "5672"
|
||||
|
|
|
@ -4,9 +4,10 @@ maintainer_email "cookbooks@lists.tfoundry.com"
|
|||
license "Apache 2.0"
|
||||
description "Common OpenStack attributes, libraries and recipes."
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version "0.4.4"
|
||||
version "0.4.5"
|
||||
|
||||
recipe "openstack-common", "Installs/Configures common recipes"
|
||||
recipe "openstack-common::set_endpoints_by_interface", "Set endpoints by interface"
|
||||
recipe "openstack-common::logging", "Installs/Configures common logging"
|
||||
recipe "openstack-common::sysctl", "Configures sysctl settings"
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
#
|
||||
# Cookbook Name:: openstack-common
|
||||
# recipe:: set_endpoints_by_interface
|
||||
#
|
||||
# Copyright 2013, Opscode, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
class ::Chef::Recipe
|
||||
include ::Openstack
|
||||
end
|
||||
|
||||
# iterate over the endpoints, look for bind_interface to set the host
|
||||
node['openstack']['endpoints'].keys.each do |component|
|
||||
unless node['openstack']['endpoints'][component]['bind_interface'].nil?
|
||||
ip_address = address_for node['openstack']['endpoints'][component]['bind_interface']
|
||||
node.default['openstack']['endpoints'][component]['host'] = ip_address
|
||||
end
|
||||
end
|
|
@ -4,7 +4,7 @@ require ::File.join ::File.dirname(__FILE__), "..", "libraries", "endpoints"
|
|||
describe ::Openstack do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::ChefRunner.new ::CHEFSPEC_OPTS
|
||||
@chef_run.converge "openstack-common::default"
|
||||
@chef_run.converge "openstack-common::set_endpoints_by_interface"
|
||||
@subject = ::Object.new.extend ::Openstack
|
||||
end
|
||||
|
||||
|
@ -74,6 +74,35 @@ describe ::Openstack do
|
|||
@subject.stub(:node).and_return uri_hash
|
||||
@subject.endpoint "compute-api"
|
||||
end
|
||||
it "endpoints recipe bind_interface sets host" do
|
||||
@subject.stub('address_for').and_return '10.0.0.100'
|
||||
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
|
||||
chef_run.node.set['openstack']['endpoints']['identity-api']['bind_interface'] = 'eth0'
|
||||
chef_run.node.set['network'] = {
|
||||
'interfaces' => {
|
||||
'lo' => {
|
||||
'addresses' => {
|
||||
'127.0.0.1'=> {
|
||||
'family' => 'inet',
|
||||
'netmask' => '255.0.0.0',
|
||||
'scope' => 'Node'
|
||||
}
|
||||
}
|
||||
},
|
||||
'eth0' => {
|
||||
'addresses' => {
|
||||
'10.0.0.100'=> {
|
||||
'family' => 'inet',
|
||||
'netmask' => '255.255.255.0',
|
||||
'scope' => 'Global'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
chef_run.converge 'openstack-common::set_endpoints_by_interface'
|
||||
expect(chef_run.node['openstack']['endpoints']['identity-api']['host']).to eql('10.0.0.100')
|
||||
end
|
||||
end
|
||||
|
||||
describe "#endpoints" do
|
||||
|
|
Loading…
Reference in New Issue