From f63fde7ab363ab6b0eeae3db022f7a8efab54074 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Charlier?= Date: Sat, 20 Apr 2013 03:46:05 +0200 Subject: [PATCH] Fix lint errors, add some documentation --- manifests/agent/compute.pp | 14 ++++++++- manifests/api.pp | 16 ++++++++++ manifests/db/mysql.pp | 24 +++++++++++++-- manifests/db/mysql/host_access.pp | 17 ++++++++--- manifests/init.pp | 49 ++++++++++++++++++++++++----- manifests/keystone/auth.pp | 51 +++++++++++++++++++++---------- manifests/params.pp | 9 ++++-- 7 files changed, 145 insertions(+), 35 deletions(-) diff --git a/manifests/agent/compute.pp b/manifests/agent/compute.pp index 96a428d..27cf6fd 100644 --- a/manifests/agent/compute.pp +++ b/manifests/agent/compute.pp @@ -1,3 +1,14 @@ +# The ceilometer::agent::compute class installs the ceilometer compute agent +# Include this class on all nova compute nodes +# +# == Parameters +# * auth_url: the keystone public endpoint +# *auth_region: the keystone region of this compute node +# *auth_user: the keystone user for ceilometer services +# *auth_password: the keystone password for ceilometer services +# *auth_tenant_name: the keystone tenant name for ceilometer services +# *auth_tenant_id (optional): the keystone tenant id for ceilometer services +# *enabled: should the service be started or not # class ceilometer::agent::compute ( $auth_url = 'http://localhost:5000/v2.0', @@ -69,7 +80,8 @@ class ceilometer::agent::compute ( file_line { 'nova-notification-driver-common': - line => 'notification_driver=nova.openstack.common.notifier.rabbit_notifier', + line => + 'notification_driver=nova.openstack.common.notifier.rabbit_notifier', path => '/etc/nova/nova.conf', notify => Service['nova-compute']; 'nova-notification-driver-ceilometer': diff --git a/manifests/api.pp b/manifests/api.pp index 5136d18..f020dd9 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -1,4 +1,20 @@ +# Installs & configure the ceilometer api service # +# == Parameters +# $enabled: should the service be enabled +# Optional. Defaults to true +# $keystone_host: keystone's admin endpoint IP/Host +# Optional. Defaults to 127.0.0.1 +# $keystone_port: keystone's admin endpoint port +# Optional. Defaults to 35357 +# $keystone_protocol: http/https +# Optional. Defaults to https +# $keytone_user: user to authenticate with +# Optional. Defaults to ceilometer +# $keystone_tenant: tenant to authenticate with +# Optional. Defaults to services +# $keystone_password: password to authenticate with +# Mandatory. class ceilometer::api ( $enabled = true, $keystone_host = '127.0.0.1', diff --git a/manifests/db/mysql.pp b/manifests/db/mysql.pp index 5a03411..82b4182 100644 --- a/manifests/db/mysql.pp +++ b/manifests/db/mysql.pp @@ -1,5 +1,23 @@ +# The ceilometer::db::mysql class creates a MySQL database for ceilometer. +# It must be used on the MySQL server +# +# == Parameters +# +# $password: password to connect to the database +# Mandatory. +# $dbname: name of the database +# Optional. Defaults to ceilometer. +# $user: user to connect to the database +# Optional. Defaults to ceilometer. +# $host: the default source host user is allowed to connect from +# Optional. Defaults to 'localhost' +# $allowed_hosts: other hosts the user is allowd to connect from +# Optional. Defaults to undef. +# $charset: the database charset +# Optional. Defaults to 'latin1' + class ceilometer::db::mysql( - $password, + $password = undef, $dbname = 'ceilometer', $user = 'ceilometer', $host = 'localhost', @@ -11,6 +29,8 @@ class ceilometer::db::mysql( Class['ceilometer::db::mysql'] -> Exec<| title == 'ceilometer-dbsync' |> Mysql::Db[$dbname] ~> Exec<| title == 'ceilometer-dbsync' |> + #FIXME: ensure password is not empty + mysql::db { $dbname: user => $user, password => $password, @@ -20,7 +40,7 @@ class ceilometer::db::mysql( } if $allowed_hosts { - ceilometer::db::mysql::host_access { $allowed_hosts: + ceilometer::db::mysql::host_access { $allowed_hosts: user => $user, password => $password, database => $dbname, diff --git a/manifests/db/mysql/host_access.pp b/manifests/db/mysql/host_access.pp index af16da7..cd2dac1 100644 --- a/manifests/db/mysql/host_access.pp +++ b/manifests/db/mysql/host_access.pp @@ -1,13 +1,20 @@ +# Allow a user to access the ceilometer database +# +# == Parameters +# * namevar: the host to allow +# * user: username to allow +# * password: user password +# * database: the database name define ceilometer::db::mysql::host_access ($user, $password, $database) { database_user { "${user}@${name}": password_hash => mysql_password($password), - provider => 'mysql', - require => Database[$database], + provider => 'mysql', + require => Database[$database], } database_grant { "${user}@${name}/${database}": # TODO figure out which privileges to grant. - privileges => "all", - provider => 'mysql', - require => Database_user["${user}@${name}"] + privileges => 'all', + provider => 'mysql', + require => Database_user["${user}@${name}"] } } diff --git a/manifests/init.pp b/manifests/init.pp index a9aa5c8..e581e49 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,17 +1,45 @@ +# Class ceilometer # -class ceilometer ( - $metering_secret, +# ceilometer base package & configuration +# +# == parameters +# $metering_secret: secret key for signing messages +# Mandatory. +# $package_ensure: ensure state for package. +# Optional. Defaults to 'present' +# $verbose: should the daemons log verbose messages +# Optional. Defaults to 'False' +# $debug: should the daemons log debug messages +# Optional. Defaults to 'False' +# $rabbit_host: ip or hostname of the rabbit server +# Optional. Defaults to '127.0.0.1' +# $rabbit_port: port of the rabbit server +# Optional. Defaults to 5672. +# $rabbit_hosts: array of host:port (used with HA queues) +# Optional. Defaults to undef. +# If defined, will remove rabbit_host & rabbit_port parameters from config +# $rabbit_userid: user to connect to the rabbit server +# Optional. Defaults to 'guest' +# $rabbit_password: password to connect to the rabbit_server +# Optional. Defaults to empty string. +# $rabbit_virtualhost: virtualhost to use +# Optional. Defaults to '/' +# +class ceilometer( + $metering_secret = undef, $package_ensure = 'present', $verbose = 'False', $debug = 'False', $rabbit_host = '127.0.0.1', - $rabbit_hosts = undef, $rabbit_port = 5672, + $rabbit_hosts = undef, $rabbit_userid = 'guest', $rabbit_password = '', $rabbit_virtualhost = '/', ) { + #FIXME: ensure metering_secret is non-empty + include ceilometer::params File { @@ -54,17 +82,21 @@ class ceilometer ( if $rabbit_hosts { ceilometer_config { 'DEFAULT/rabbit_host': ensure => absent } ceilometer_config { 'DEFAULT/rabbit_port': ensure => absent } - ceilometer_config { 'DEFAULT/rabbit_hosts': value => join($rabbit_hosts, ',') } + ceilometer_config { 'DEFAULT/rabbit_hosts': + value => join($rabbit_hosts, ',') + } } else { ceilometer_config { 'DEFAULT/rabbit_host': value => $rabbit_host } ceilometer_config { 'DEFAULT/rabbit_port': value => $rabbit_port } - ceilometer_config { 'DEFAULT/rabbit_hosts': value => "${rabbit_host}:${rabbit_port}" } + ceilometer_config { 'DEFAULT/rabbit_hosts': + value => "${rabbit_host}:${rabbit_port}" + } } if size($rabbit_hosts) > 1 { - ceilometer_config { 'DEFAULT/rabbit_ha_queues': value => 'true' } + ceilometer_config { 'DEFAULT/rabbit_ha_queues': value => true } } else { - ceilometer_config { 'DEFAULT/rabbit_ha_queues': value => 'false' } + ceilometer_config { 'DEFAULT/rabbit_ha_queues': value => false } } ceilometer_config { @@ -81,7 +113,8 @@ class ceilometer ( # Add glance-notifications topic. # Fixed in glance https://github.com/openstack/glance/commit/2e0734e077ae # Fix will be included in Grizzly - 'DEFAULT/notification_topics' : value => 'notifications,glance_notifications'; + 'DEFAULT/notification_topics' : + value => 'notifications,glance_notifications'; } } diff --git a/manifests/keystone/auth.pp b/manifests/keystone/auth.pp index 1a81521..c5b2a14 100644 --- a/manifests/keystone/auth.pp +++ b/manifests/keystone/auth.pp @@ -3,22 +3,35 @@ # # == Parameters: # -# $auth_name :: identifier used for all keystone objects related to ceilometer. -# Optional. Defaults to ceilometer. -# $password :: password for ceilometer user. Optional. Defaults to glance_password. -# $service_type :: type of service to create. Optional. Defaults to image. -# $public_address :: Public address for endpoint. Optional. Defaults to 127.0.0.1. -# $admin_address :: Admin address for endpoint. Optional. Defaults to 127.0.0.1. -# $inernal_address :: Internal address for endpoint. Optional. Defaults to 127.0.0.1. -# $port :: Port for endpoint. Needs to match ceilometer api service port. Optional. -# Defaults to 8777. -# $region :: Region where endpoint is set. +# $password: ceilometer user's password +# Mandatory +# $email: ceilometer user's email +# Optional. +# $auth_name: username +# Optional. Defaults to 'ceilometer'. +# $service_type: type of service to create. +# Optional. Defaults to 'metering'. +# $public_address: Public address for endpoint. +# Optional. Defaults to 127.0.0.1. +# $admin_address: Admin address for endpoint. +# Optional. Defaults to 127.0.0.1. +# $internal_address: Internal address for endpoint. +# Optional. Defaults to 127.0.0.1. +# $port: Port for endpoint. Needs to match ceilometer api service port. +# Optional. Defaults to 8777. +# $region: Region where endpoint is set. +# Optional. Defaults to 'RegionOne'. +# $tenant: Service tenant name. +# Optional. Defaults to 'services'. +# $public_protocol: http/https. +# Optional. Defaults to 'http'. +# $configure_endpoint: should the endpoint be created in keystone ? +# Optional. Defaults to true # class ceilometer::keystone::auth( - $password, + $password = undef, $email = 'ceilometer@localhost', $auth_name = 'ceilometer', - $configure_endpoint = true, $service_type = 'metering', $public_address = '127.0.0.1', $admin_address = '127.0.0.1', @@ -26,10 +39,16 @@ class ceilometer::keystone::auth( $port = '8777', $region = 'RegionOne', $tenant = 'services', - $public_protocol = 'http' + $public_protocol = 'http', + $admin_protocol = 'http', + $internal_protocol = 'http', + $configure_endpoint = true ) { - Keystone_user_role["${auth_name}@${tenant}"] ~> Service <| name == 'ceilometer' |> + #FIXME: ensure $password is not empty + + Keystone_user_role["${auth_name}@${tenant}"] ~> + Service <| name == 'ceilometer' |> keystone_user { $auth_name: ensure => present, @@ -56,8 +75,8 @@ class ceilometer::keystone::auth( keystone_endpoint { "${region}/${auth_name}": ensure => present, public_url => "${public_protocol}://${public_address}:${port}", - admin_url => "http://${admin_address}:${port}", - internal_url => "http://${internal_address}:${port}", + admin_url => "${admin_protocol}://${admin_address}:${port}", + internal_url => "${internal_protocol}://${internal_address}:${port}", } } } diff --git a/manifests/params.pp b/manifests/params.pp index dfcdf8e..e1c70ff 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,7 +1,8 @@ -# +# Parameters for puppet-ceilometer class ceilometer::params { - $dbsync_command = 'ceilometer-dbsync --config-file=/etc/ceilometer/ceilometer.conf' + $dbsync_command = + 'ceilometer-dbsync --config-file=/etc/ceilometer/ceilometer.conf' $log_dir = '/var/log/ceilometer' case $::osfamily { @@ -43,7 +44,9 @@ class ceilometer::params { } } default: { - fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} only support osfamily RedHat and Debian") + fail("Unsupported osfamily: ${::osfamily} operatingsystem: \ +${::operatingsystem}, module ${module_name} only support osfamily \ +RedHat and Debian") } } } -- 2.45.2