Add installation and configuration support for Ironic
This commit adds attributes, templates, recipes and spec files to support the installation and configuration of Ironic. Depends on: https://review.openstack.org/#/c/148458/ https://review.openstack.org/#/c/148463/ Adds temp workaround to cover the common attributes and create ironic database with user util Kilo branch is created. blueprint bare-metal-enablement Change-Id: I48202ea1ebf7621141f97778961758b73da76e27
This commit is contained in:
parent
001ae7fe6d
commit
591c8773d2
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -1,13 +0,0 @@
|
|||
cookbook-openstack-bare-metal CHANGELOG
|
||||
=======================================
|
||||
|
||||
This file is used to list changes made in each version of the cookbook-openstack-bare-metal cookbook.
|
||||
|
||||
11.0.0
|
||||
-----
|
||||
- Initial release of cookbook-openstack-bare-metal for Kilo
|
||||
|
||||
- - -
|
||||
Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.
|
||||
|
||||
The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.
|
|
@ -0,0 +1,101 @@
|
|||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: openstack-bare-metal
|
||||
# Attributes:: common-temp
|
||||
#
|
||||
# Copyright 2015, IBM, Corp
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# TODO(wenchma) The following attributes are temporary workaround.
|
||||
# These could be removed and replaced by the following patch once Kilo branch is created.
|
||||
# https://review.openstack.org/#/c/148458/
|
||||
|
||||
# Database used by OpenStack Bare Metal (Ironic)
|
||||
default['openstack']['db']['bare-metal']['service_type'] = node['openstack']['db']['service_type']
|
||||
default['openstack']['db']['bare-metal']['host'] = node['openstack']['endpoints']['db']['host']
|
||||
default['openstack']['db']['bare-metal']['port'] = node['openstack']['endpoints']['db']['port']
|
||||
default['openstack']['db']['bare-metal']['db_name'] = 'ironic'
|
||||
default['openstack']['db']['bare-metal']['username'] = 'ironic'
|
||||
default['openstack']['db']['bare-metal']['options'] = node['openstack']['db']['options']
|
||||
|
||||
# Default attributes when not using data bags (use_databags = false)
|
||||
%w{user service db token}.each do |type|
|
||||
default['openstack']['secret']['bare-metal'][type] = "bare-metal-#{type}"
|
||||
end
|
||||
|
||||
qpid_defaults = {
|
||||
username: node['openstack']['mq']['user'],
|
||||
sasl_mechanisms: '',
|
||||
reconnect: true,
|
||||
reconnect_timeout: 0,
|
||||
reconnect_limit: 0,
|
||||
reconnect_interval_min: 0,
|
||||
reconnect_interval_max: 0,
|
||||
reconnect_interval: 0,
|
||||
heartbeat: 60,
|
||||
protocol: node['openstack']['mq']['qpid']['protocol'],
|
||||
tcp_nodelay: true,
|
||||
host: node['openstack']['endpoints']['mq']['host'],
|
||||
port: node['openstack']['endpoints']['mq']['port'],
|
||||
qpid_hosts: ["#{node['openstack']['endpoints']['mq']['host']}:#{node['openstack']['endpoints']['mq']['port']}"],
|
||||
topology_version: node['openstack']['mq']['qpid']['topology_version']
|
||||
}
|
||||
|
||||
rabbit_defaults = {
|
||||
userid: node['openstack']['mq']['user'],
|
||||
vhost: node['openstack']['mq']['vhost'],
|
||||
port: node['openstack']['endpoints']['mq']['port'],
|
||||
host: node['openstack']['endpoints']['mq']['host'],
|
||||
ha: node['openstack']['mq']['rabbitmq']['ha'],
|
||||
use_ssl: node['openstack']['mq']['rabbitmq']['use_ssl']
|
||||
}
|
||||
|
||||
default['openstack']['mq']['bare-metal']['service_type'] = node['openstack']['mq']['service_type']
|
||||
default['openstack']['mq']['bare-metal']['notification_topic'] = 'notifications'
|
||||
|
||||
default['openstack']['mq']['bare-metal']['durable_queues'] =
|
||||
node['openstack']['mq']['durable_queues']
|
||||
default['openstack']['mq']['bare-metal']['auto_delete'] =
|
||||
node['openstack']['mq']['auto_delete']
|
||||
|
||||
case node['openstack']['mq']['bare-metal']['service_type']
|
||||
when 'qpid'
|
||||
qpid_defaults.each do |key, val|
|
||||
default['openstack']['mq']['bare-metal']['qpid'][key.to_s] = val
|
||||
end
|
||||
when 'rabbitmq'
|
||||
rabbit_defaults.each do |key, val|
|
||||
default['openstack']['mq']['bare-metal']['rabbit'][key.to_s] = val
|
||||
end
|
||||
end
|
||||
|
||||
default['openstack']['mq']['bare-metal']['qpid']['notification_topic'] =
|
||||
node['openstack']['mq']['bare-metal']['notification_topic']
|
||||
default['openstack']['mq']['bare-metal']['rabbit']['notification_topic'] =
|
||||
node['openstack']['mq']['bare-metal']['notification_topic']
|
||||
default['openstack']['mq']['bare-metal']['control_exchange'] = 'ironic'
|
||||
|
||||
# ******************** OpenStack Bare Metal Endpoints *****************************
|
||||
|
||||
# The OpenStack Bare Metal (Ironic) API endpoint
|
||||
default['openstack']['endpoints']['bare-metal-api-bind']['host'] = node['openstack']['endpoints']['bind-host']
|
||||
default['openstack']['endpoints']['bare-metal-api-bind']['port'] = '6385'
|
||||
default['openstack']['endpoints']['bare-metal-api-bind']['bind_interface'] = nil
|
||||
|
||||
default['openstack']['endpoints']['bare-metal-api']['host'] = node['openstack']['endpoints']['host']
|
||||
default['openstack']['endpoints']['bare-metal-api']['scheme'] = 'http'
|
||||
default['openstack']['endpoints']['bare-metal-api']['port'] = '6385'
|
||||
default['openstack']['endpoints']['bare-metal-api']['path'] = ''
|
||||
default['openstack']['endpoints']['bare-metal-api']['bind_interface'] = nil
|
|
@ -0,0 +1,81 @@
|
|||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: openstack-bare-metal
|
||||
# Attributes:: default
|
||||
#
|
||||
# Copyright 2015, IBM, Corp
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# Set to some text value if you want templated config files
|
||||
# to contain a custom banner at the top of the written file
|
||||
default['openstack']['bare-metal']['custom_template_banner'] = "
|
||||
# This file autogenerated by Chef
|
||||
# Do not edit, changes will be overwritten
|
||||
"
|
||||
|
||||
default['openstack']['bare-metal']['verbose'] = 'false'
|
||||
default['openstack']['bare-metal']['debug'] = 'false'
|
||||
|
||||
# Common rpc definitions
|
||||
default['openstack']['bare-metal']['rpc_thread_pool_size'] = 64
|
||||
default['openstack']['bare-metal']['rpc_conn_pool_size'] = 30
|
||||
default['openstack']['bare-metal']['rpc_response_timeout'] = 60
|
||||
|
||||
# Logging stuff
|
||||
default['openstack']['bare-metal']['log_dir'] = '/var/log/ironic'
|
||||
|
||||
default['openstack']['bare-metal']['syslog']['use'] = false
|
||||
default['openstack']['bare-metal']['syslog']['facility'] = 'LOG_LOCAL1'
|
||||
default['openstack']['bare-metal']['syslog']['config_facility'] = 'local1'
|
||||
|
||||
default['openstack']['bare-metal']['region'] = node['openstack']['region']
|
||||
|
||||
# Keystone settings
|
||||
default['openstack']['bare-metal']['api']['auth_strategy'] = 'keystone'
|
||||
|
||||
default['openstack']['bare-metal']['api']['auth']['version'] = node['openstack']['api']['auth']['version']
|
||||
|
||||
default['openstack']['bare-metal']['service_tenant_name'] = 'service'
|
||||
default['openstack']['bare-metal']['service_user'] = 'ironic'
|
||||
default['openstack']['bare-metal']['service_role'] = 'admin'
|
||||
|
||||
default['openstack']['bare-metal']['user'] = 'ironic'
|
||||
default['openstack']['bare-metal']['group'] = 'ironic'
|
||||
|
||||
# rootwrap.conf
|
||||
default['openstack']['bare-metal']['rootwrap']['filters_path'] = '/etc/ironic/rootwrap.d,/usr/share/ironic/rootwrap'
|
||||
default['openstack']['bare-metal']['rootwrap']['exec_dirs'] = '/sbin,/usr/sbin,/bin,/usr/bin'
|
||||
default['openstack']['bare-metal']['rootwrap']['use_syslog'] = false
|
||||
default['openstack']['bare-metal']['rootwrap']['syslog_log_facility'] = 'syslog'
|
||||
default['openstack']['bare-metal']['rootwrap']['syslog_log_level'] = 'ERROR'
|
||||
|
||||
case platform_family
|
||||
when 'fedora', 'rhel'
|
||||
default['openstack']['bare-metal']['platform'] = {
|
||||
'ironic_api_packages' => ['openstack-ironic-api'],
|
||||
'ironic_api_service' => 'openstack-ironic-api',
|
||||
'ironic_conductor_packages' => ['openstack-ironic-conductor'],
|
||||
'ironic_conductor_service' => 'openstack-ironic-conductor',
|
||||
'ironic_common_packages' => ['openstack-ironic-common', 'python-ironicclient']
|
||||
}
|
||||
when 'debian'
|
||||
default['openstack']['bare-metal']['platform'] = {
|
||||
'ironic_api_packages' => ['ironic-api'],
|
||||
'ironic_api_service' => 'ironic-api',
|
||||
'ironic_conductor_packages' => ['ironic-conductor'],
|
||||
'ironic_conductor_service' => 'ironic-conductor',
|
||||
'ironic_common_packages' => ['python-ironicclient']
|
||||
}
|
||||
end
|
|
@ -6,4 +6,10 @@ description 'Installs/Configures OpenStack Bare Metal service Ironic'
|
|||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version '11.0.0'
|
||||
|
||||
recipe 'openstack-bare-metal::api', 'Installs the ironic-api, sets up the ironic database'
|
||||
recipe 'openstack-bare-metal::conductor', 'Installs the ironic-conductor service'
|
||||
recipe 'openstack-bare-metal::default', 'Temp workaround to create ironic db with user'
|
||||
recipe 'openstack-bare-metal::identity_registration', 'Registers ironic service/user/endpoints in keystone'
|
||||
recipe 'openstack-bare-metal::ironic-common', 'Defines the common pieces of repeated code from the other recipes'
|
||||
|
||||
depends 'openstack-common', '~> 10.0'
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
# Encoding: utf-8
|
||||
#
|
||||
# Cookbook Name:: openstack-bare-metal
|
||||
# Recipe:: api
|
||||
#
|
||||
# Copyright 2015, IBM Corp.
|
||||
#
|
||||
# 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 # rubocop:disable Documentation
|
||||
include ::Openstack
|
||||
end
|
||||
|
||||
include_recipe 'openstack-bare-metal::ironic-common'
|
||||
|
||||
platform_options = node['openstack']['bare-metal']['platform']
|
||||
|
||||
platform_options['ironic_api_packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :upgrade
|
||||
|
||||
notifies :restart, 'service[ironic-api]'
|
||||
end
|
||||
end
|
||||
|
||||
service 'ironic-api' do
|
||||
service_name platform_options['ironic_api_service']
|
||||
supports status: true, restart: true
|
||||
|
||||
action [:enable]
|
||||
|
||||
subscribes :restart, 'template[/etc/ironic/ironic.conf]'
|
||||
|
||||
platform_options['ironic_common_packages'].each do |pkg|
|
||||
subscribes :restart, "package[#{pkg}]"
|
||||
end
|
||||
end
|
||||
|
||||
execute 'ironic db sync' do
|
||||
command 'ironic-dbsync --config-file /etc/ironic/ironic.conf create_schema'
|
||||
user node['openstack']['bare-metal']['user']
|
||||
group node['openstack']['bare-metal']['group']
|
||||
action :run
|
||||
end
|
|
@ -0,0 +1,48 @@
|
|||
# Encoding: utf-8
|
||||
#
|
||||
# Cookbook Name:: openstack-bare-metal
|
||||
# Recipe:: conductor
|
||||
#
|
||||
# Copyright 2015, IBM Corp.
|
||||
#
|
||||
# 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 # rubocop:disable Documentation
|
||||
include ::Openstack
|
||||
end
|
||||
|
||||
include_recipe 'openstack-bare-metal::ironic-common'
|
||||
|
||||
platform_options = node['openstack']['bare-metal']['platform']
|
||||
|
||||
platform_options['ironic_conductor_packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :upgrade
|
||||
|
||||
notifies :restart, 'service[ironic-conductor]'
|
||||
end
|
||||
end
|
||||
|
||||
service 'ironic-conductor' do
|
||||
service_name platform_options['ironic_conductor_service']
|
||||
supports status: true, restart: true
|
||||
|
||||
action [:enable]
|
||||
|
||||
subscribes :restart, 'template[/etc/ironic/ironic.conf]'
|
||||
|
||||
platform_options['ironic_common_packages'].each do |pkg|
|
||||
subscribes :restart, "package[#{pkg}]"
|
||||
end
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
# Encoding: utf-8
|
||||
#
|
||||
# Cookbook Name:: openstack-bare-metal
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2015, IBM Corp.
|
||||
#
|
||||
# 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 # rubocop:disable Documentation
|
||||
include ::Openstack
|
||||
end
|
||||
|
||||
# TODO(wenchma) A temporary workaround to ironic database with user instead of openstack-ops-database.
|
||||
# These could be removed and replaced by the following patch once Kilo branch is created.
|
||||
# https://review.openstack.org/#/c/148463/
|
||||
db_create_with_user(
|
||||
'bare-metal',
|
||||
node['openstack']['db']['bare-metal']['username'],
|
||||
get_password('db', 'ironic')
|
||||
)
|
|
@ -0,0 +1,86 @@
|
|||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: openstack-bare-metal
|
||||
# Recipe:: identity_registration
|
||||
#
|
||||
# Copyright 2015, IBM, 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.
|
||||
#
|
||||
|
||||
require 'uri'
|
||||
|
||||
class ::Chef::Recipe # rubocop:disable Documentation
|
||||
include ::Openstack
|
||||
end
|
||||
|
||||
identity_admin_endpoint = endpoint 'identity-admin'
|
||||
bootstrap_token = get_secret 'openstack_identity_bootstrap_token'
|
||||
auth_uri = ::URI.decode identity_admin_endpoint.to_s
|
||||
ironic_api_endpoint = endpoint 'bare-metal-api'
|
||||
service_pass = get_password 'service', 'openstack-bare-metal'
|
||||
region = node['openstack']['bare-metal']['region']
|
||||
service_tenant_name = node['openstack']['bare-metal']['service_tenant_name']
|
||||
service_user = node['openstack']['bare-metal']['service_user']
|
||||
service_role = node['openstack']['bare-metal']['service_role']
|
||||
|
||||
openstack_identity_register 'Register Service Tenant' do
|
||||
auth_uri auth_uri
|
||||
bootstrap_token bootstrap_token
|
||||
tenant_name service_tenant_name
|
||||
tenant_description 'Service Tenant'
|
||||
|
||||
action :create_tenant
|
||||
end
|
||||
|
||||
openstack_identity_register 'Register Ironic bare metal Service' do
|
||||
auth_uri auth_uri
|
||||
bootstrap_token bootstrap_token
|
||||
service_name 'ironic'
|
||||
service_type 'baremetal'
|
||||
service_description 'Ironic bare metal provisioning service'
|
||||
|
||||
action :create_service
|
||||
end
|
||||
|
||||
openstack_identity_register 'Register Ironic bare metal Endpoint' do
|
||||
auth_uri auth_uri
|
||||
bootstrap_token bootstrap_token
|
||||
service_type 'baremetal'
|
||||
endpoint_region region
|
||||
endpoint_adminurl ::URI.decode ironic_api_endpoint.to_s
|
||||
endpoint_internalurl ::URI.decode ironic_api_endpoint.to_s
|
||||
endpoint_publicurl ::URI.decode ironic_api_endpoint.to_s
|
||||
|
||||
action :create_endpoint
|
||||
end
|
||||
|
||||
openstack_identity_register 'Register Ironic bare metal Service User' do
|
||||
auth_uri auth_uri
|
||||
bootstrap_token bootstrap_token
|
||||
tenant_name service_tenant_name
|
||||
user_name service_user
|
||||
user_pass service_pass
|
||||
|
||||
action :create_user
|
||||
end
|
||||
|
||||
openstack_identity_register 'Grant service Role to Ironic Service User for Ironic Service Tenant' do
|
||||
auth_uri auth_uri
|
||||
bootstrap_token bootstrap_token
|
||||
tenant_name service_tenant_name
|
||||
user_name service_user
|
||||
role_name service_role
|
||||
|
||||
action :grant_role
|
||||
end
|
|
@ -0,0 +1,98 @@
|
|||
# Encoding: utf-8
|
||||
#
|
||||
# Cookbook Name:: openstack-bare-metal
|
||||
# Recipe:: ironic-common
|
||||
#
|
||||
# Copyright 2015, IBM Corp.
|
||||
#
|
||||
# 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 # rubocop:disable Documentation
|
||||
include ::Openstack
|
||||
end
|
||||
|
||||
if node['openstack']['bare-metal']['syslog']['use']
|
||||
include_recipe 'openstack-common::logging'
|
||||
end
|
||||
|
||||
platform_options = node['openstack']['bare-metal']['platform']
|
||||
|
||||
platform_options['ironic_common_packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :upgrade
|
||||
end
|
||||
end
|
||||
|
||||
db_type = node['openstack']['db']['bare-metal']['service_type']
|
||||
node['openstack']['db']['python_packages'][db_type].each do |pkg|
|
||||
package pkg do
|
||||
action :upgrade
|
||||
end
|
||||
end
|
||||
|
||||
directory '/etc/ironic' do
|
||||
owner node['openstack']['bare-metal']['user']
|
||||
group node['openstack']['bare-metal']['group']
|
||||
mode 00750
|
||||
action :create
|
||||
end
|
||||
|
||||
db_user = node['openstack']['db']['bare-metal']['username']
|
||||
db_pass = get_password 'db', 'ironic'
|
||||
db_connection = db_uri('bare-metal', db_user, db_pass)
|
||||
|
||||
mq_service_type = node['openstack']['mq']['bare-metal']['service_type']
|
||||
|
||||
if mq_service_type == 'rabbitmq'
|
||||
node['openstack']['mq']['bare-metal']['rabbit']['ha'] && (rabbit_hosts = rabbit_servers)
|
||||
mq_password = get_password 'user', node['openstack']['mq']['bare-metal']['rabbit']['userid']
|
||||
elsif mq_service_type == 'qpid'
|
||||
mq_password = get_password 'user', node['openstack']['mq']['bare-metal']['qpid']['username']
|
||||
end
|
||||
|
||||
image_endpoint = endpoint 'image-api'
|
||||
|
||||
identity_endpoint = endpoint 'identity-api'
|
||||
identity_admin_endpoint = endpoint 'identity-admin'
|
||||
service_pass = get_password 'service', 'openstack-bare-metal'
|
||||
|
||||
auth_uri = auth_uri_transform(identity_endpoint.to_s, node['openstack']['bare-metal']['api']['auth']['version'])
|
||||
|
||||
template '/etc/ironic/ironic.conf' do
|
||||
source 'ironic.conf.erb'
|
||||
owner node['openstack']['bare-metal']['user']
|
||||
group node['openstack']['bare-metal']['group']
|
||||
mode 00640
|
||||
variables(
|
||||
db_connection: db_connection,
|
||||
mq_service_type: mq_service_type,
|
||||
mq_password: mq_password,
|
||||
rabbit_hosts: rabbit_hosts,
|
||||
identity_endpoint: identity_endpoint,
|
||||
glance_protocol: image_endpoint.scheme,
|
||||
glance_host: image_endpoint.host,
|
||||
glance_port: image_endpoint.port,
|
||||
auth_uri: auth_uri,
|
||||
identity_admin_endpoint: identity_admin_endpoint,
|
||||
service_pass: service_pass
|
||||
)
|
||||
end
|
||||
|
||||
template '/etc/ironic/rootwrap.conf' do
|
||||
source 'rootwrap.conf.erb'
|
||||
# Must be root!
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode 00644
|
||||
end
|
|
@ -0,0 +1,67 @@
|
|||
# Encoding: utf-8
|
||||
#
|
||||
# Cookbook Name:: openstack-bare-metal
|
||||
# Spec:: api_spec
|
||||
#
|
||||
# Copyright 2015, IBM Corp.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-bare-metal::api' do
|
||||
describe 'ubuntu' do
|
||||
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
include_context 'bare-metal-stubs'
|
||||
|
||||
it 'includes ironic common recipe' do
|
||||
expect(chef_run).to include_recipe('openstack-bare-metal::ironic-common')
|
||||
end
|
||||
|
||||
it 'upgrades ironic api packages' do
|
||||
expect(chef_run).to upgrade_package('ironic-api')
|
||||
end
|
||||
|
||||
describe 'ironic-api packages' do
|
||||
let(:package) { chef_run.package('ironic-api') }
|
||||
|
||||
it 'sends a notification to the service' do
|
||||
expect(package).to notify('service[ironic-api]').to(:restart)
|
||||
end
|
||||
end
|
||||
|
||||
it 'enables ironic api on boot' do
|
||||
expect(chef_run).to enable_service('ironic-api')
|
||||
end
|
||||
|
||||
describe 'ironic-api' do
|
||||
let(:service) { chef_run.service('ironic-api') }
|
||||
|
||||
it 'subscribes to the template creation' do
|
||||
expect(service).to subscribe_to('template[/etc/ironic/ironic.conf]')
|
||||
end
|
||||
|
||||
it 'subscribes to the common packages' do
|
||||
expect(service).to subscribe_to('package[python-ironicclient]')
|
||||
end
|
||||
end
|
||||
|
||||
it 'runs db migrations' do
|
||||
expect(chef_run).to run_execute('ironic db sync').with(user: 'ironic', group: 'ironic')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,63 @@
|
|||
# Encoding: utf-8
|
||||
#
|
||||
# Cookbook Name:: openstack-bare-metal
|
||||
# Spec:: conductor_spec
|
||||
#
|
||||
# Copyright 2015, IBM Corp.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-bare-metal::conductor' do
|
||||
describe 'ubuntu' do
|
||||
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
include_context 'bare-metal-stubs'
|
||||
|
||||
it 'includes ironic common recipe' do
|
||||
expect(chef_run).to include_recipe('openstack-bare-metal::ironic-common')
|
||||
end
|
||||
|
||||
it 'upgrades ironic api packages' do
|
||||
expect(chef_run).to upgrade_package('ironic-conductor')
|
||||
end
|
||||
|
||||
describe 'ironic-conductor packages' do
|
||||
let(:package) { chef_run.package('ironic-conductor') }
|
||||
|
||||
it 'sends a notification to the service' do
|
||||
expect(package).to notify('service[ironic-conductor]').to(:restart)
|
||||
end
|
||||
end
|
||||
|
||||
it 'enables ironic conductor on boot' do
|
||||
expect(chef_run).to enable_service('ironic-conductor')
|
||||
end
|
||||
|
||||
describe 'ironic-conductor' do
|
||||
let(:service) { chef_run.service('ironic-conductor') }
|
||||
|
||||
it 'subscribes to the template creation' do
|
||||
expect(service).to subscribe_to('template[/etc/ironic/ironic.conf]')
|
||||
end
|
||||
|
||||
it 'subscribes to the common packages' do
|
||||
expect(service).to subscribe_to('package[python-ironicclient]')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,110 @@
|
|||
# Encoding: utf-8
|
||||
#
|
||||
# Cookbook Name:: openstack-bare-metal
|
||||
# Spec:: ironic_common_spec
|
||||
#
|
||||
# Copyright 2015, IBM Corp.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-bare-metal::ironic-common' do
|
||||
describe 'ubuntu' do
|
||||
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
include_context 'bare-metal-stubs'
|
||||
|
||||
it 'upgrades ironic client packages' do
|
||||
expect(chef_run).to upgrade_package('python-ironicclient')
|
||||
end
|
||||
|
||||
it 'upgrades mysql python package' do
|
||||
expect(chef_run).to upgrade_package('python-mysqldb')
|
||||
end
|
||||
|
||||
describe '/etc/ironic' do
|
||||
let(:dir) { chef_run.directory('/etc/ironic') }
|
||||
|
||||
it 'should create the directory' do
|
||||
expect(chef_run).to create_directory(dir.name)
|
||||
end
|
||||
|
||||
it 'has proper owner' do
|
||||
expect(dir.owner).to eq('ironic')
|
||||
expect(dir.group).to eq('ironic')
|
||||
end
|
||||
|
||||
it 'has proper modes' do
|
||||
expect(sprintf('%o', dir.mode)).to eq('750')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'ironic.conf' do
|
||||
let(:file) { chef_run.template('/etc/ironic/ironic.conf') }
|
||||
|
||||
it 'should create the ironic.conf template' do
|
||||
expect(chef_run).to create_template(file.name)
|
||||
end
|
||||
|
||||
it 'has proper owner' do
|
||||
expect(file.owner).to eq('ironic')
|
||||
expect(file.group).to eq('ironic')
|
||||
end
|
||||
|
||||
it 'has proper modes' do
|
||||
expect(sprintf('%o', file.mode)).to eq('640')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'rootwrap.conf' do
|
||||
let(:file) { chef_run.template('/etc/ironic/rootwrap.conf') }
|
||||
|
||||
it 'should create the /etc/ironic/rootwrap.conf file' do
|
||||
expect(chef_run).to create_template(file.name)
|
||||
end
|
||||
|
||||
it 'has proper owner' do
|
||||
expect(file.owner).to eq('root')
|
||||
expect(file.group).to eq('root')
|
||||
end
|
||||
|
||||
it 'has proper modes' do
|
||||
expect(sprintf('%o', file.mode)).to eq('644')
|
||||
end
|
||||
|
||||
context 'template contents' do
|
||||
it 'shows the custom banner' do
|
||||
node.set['openstack']['bare-metal']['custom_template_banner'] = 'banner'
|
||||
|
||||
expect(chef_run).to render_file(file.name).with_content(/^banner$/)
|
||||
end
|
||||
|
||||
it 'sets the default attributes' do
|
||||
[
|
||||
%r(^filters_path=/etc/ironic/rootwrap.d,/usr/share/ironic/rootwrap$),
|
||||
%r(^exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin$),
|
||||
/^use_syslog=false$/,
|
||||
/^syslog_log_facility=syslog$/,
|
||||
/^syslog_log_level=ERROR$/
|
||||
].each do |line|
|
||||
expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -20,3 +20,20 @@ UBUNTU_OPTS = {
|
|||
version: '14.04',
|
||||
log_level: ::LOG_LEVEL
|
||||
}
|
||||
|
||||
shared_context 'bare-metal-stubs' do
|
||||
before do
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
||||
.with('service', anything)
|
||||
.and_return('')
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
||||
.with('db', anything)
|
||||
.and_return('')
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
||||
.with('user', anything)
|
||||
.and_return('')
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:get_secret)
|
||||
.with('openstack_identity_bootstrap_token')
|
||||
.and_return('bootstrap-token')
|
||||
end
|
||||
end
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,29 @@
|
|||
<%= node['openstack']['bare-metal']['custom_template_banner'] %>
|
||||
|
||||
# Configuration for ironic-rootwrap
|
||||
# This file should be owned by (and only-writeable by) the root user
|
||||
|
||||
[DEFAULT]
|
||||
# List of directories to load filter definitions from (separated by ',').
|
||||
# These directories MUST all be only writeable by root !
|
||||
filters_path=<%= node['openstack']['bare-metal']['rootwrap']['filters_path'] %>
|
||||
|
||||
# List of directories to search executables in, in case filters do not
|
||||
# explicitely specify a full path (separated by ',')
|
||||
# If not specified, defaults to system PATH environment variable.
|
||||
# These directories MUST all be only writeable by root !
|
||||
exec_dirs=<%= node['openstack']['bare-metal']['rootwrap']['exec_dirs'] %>
|
||||
|
||||
# Enable logging to syslog
|
||||
# Default value is False
|
||||
use_syslog=<%= node['openstack']['bare-metal']['rootwrap']['use_syslog'] %>
|
||||
|
||||
# Which syslog facility to use.
|
||||
# Valid values include auth, authpriv, syslog, local0, local1...
|
||||
# Default value is 'syslog'
|
||||
syslog_log_facility=<%= node['openstack']['bare-metal']['rootwrap']['syslog_log_facility'] %>
|
||||
|
||||
# Which messages to log.
|
||||
# INFO means log all usage
|
||||
# ERROR means only log unsuccessful attempts
|
||||
syslog_log_level=<%= node['openstack']['bare-metal']['rootwrap']['syslog_log_level'] %>
|
Loading…
Reference in New Issue