Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -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.*/
15 changes: 3 additions & 12 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
46 changes: 24 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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]`.

Expand All @@ -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
```
Expand All @@ -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
```

Expand Down Expand Up @@ -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
```
Expand All @@ -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
```

Expand Down
12 changes: 0 additions & 12 deletions Thorfile

This file was deleted.

31 changes: 24 additions & 7 deletions libraries/cloudstack_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
55 changes: 0 additions & 55 deletions libraries/database.rb

This file was deleted.

12 changes: 6 additions & 6 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Loading