diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..af6dee9 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,94 @@ +defaults: &defaults + docker: + - image: chef/chefdk + working_directory: ~/cookbook/cookbook_cloudstack + +version: 2 +jobs: + checkout: + <<: *defaults + steps: + - checkout + - save_cache: + key: repo-{{ .Environment.CIRCLE_SHA1 }} + paths: + - ~/cookbook/cookbook_cloudstack + + cookstyle: + <<: *defaults + steps: + - restore_cache: + key: repo-{{ .Environment.CIRCLE_SHA1 }} + - run: chef --version + - run: chef exec cookstyle . + + foodcritic: + <<: *defaults + steps: + - restore_cache: + key: repo-{{ .Environment.CIRCLE_SHA1 }} + - run: chef --version + - run: chef exec foodcritic . + + chefspec: + <<: *defaults + steps: + - restore_cache: + key: repo-{{ .Environment.CIRCLE_SHA1 }} + - run: chef --version + - run: chef exec rspec spec + + kitchen: + machine: + services: + - docker + working_directory: ~/cookbook/cookbook_cloudstack + steps: + - checkout + - run: | + if ! chef -v; then + wget https://packages.chef.io/files/stable/chefdk/3.5.13/ubuntu/18.04/chefdk_3.5.13-1_amd64.deb + sudo dpkg -i chefdk_3.5.13-1_amd64.deb + fi + - run: chef --version + - run: bundle install + - run: berks install + - run: berks update + - run: KITCHEN_LOCAL_YAML=.kitchen.docker.yml kitchen test --destroy always + +workflows: + version: 2 + build: + jobs: + - checkout: + filters: + tags: + only: /v.*/ + + - cookstyle: + requires: + - checkout + filters: + tags: + only: /v.*/ + + - foodcritic: + requires: + - checkout + filters: + tags: + only: /v.*/ + + - chefspec: + requires: + - checkout + filters: + tags: + only: /v.*/ + + - kitchen: + requires: + - checkout + filters: + tags: + only: /v.*/ diff --git a/.kitchen.yml b/.kitchen.yml index e3698f3..211d4e5 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -6,20 +6,11 @@ provisioner: name: chef_solo platforms: - - name: ubuntu-14.04 - - name: centos-6.6 - - name: centos-7.1 +# - name: ubuntu-16.04 + - name: centos-7 suites: - name: default run_list: - - recipe[cloudstack::management_server] - - recipe[cloudstack::usage] + - recipe[cloudstack::circle-ci] attributes: - - name: acs46 - run_list: - - recipe[cloudstack::management_server] - - recipe[cloudstack::usage] - attributes: - cloudstack: - release_major: '4.6' diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d3e4d1..652b3f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ cloudstack CHANGELOG This file is used to list changes made in each version of the co-cloudstack cookbook. +6.0.0 +----- +- pdion891 - Fix Chef14 issues on CentOS 7 for cloudstack_setup_database ressource. + - Added circle-ci recipe for automated CI. + - Remove management of sudoers file, pkgs are taking care of it. + 5.0.0 ----- - pdion891 - update default version to 4.11. diff --git a/README.md b/README.md index 7fa796c..209b8c6 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ # CloudStack Cookbook -Install and configure [Apache Cloudstack](http://cloudstack.apache.org) using [Chef](http://www.chef.io/). A wrapper cookbook is prefered in order to Install Apache CloudStack properly, refer to [cloudstack_wrapper cookbook](https://github.com/cloudops/cookbook_cloudstack_wrapper) for example. +[![Build Status](https://circleci.com/gh/cloudops/cookbook_cloudstack.svg?style=svg)](https://circleci.com/gh/cloudops/cookbook_cloudstack) +[![Cookbook Version](https://img.shields.io/cookbook/v/cloudstack.svg)](https://supermarket.chef.io/cookbooks/cloudstack) -Work with Chef 12 only. +Install and configure [Apache Cloudstack](http://cloudstack.apache.org) using [Chef](http://www.chef.io/). A wrapper cookbook is prefered in order to Install Apache CloudStack properly, refer to [cloudstack_wrapper cookbook](https://github.com/cloudops/cookbook_cloudstack_wrapper) for example. -Tested on CentOS 7 and Ubuntu 16.04 +Tested on CentOS 7 +Some parts work with Ubuntu 16.04 but this cookbook does not perform all configuraiton required for CloudStack Management-server on Ubuntu. ## Table of Contents @@ -42,7 +44,7 @@ More info on: http://cloudstack.apache.org/ - `yum` - packages management - `apt` - packages management - `mysql` - for MySQL database server and client -- `sudo` - to configure sudoers for user "cloud" +- `sudo` - to configure sudoers for user `cloud` There is a dependency on Ruby gem [cloudstack_ruby_client](https://github.com/chipchilders/cloudstack_ruby_client) for chef which is handle in `recipe[cloudstack::default]`. @@ -54,18 +56,18 @@ Create MySQL database and connection configuration used by CloudStack management ```ruby # Using attributes -cloudstack_setup_database node["cloudstack"]["db"]["host"] do - root_user node["cloudstack"]["db"]["rootusername"] - root_password node["cloudstack"]["db"]["rootpassword"] - user node["cloudstack"]["db"]["username"] - password node["cloudstack"]["db"]["password"] +cloudstack_setup_database node['cloudstack']['db']['host'] do + root_user node['cloudstack']['db']['rootusername'] + root_password node['cloudstack']['db']['rootpassword'] + user node['cloudstack']['db']['username'] + password node['cloudstack']['db']['password'] action :create end ``` ```ruby # using mysql cookbook and CloudStack default passwords -cloudstack_setup_database node["cloudstack"]["db"]["host"] do +cloudstack_setup_database node['cloudstack']['db']['host'] do action :create end ``` @@ -78,11 +80,11 @@ Download initial SystemVM template prior to initialize a CloudStack Region. clou # Using attributes cloudstack_system_template 'xenserver' do url node['cloudstack']['systemvm']['xenserver'] - nfs_path node["cloudstack"]["secondary"]["path"] - nfs_server node["cloudstack"]["secondary"]["host"] - db_user node["cloudstack"]["db"]["username"] - db_password node["cloudstack"]["db"]["password"] - db_host node["cloudstack"]["db"]["host"] + nfs_path node['cloudstack']['secondary']['path'] + nfs_server node['cloudstack']['secondary']['host'] + db_user node['cloudstack']['db']['username'] + db_password node['cloudstack']['db']['password'] + db_host node['cloudstack']['db']['host'] end ``` @@ -118,19 +120,19 @@ Generate api keys for account. Currently working only for admin account. Will update attributes: -- `node["cloudstack"]["admin"]["api_key"]` -- `node["cloudstack"]["admin"]["secret_key"]` +- `node['cloudstack']['admin']['api_key']` +- `node['cloudstack']['admin']['secret_key']` ``` ruby # Create API key if now exist in Cloudstack and update node attributes -cloudstack_api_keys "admin" do +cloudstack_api_keys 'admin' do action :create end ``` ``` ruby # Generate new API Keys -cloudstack_api_keys "admin" do +cloudstack_api_keys 'admin' do action :reset end ``` @@ -140,9 +142,9 @@ end Update Global Settings values. ``` ruby -cloudstack_global_setting "expunge.delay" do - value "80" - notifies :restart, "service[cloudstack-management]", :delayed +cloudstack_global_setting 'expunge.delay' do + value '80' + notifies :restart, 'service[cloudstack-management]', :delayed end ``` diff --git a/Thorfile b/Thorfile deleted file mode 100644 index 19aaaf2..0000000 --- a/Thorfile +++ /dev/null @@ -1,12 +0,0 @@ -# encoding: utf-8 - -require 'bundler' -require 'bundler/setup' -require 'berkshelf/thor' - -begin - require 'kitchen/thor_tasks' - Kitchen::ThorTasks.new -rescue LoadError - puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI'] -end diff --git a/libraries/cloudstack_helper.rb b/libraries/cloudstack_helper.rb index b3336f0..84bf8f3 100644 --- a/libraries/cloudstack_helper.rb +++ b/libraries/cloudstack_helper.rb @@ -41,15 +41,32 @@ def port_open(ip, port, seconds = 1) false end - # Test if CloudStack Database already exist + def verify_db_connection?(db_host = 'localhost', db_user = 'root', db_password = 'password') + # Make sure we can connect to db server + conn_db_test = "mysql -h #{db_host} -u #{db_user} -p#{db_password} -e 'show databases;'" + begin + if shell_out!(conn_db_test).error? + false + else + true + end + rescue + false + end + end + def db_exist?(db_host = 'localhost', db_user = 'cloud', db_password = 'password') + # Test if CloudStack Database already exist + # if fail to connect with db_user, return false; conn_db_test = "mysql -h #{db_host} -u #{db_user} -p#{db_password} -e 'show databases;'|grep cloud" - conn_db_test_out = Mixlib::ShellOut.new(conn_db_test) - conn_db_test_out.run_command - if conn_db_test_out.exitstatus == 0 - return true - else - return false + begin + if shell_out!(conn_db_test).error? + false + else + true + end + rescue + false end end diff --git a/libraries/database.rb b/libraries/database.rb deleted file mode 100644 index a249c73..0000000 --- a/libraries/database.rb +++ /dev/null @@ -1,55 +0,0 @@ -# -# Cookbook Name:: cloudstack -# Library:: database -# Author:: Pierre-Luc Dion -# Copyright 2018, CloudOps, 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. -# -include Chef::Mixin::ShellOut - -module Cloudstack - module Database - def init_database - # Create database in MySQL using cloudstack-setup-databases scripts - setup_db_init_cmd = "#{@scriptname} #{@current_resource.user}:#{@current_resource.password}@#{@current_resource.ip} --deploy-as=#{@current_resource.root_user}:#{@current_resource.root_password} -m #{@current_resource.management_server_key} -k #{@current_resource.database_key}" - cloudstack_setup_database = Mixlib::ShellOut.new(setup_db_init_cmd) - cloudstack_setup_database.run_command - if cloudstack_setup_database.exitstatus == 0 - end - end - - def init_config_database - # Create database configuration for cloudstack management server that will use and existing database. - setup_db_init_cmd = "#{@scriptname} #{@current_resource.user}:#{@current_resource.password}@#{@current_resource.ip} -m #{@current_resource.management_server_key} -k #{@current_resource.database_key}" - cloudstack_setup_database = Mixlib::ShellOut.new(setup_db_init_cmd) - cloudstack_setup_database.run_command - if cloudstack_setup_database.exitstatus == 0 - - end - end - - def dbconf_exist? - # test if db.properties as been modified from default installation file. if password encrypted, then we step there to not break anything. - Chef::Log.debug 'Checking to see if database config db.properties as been configured' - conf_exist = Mixlib::ShellOut.new('cat /etc/cloudstack/management/db.properties |grep "ENC("') - conf_exist.run_command - if conf_exist.exitstatus == 0 - return true - else - return false - end - end - end -end diff --git a/metadata.rb b/metadata.rb index ae64192..f7fd065 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,15 +4,15 @@ license 'Apache-2.0' description 'Installs/Configures cloudstack' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '5.0.0' +version '6.0.0' -source_url 'https://github.com/cloudops/cookbook_cloudstack' -issues_url 'https://github.com/cloudops/cookbook_cloudstack/issues' +source_url 'https://github.com/cloudops/cookbook_cloudstack' +issues_url 'https://github.com/cloudops/cookbook_cloudstack/issues' -depends 'yum', '> 3.0' -depends 'apt', '> 2.0' +depends 'yum' , '> 3.0' +depends 'apt' , '> 2.0' depends 'mysql', '~> 8.0' -depends 'sudo', '>= 2.6.0' +depends 'sudo' , '>= 2.6.0' supports 'centos' supports 'redhat' diff --git a/providers/setup_database.rb b/providers/setup_database.rb deleted file mode 100644 index 5dc6d9e..0000000 --- a/providers/setup_database.rb +++ /dev/null @@ -1,72 +0,0 @@ -# -# Cookbook Name:: cloudstack -# Provider:: setup_database -# Author:: Pierre-Luc Dion () -# Copyright 2018, CloudOps, 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. -# - -# include Chef::Mixin::ShellOut -include Cloudstack::Helper -include Cloudstack::Database - -use_inline_resources if defined?(:use_inline_resources) # ~FC113 - -action :create do - # load_current_resource - # Chef::Log.info 'creating cloudstack database' - unless @current_resource.exists - # 1. check if database exist, if so create connection config but do not init db. - # 2. if db not exist, create db and create connection - @scriptname = '/usr/bin/cloudstack-setup-databases' - if ::File.exist?(@scriptname) - if db_exist?(@current_resource.ip, @current_resource.user, @current_resource.password) - converge_by('Using existing CloudStack database') do - init_config_database - end - else - converge_by('Creating CloudStack database') do - init_database - end - end - else - Chef::Log.error "#{@scriptname} not found" - end - end -end - -def load_current_resource - @current_resource = Chef::Resource::CloudstackSetupDatabase.new(@new_resource.name) - @current_resource.name(@new_resource.name) - @current_resource.ip(@new_resource.ip) - @current_resource.user(@new_resource.user) - @current_resource.password(@new_resource.password) - @current_resource.root_user(@new_resource.root_user) - @current_resource.root_password(@new_resource.root_password) - @current_resource.management_server_key(@new_resource.management_server_key) - @current_resource.database_key(@new_resource.database_key) - - if cloudstack_is_running? - @current_resource.exists = true - elsif dbconf_exist? - if db_exist?(@current_resource.ip, @current_resource.user, @current_resource.password) - @current_resource.exists = true - else - Chef::Log.info 'Database server ready, not database found, creating it...' - @current_resource.exists = false - end - else - @current_resource.exists = false - end -end diff --git a/providers/setup_management.rb b/providers/setup_management.rb deleted file mode 100644 index 4312287..0000000 --- a/providers/setup_management.rb +++ /dev/null @@ -1,57 +0,0 @@ -# -# Cookbook Name:: cloudstack -# Provider:: setup_management -# Author:: Pierre-Luc Dion () -# Copyright 2018, CloudOps, 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. -# -# execute default cloudstack configuration script -############################################################################### - -# use_inline_resources - -# # Support whyrun -# def whyrun_supported? -# false -# end - -# action :run do -# load_current_resource - -# if !@current_resource.exists -# params = '' -# # params += ' --tomcat7' if @current_resource.tomcat7 -# # params += ' --https' if @current_resource.https -# # params += ' --no-start' if @current_resource.nostart - -# bash "cloudstack-setup-management" do -# code "/usr/bin/cloudstack-setup-management #{params}" -# not_if { ::File.exists?("/etc/cloudstack/management/tomcat6.conf") || ::File.exists?("/etc/cloudstack/management/server.xml")} -# end -# end - -# end - -# def load_current_resource -# @current_resource = Chef::Resource::CloudstackSetupDatabase.new(@new_resource.name) -# @current_resource.name(@new_resource.name) -# @current_resource.tomcat7(@new_resource.tomcat7) -# @current_resource.https(@new_resource.https) -# @current_resource.nostart(@new_resource.nostart) - -# # use tomcat7 if CentOS 7 -# # @current_resource.tomcat = true if node['platform'] == 'centos' && node['platform_version'] == '7' - -# @current_resource.exists = ::File.exists?("/etc/cloudstack/management/server.xml") -# end diff --git a/recipes/circle-ci.rb b/recipes/circle-ci.rb new file mode 100644 index 0000000..f1f9fd7 --- /dev/null +++ b/recipes/circle-ci.rb @@ -0,0 +1,51 @@ +# +# Cookbook Name:: cloudstack +# Recipe:: default +# Author:: Pierre-Luc Dion () +# Copyright 2018, CloudOps, Inc. +# +# kitchen test file + +include_recipe 'cloudstack::management_server' +include_recipe 'cloudstack::usage' + +# install mysql-server +package 'mariadb-server' + +execute 'set mysql root password' do + command 'mysqladmin -h 127.0.0.1 -u root password password' + action :nothing +end + +if platform?(%w(redhat centos fedora oracle)) + service 'mariadb' do + action :start + notifies :run, 'execute[set mysql root password]', :immediately + end +elsif platform?(%w(ubuntu debian)) + service 'mysql' do + action :start + notifies :run, 'execute[set mysql root password]', :immediately + end +end + +# init database and connection configuration +cloudstack_setup_database '127.0.0.1' do + root_user 'root' + root_password 'password' + user 'cloud' + password 'cloud' + action :create +end + +cloudstack_setup_management node.name do + tomcat7 true +end + +service 'cloudstack-management' do + action [ :enable, :start ] +end + +service 'cloudstack-usage' do + action [ :enable, :start ] +end diff --git a/recipes/management_server.rb b/recipes/management_server.rb index 029ab1c..5f1dfef 100644 --- a/recipes/management_server.rb +++ b/recipes/management_server.rb @@ -37,43 +37,3 @@ include_recipe 'cloudstack::vhd-util' -# -# Set nproc limits for user cloud -# -template node['cloudstack']['nproc_limit_file'] do - source 'nproc_limits.erb' - owner 'root' - group 'root' - mode 0755 - variables user: node['cloudstack']['username'], - hard: node['cloudstack']['nproc_limit_hard'], - soft: node['cloudstack']['nproc_limit_soft'], - recipe_file: __FILE__.to_s.split('cookbooks/').last, - template_file: source.to_s -end - -# -# Set nofile limits for user cloud -# -template node['cloudstack']['nofile_limit_file'] do - source 'nofile_limits.erb' - owner 'root' - group 'root' - mode 0755 - variables user: node['cloudstack']['username'], - hard: node['cloudstack']['nofile_limit_hard'], - soft: node['cloudstack']['nofile_limit_soft'], - recipe_file: __FILE__.to_s.split('cookbooks/').last, - template_file: source.to_s -end - -# Configure sudo for user cloud -include_recipe 'sudo' -sudo 'cloud' do - template 'sudoers_cloudstack.erb' -end - -# service 'cloudstack-management' do -# supports :restart => true, :status => true, :start => true, :stop => true -# action :nothing -# end diff --git a/resources/setup_database.rb b/resources/setup_database.rb index 595b4de..d0fc228 100644 --- a/resources/setup_database.rb +++ b/resources/setup_database.rb @@ -1,8 +1,8 @@ # # Cookbook Name:: cloudstack -# Resource:: init_db +# Resource:: setup_database # Author:: Pierre-Luc Dion () -# Copyright 2015, CloudOps, Inc. +# Copyright 2018, CloudOps, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,16 +16,62 @@ # See the License for the specific language governing permissions and # limitations under the License. -actions :create +# include Chef::Mixin::ShellOut default_action :create -attribute :ip, name_attribute: true, kind_of: String -attribute :user, kind_of: String, default: 'cloud' -attribute :password, kind_of: String, default: 'password' -attribute :root_user, kind_of: String, default: 'root' -attribute :root_password, kind_of: String, default: 'ilikerandompasswords' -attribute :management_server_key, kind_of: String, default: 'password' -attribute :database_key, kind_of: String, default: 'password' +property :ip, String, name_property: true +property :user, String, default: 'cloud' +property :password, String, default: 'password' +property :root_user, String, default: 'root' +property :root_password, String, default: 'ilikerandompasswords' +property :management_server_key, String, default: 'password' +property :database_key, String, default: 'password' -attr_accessor :exists +action :create do + unless dbconf_exist? + @scriptname = '/usr/bin/cloudstack-setup-databases' + if ::File.exist?(@scriptname) && verify_db_connection?(new_resource.ip, new_resource.root_user, new_resource.root_password) + if db_exist?(new_resource.ip, new_resource.user, new_resource.password) + converge_by('Using existing CloudStack database') do + init_config_database + end + else + converge_by('Creating CloudStack database') do + init_database + end + end + else + Chef::Log.error "#{@scriptname} not found or fail to connect to database." + end + end +end + +action_class do + include Cloudstack::Helper + + def init_database + # Create database in MySQL using cloudstack-setup-databases scripts + setup_db_init_cmd = "#{@scriptname} #{new_resource.user}:#{new_resource.password}@#{new_resource.ip} --deploy-as=#{new_resource.root_user}:#{new_resource.root_password} -m #{new_resource.management_server_key} -k #{new_resource.database_key}" + shell_out!(setup_db_init_cmd) + end + + def init_config_database + # Create database configuration for cloudstack management server that will use and existing database. + setup_db_init_cmd = "#{@scriptname} #{new_resource.user}:#{new_resource.password}@#{new_resource.ip} -m #{new_resource.management_server_key} -k #{new_resource.database_key}" + shell_out!(setup_db_init_cmd) + end + + def dbconf_exist? + # test if db.properties as been modified from default installation file. if password encrypted, then we step there to not break anything. + Chef::Log.debug 'Checking to see if database config db.properties as been configured' + conf_exist = Mixlib::ShellOut.new('cat /etc/cloudstack/management/db.properties |grep "ENC("') + conf_exist.run_command + if conf_exist.exitstatus == 0 + true + else + Chef::Log.debug 'db.properties does not contain encrypted passwords.' + false + end + end +end diff --git a/resources/setup_management.rb b/resources/setup_management.rb index 1b84565..d4966e1 100644 --- a/resources/setup_management.rb +++ b/resources/setup_management.rb @@ -21,20 +21,26 @@ ############################################################################### property :host, String, name_property: true -property :tomcat7, [true, false], required: false, default: false +property :tomcat7, [true, false], required: false, default: true property :https, [true, false], required: false, default: false property :nostart, [true, false], required: false, default: false -tomcat7 = true if node['platform'] == 'centos' && node['platform_version'].split('.')[0] == '7' - action :run do + new_resource.tomcat7 = true if node['platform'] == 'centos' && node['platform_version'].split('.')[0] == '7' params = '' - params += ' --tomcat7' if tomcat7 - params += ' --https' if https - params += ' --nostart' if nostart - - bash 'cloudstack-setup-management' do - code "/usr/bin/cloudstack-setup-management #{params}" - not_if { ::File.exist?('/etc/cloudstack/management/tomcat6.conf') || ::File.exist?('/etc/cloudstack/management/server.xml') } + params += ' --tomcat7' if new_resource.tomcat7 + params += ' --https' if new_resource.https + params += ' --nostart' if new_resource.nostart + unless ::File.exist?('/etc/cloudstack/management/tomcat6.conf') || ::File.exist?('/etc/cloudstack/management/server.xml') + converge_by('Configure embedded tomcat') do + bash 'cloudstack-setup-management' do + code <<-EOH + /usr/bin/cloudstack-setup-management #{params} + if [ ! -f /etc/cloudstack/management/server.xml ]; then + touch /etc/cloudstack/management/server.xml + fi + EOH + end + end end end diff --git a/test/integration/default/serverspec/management_spec.rb b/test/integration/default/serverspec/management_spec.rb index 10e0bc7..c63b94c 100644 --- a/test/integration/default/serverspec/management_spec.rb +++ b/test/integration/default/serverspec/management_spec.rb @@ -9,3 +9,31 @@ describe user('cloud') do it { should exist } end + +describe service('cloudstack-management') do + it { should be_enabled } + it { should be_running } +end + +describe file('/etc/cloudstack/management/server.xml') do + it { should be_file } + it { should exist } +end + +describe file('/etc/cloudstack/management/db.properties') do + it { should be_file } + it { should exist } +end + +describe file('/etc/cloudstack/management/key') do + it { should be_file } + it { should exist } +end + +describe file('/var/log/cloudstack/management') do + it { should be_directory } +end + +describe command('mysql -u root -h 127.0.0.1 -ppassword -e "show databases;"|grep cloud') do + its(:exit_status) { should eq 0 } +end