From 12671c255d6919d536fb4463b6e93f6d298a8b57 Mon Sep 17 00:00:00 2001 From: Craig Bryant Date: Wed, 3 Sep 2014 21:49:02 -0600 Subject: [PATCH] Changes to use monasca instead of mon Changed to use monasca_api instead of mon_api. Added monasca_api user to group monasca so the api can write to /var/log/monasca and read the config file in /etc/monasca Change data bag names to monasca_api instead of mon_api Place jar file in /opt/monasca Change service name from mon-api to monasca-api Change-Id: Ic2a8db0b6b1451872f42373077cf5f2911de3652 --- README.md | 2 +- attributes/backup.rb | 4 -- attributes/default.rb | 6 +-- attributes/ufw.rb | 16 -------- metadata.rb | 6 +-- recipes/default.rb | 37 ++++++++++++------- ...vice-config.yml.erb => api-config.yml.erb} | 6 +-- 7 files changed, 33 insertions(+), 44 deletions(-) delete mode 100644 attributes/backup.rb delete mode 100644 attributes/ufw.rb rename templates/default/{mon-service-config.yml.erb => api-config.yml.erb} (94%) diff --git a/README.md b/README.md index 5004064..321ba10 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ Also included is an icinga check for the service health check. Using Vertica ------------ -If Vertica is used as the database for Monasca, the Vertica JDBC jar that matches the Vertica version must be placed in /opt/mon/vertica. The jar from Vertica will be named like vertica-jdbc-7.0.1-0.jar and must be renamed to vertica_jdbc.jar when placed in /opt/mon/vertica. You can find the Vertica JDBC jar in /opt/vertica/java on a system with the Vertica database installed. This cookbook will copy the Vertica JDBC Jar from /vagrant and place it in /opt/mon/vertica if run using Chef Solo. +If Vertica is used as the database for Monasca, the Vertica JDBC jar that matches the Vertica version must be placed in /opt/monasca/vertica. The jar from Vertica will be named like vertica-jdbc-7.0.1-0.jar and must be renamed to vertica_jdbc.jar when placed in /opt/monasca/vertica. You can find the Vertica JDBC jar in /opt/vertica/java on a system with the Vertica database installed. This cookbook will copy the Vertica JDBC Jar from /vagrant and place it in /opt/monasca/vertica if run using Chef Solo. diff --git a/attributes/backup.rb b/attributes/backup.rb deleted file mode 100644 index 5c80c49..0000000 --- a/attributes/backup.rb +++ /dev/null @@ -1,4 +0,0 @@ -# encoding: UTF-8# -# -# Logs to backup -node.default[:mon_log_backup][:logs][:som_api] = ['/var/log/som-api/'] diff --git a/attributes/default.rb b/attributes/default.rb index 1e6c3ff..0fafca5 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,5 +1,5 @@ # encoding: UTF-8# # -node.default[:mon_api][:group] = 'mon_api' -node.default[:mon_api][:owner] = 'mon_api' -node.default[:mon_api][:data_bag] = 'mon_api' +node.default[:monasca_api][:group] = 'monasca' +node.default[:monasca_api][:owner] = 'monasca_api' +node.default[:monasca_api][:data_bag] = 'monasca_api' diff --git a/attributes/ufw.rb b/attributes/ufw.rb deleted file mode 100644 index 21e9bbd..0000000 --- a/attributes/ufw.rb +++ /dev/null @@ -1,16 +0,0 @@ -# encoding: UTF-8# -# -default[:som_api][:firewall][:rules] = [ - https: { - port: '443', - protocol: 'tcp' - }, - https_8080: { - port: '8080', - protocol: 'tcp' - }, - http_8081: { - port: '8081', - protocol: 'tcp' - } -] diff --git a/metadata.rb b/metadata.rb index 8a8df23..1d226da 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,9 +1,9 @@ # encoding: UTF-8# # -name 'mon_api' +name 'monasca_api' maintainer 'Monasca Team' maintainer_email 'monasca@lists.launchpad.net' license 'All rights reserved' -description 'Installs/Configures mon_api' +description 'Installs/Configures the Monasca API' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '0.0.13' +version '0.0.14' diff --git a/recipes/default.rb b/recipes/default.rb index 4466d7d..83ef11b 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -1,44 +1,53 @@ # encoding: UTF-8# # -package 'mon-api' do +group node[:monasca_api][:group] do + action :create +end +user node[:monasca_api][:owner] do + action :create + system true + gid node[:monasca_api][:group] +end + +package 'monasca-api' do action :upgrade end -service 'mon-api' do +service 'monasca-api' do action :enable provider Chef::Provider::Service::Upstart end -directory '/var/log/mon-api' do +directory '/var/log/monasca' do recursive true - owner node[:mon_api][:owner] - group node[:mon_api][:group] - mode 0755 + owner node[:monasca_api][:owner] + group node[:monasca_api][:group] + mode 0775 action :create end -creds = data_bag_item(node[:mon_api][:data_bag], 'mon_credentials') -setting = data_bag_item(node[:mon_api][:data_bag], 'mon_api') +creds = data_bag_item(node[:monasca_api][:data_bag], 'credentials') +setting = data_bag_item(node[:monasca_api][:data_bag], 'monasca_api') # Create the config file -template '/etc/mon/mon-api-config.yml' do +template '/etc/monasca/api-config.yml' do action :create owner 'root' - group node[:mon_api][:group] + group node[:monasca_api][:group] mode '640' - source 'mon-service-config.yml.erb' + source 'api-config.yml.erb' variables( creds: creds, setting: setting ) - notifies :restart, 'service[mon-api]' + notifies :restart, 'service[monasca-api]' end if setting['database-configuration']['database-type'] == 'vertica' # Create the directory for the vertica JDBC jar - directory '/opt/mon/vertica' do + directory '/opt/monasca/vertica' do recursive true owner 'root' group 'root' @@ -50,7 +59,7 @@ if setting['database-configuration']['database-type'] == 'vertica' bash 'vertica_jdbc.jar' do action :run code <<-EOL - DEST=/opt/mon/vertica/vertica_jdbc.jar + DEST=/opt/monasca/vertica/vertica_jdbc.jar if [ ! -s ${DEST} ]; then SRC=`ls /vagrant/vertica-jdbc-*.jar` if [ $? != 0 ]; then diff --git a/templates/default/mon-service-config.yml.erb b/templates/default/api-config.yml.erb similarity index 94% rename from templates/default/mon-service-config.yml.erb rename to templates/default/api-config.yml.erb index d7b4636..d0d1dc3 100644 --- a/templates/default/mon-service-config.yml.erb +++ b/templates/default/api-config.yml.erb @@ -70,7 +70,7 @@ influxDB: password: <%=@creds['influxdb']['password'] %> # Uncomment if databaseType is vertica -# As of 7/10 there is a bug in the mon-api that requires this section even if databaseType is set to influxdb +# As of 7/10 there is a bug in the monasca-api that requires this section even if databaseType is set to influxdb vertica: driverClass: com.vertica.jdbc.Driver url: jdbc:vertica://localhost/mon @@ -131,10 +131,10 @@ logging: logFormat: # TODO - type: file - currentLogFilename: /var/log/mon-api/mon-api.log + currentLogFilename: /var/log/monasca/monasca-api.log threshold: ALL archive: true - archivedLogFilenamePattern: /var/log/mon-api/mon-api-%d.log.gz + archivedLogFilenamePattern: /var/log/monasca/monasca-api-%d.log.gz archivedFileCount: 5 timeZone: UTC logFormat: # TODO