diff --git a/files/default/policy.json b/files/default/policy.json new file mode 100644 index 00000000..373c5688 --- /dev/null +++ b/files/default/policy.json @@ -0,0 +1,3 @@ +{ + "context_is_admin": [["role:admin"]] +} diff --git a/metadata.rb b/metadata.rb index ca168abe..b100247b 100644 --- a/metadata.rb +++ b/metadata.rb @@ -26,6 +26,7 @@ end depends "database" depends "glance" depends "keystone" +depends "mongodb" depends "mysql" depends "openstack-utils" depends "openstack-common", ">= 0.1.4" @@ -33,3 +34,4 @@ depends "rabbitmq" depends "selinux" depends "sysctl" depends "yum" +depends "python" diff --git a/recipes/ceilometer-agent-central.rb b/recipes/ceilometer-agent-central.rb new file mode 100644 index 00000000..c69a2d62 --- /dev/null +++ b/recipes/ceilometer-agent-central.rb @@ -0,0 +1,34 @@ +# +# Cookbook Name:: nova +# Recipe:: ceilometer-agent-central +# +# Copyright 2012, AT&T +# +# 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 + +include_recipe "nova::ceilometer-common" + +bindir = '/usr/local/bin' +conf_switch = '--config-file /etc/ceilometer/ceilometer.conf' + +service "ceilometer-agent-central" do + service_name "ceilometer-agent-central" + action [:enable, :start] + start_command "nohup #{bindir}/ceilometer-agent-central #{conf_switch} &" + stop_command "pkill -f ceilometer-agent-central" +end diff --git a/recipes/ceilometer-agent-compute.rb b/recipes/ceilometer-agent-compute.rb new file mode 100644 index 00000000..85d4f7ec --- /dev/null +++ b/recipes/ceilometer-agent-compute.rb @@ -0,0 +1,34 @@ +# +# Cookbook Name:: nova +# Recipe:: ceilometer-agent-compute +# +# Copyright 2012, AT&T +# +# 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 + +include_recipe "nova::ceilometer-common" + +bindir = '/usr/local/bin' +conf_switch = '--config-file /etc/ceilometer/ceilometer.conf' + +service "ceilometer-agent-compute" do + service_name "ceilometer-agent-compute" + action [:enable, :start] + start_command "nohup #{bindir}/ceilometer-agent-compute #{conf_switch}&" + stop_command "pkill -f ceilometer-agent-compute" +end diff --git a/recipes/ceilometer-api.rb b/recipes/ceilometer-api.rb new file mode 100644 index 00000000..b46dbee7 --- /dev/null +++ b/recipes/ceilometer-api.rb @@ -0,0 +1,35 @@ +# +# Cookbook Name:: nova +# Recipe:: ceilometer-api +# +# Copyright 2012, AT&T +# +# 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 + +include_recipe "nova::ceilometer-common" + +bindir = '/usr/local/bin' +logdir = '/var/log/ceilometer-api' +conf_switch = '--config-file /etc/ceilometer/ceilometer.conf' + +service "ceilometer-api" do + service_name "ceilometer-api" + action [:enable, :start] + start_command "nohup #{bindir}/ceilometer-api -d --log-dir=#{logdir} #{conf_switch} &" + stop_command "pkill -f ceilometer-api" +end diff --git a/recipes/ceilometer-collector.rb b/recipes/ceilometer-collector.rb new file mode 100644 index 00000000..3ade1253 --- /dev/null +++ b/recipes/ceilometer-collector.rb @@ -0,0 +1,34 @@ +# +# Cookbook Name:: nova +# Recipe:: ceilometer-collector +# +# Copyright 2012, AT&T +# +# 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 + +include_recipe "nova::ceilometer-common" + +bindir = '/usr/local/bin' +conf_switch = '--config-file /etc/ceilometer/ceilometer.conf' + +service "ceilometer-collector" do + service_name "ceilometer-collector" + action [:enable, :start] + start_command "nohup #{bindir}/ceilometer-collector #{conf_switch} &" + stop_command "pkill -f ceilometer-collector" +end diff --git a/recipes/ceilometer-common.rb b/recipes/ceilometer-common.rb new file mode 100644 index 00000000..70a6cca0 --- /dev/null +++ b/recipes/ceilometer-common.rb @@ -0,0 +1,93 @@ +# +# Cookbook Name:: nova +# Recipe:: ceilometer-common +# +# Copyright 2012, AT&T +# +# 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 + +include_recipe "mongodb" +include_recipe "nova::nova-common" +include_recipe "python::pip" + +api_logdir = '/var/log/ceilometer-api' +nova_owner = node["nova"]["user"] +nova_group = node["nova"]["group"] + +directory api_logdir do + owner nova_owner + group nova_group + mode 00755 + + action :create +end + +python_pip "ceilometer" do + action :install +end + +directory "/etc/ceilometer" do + owner nova_owner + group nova_group + mode 00755 + + action :create +end + +rabbit_server_role = node["nova"]["rabbit_server_chef_role"] +rabbit_info = config_by_role rabbit_server_role, "queue" + +nova_setup_role = node["nova"]["nova_setup_chef_role"] +nova_setup_info = config_by_role nova_setup_role, "nova" + +db_user = node['nova']['db']['username'] +db_pass = db_password "nova" +sql_connection = db_uri("compute", db_user, db_pass) + +keystone_service_role = node["nova"]["keystone_service_chef_role"] +keystone = config_by_role keystone_service_role, "keystone" + +# find the node attribute endpoint settings for the server holding a given role +identity_admin_endpoint = endpoint "identity-admin" + +Chef::Log.debug("nova::ceilometer-common:rabbit_info|#{rabbit_info}") +Chef::Log.debug("nova::ceilometer-common:keystone|#{keystone}") +Chef::Log.debug("nova::ceilometer-common:identity_admin_endpoint|#{identity_admin_endpoint.to_s}") + +template "/etc/ceilometer/ceilometer.conf" do + source "ceilometer.conf.erb" + owner nova_owner + group nova_group + mode 00644 + variables( + :sql_connection => sql_connection, + :rabbit_ipaddress => rabbit_info["host"], + :rabbit_port => rabbit_info["port"], + :user => keystone["admin_user"], + :tenant => keystone["users"][keystone["admin_user"]]["default_tenant"], + :password => keystone["users"][keystone["admin_user"]]["password"], + :identity_admin_endpoint => identity_admin_endpoint + ) +end + +cookbook_file "/etc/ceilometer/policy.json" do + source "policy.json" + mode 0755 + owner nova_owner + group nova_group +end diff --git a/templates/default/ceilometer.conf.erb b/templates/default/ceilometer.conf.erb new file mode 100644 index 00000000..49059f73 --- /dev/null +++ b/templates/default/ceilometer.conf.erb @@ -0,0 +1,19 @@ +[DEFAULT] +os_auth_url = <%= @identity_admin_endpoint %> +os_tenant_name = <%= @tenant %> +os_password = <%= @password %> +os_username = <%= @user %> +policy_file = /etc/ceilometer/policy.json +sql_connection = <%= @sql_connection %> +rabbit_password = guest +rabbit_port = <%= @rabbit_port %> +rabbit_host = <%= @rabbit_ipaddress %> +verbose = True +notification_topics = notifications,glance_notifications +rpc_backend = ceilometer.openstack.common.rpc.impl_kombu + +[keystone_authtoken] +admin_tenant_name = <%= @tenant %> +admin_password = <%= @password %> +admin_user = <%= @user %> +auth_protocol = <%= @identity_endpoint.scheme %>