Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

WIP - Not ready for commit to repository yet. #36

Closed
wants to merge 10 commits into from
Closed
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
1 change: 1 addition & 0 deletions .foodcritic
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
~FC016
95 changes: 63 additions & 32 deletions .kitchen.docker.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,81 @@
settings:
parallel: true

driver:
name: docker
# privileged is required otherwise the container doesn't boot right
privileged: true
name: dokken
chef_version: latest
privileged: true # because Docker and SystemD/Upstart

transport:
name: dokken

provisioner:
name: dokken

verifier:
root_path: '/opt/verifier'
sudo: false

platforms:
- name: debian-8
driver:
image: debian:8
pid_one_command: /bin/systemd
run_list:
- recipe[apt]

- name: centos-5
driver:
image: centos:5

- name: centos-6
driver:
image: centos:6
platform: rhel
run_command: /sbin/init
provision_command:
- /usr/bin/yum install -y initscripts net-tools wget
intermediate_instructions:
- RUN yum -y install tar which initscripts

- name: centos-7
driver:
image: centos:7
platform: rhel
run_command: /usr/lib/systemd/systemd
provision_command:
- /bin/yum install -y initscripts net-tools wget
intermediate_instructions:
- RUN yum clean all
- RUN yum -y install net-tools lsof
pid_one_command: /usr/lib/systemd/systemd

- name: fedora-23
driver:
image: fedora:23
intermediate_instructions:
- RUN yum clean all
pid_one_command: /usr/lib/systemd/systemd
intermediate_instructions:
- RUN yum -y install tar

- name: ubuntu-12.04
driver:
image: ubuntu-upstart:12.04
platform: ubuntu
disable_upstart: false
run_command: /sbin/init
provision_command:
- /usr/bin/apt-get update
- /usr/bin/apt-get install apt-transport-https net-tools -y
pid_one_command: /sbin/init
intermediate_instructions:
- RUN /usr/bin/apt-get update
- RUN /usr/bin/apt-get install apt-transport-https net-tools -y
run_list:
- recipe[apt]

- name: ubuntu-14.04
driver:
image: ubuntu-upstart:14.04
platform: ubuntu
disable_upstart: false
run_command: /sbin/init
provision_command:
- /usr/bin/apt-get update
- /usr/bin/apt-get install apt-transport-https net-tools -y
pid_one_command: /sbin/init
intermediate_instructions:
- RUN /usr/bin/apt-get update
- RUN /usr/bin/apt-get install apt-transport-https net-tools -y
run_list:
- recipe[apt]

- name: ubuntu-16.04
driver:
image: ubuntu:16.04
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
- RUN /usr/bin/apt-get install apt-transport-https net-tools -y

suites:
- name: default
run_list: activemq::default
attributes:
activemq:
use_default_config: true
java:
jdk_version: 8
run_list: ["recipe[test::default]"]
3 changes: 3 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ driver:
provisioner:
name: chef_zero

verifier:
name: inspec

platforms:
- name: centos-5.11
- name: centos-6.7
Expand Down
20 changes: 17 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,29 @@ services: docker

env:
matrix:
- INSTANCE=default-ubuntu-1204
- INSTANCE=default-ubuntu-1404
- INSTANCE=default-centos-5
- INSTANCE=default-centos-6
- INSTANCE=default-centos-7
- INSTANCE=default-fedora-23
- INSTANCE=default-debian-7
- INSTANCE=default-debian-8
- INSTANCE=default-ubuntu-1204
- INSTANCE=default-ubuntu-1404
- INSTANCE=default-ubuntu-1604

# Don't `bundle install`
install: echo "skip bundle install"

# Ensure we make ChefDK's Ruby the default
before_script:
# https://github.com/zuazo/kitchen-in-travis-native/issues/1#issuecomment-142230889
- docker --version
- docker info
- mount
- sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
- eval "$(/opt/chefdk/bin/chef shell-init bash)"
- /opt/chefdk/embedded/bin/chef gem install kitchen-docker
- /opt/chefdk/embedded/bin/chef gem install kitchen-dokken

script:
- /opt/chefdk/embedded/bin/chef --version
- /opt/chefdk/embedded/bin/rubocop --version
Expand All @@ -34,3 +43,8 @@ script:
- /opt/chefdk/embedded/bin/foodcritic . --exclude spec -f any
- /opt/chefdk/embedded/bin/rspec
- KITCHEN_LOCAL_YAML=.kitchen.docker.yml /opt/chefdk/embedded/bin/kitchen verify ${INSTANCE}

after_script:
- docker images
- docker ps -a
- cat .kitchen/logs/*kitchen*.log
6 changes: 5 additions & 1 deletion Berksfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ source 'https://supermarket.chef.io'
metadata

group :integration do
cookbook 'yum'
cookbook 'apt'
cookbook 'zypper'
cookbook 'yum'
cookbook 'java', '>= 1.36'
end

cookbook 'test', path: 'test/cookbooks/test'
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# activemq Cookbook CHANGELOG
This file is used to list changes made in each version of the activemq cookbook.

## v3.0.4
- rewrite of activemq cookbook as resource driven cookbook

## v2.0.4 (2015-12-03)
- Add a new attribute for setting transport protocols: default['activemq']['transport_protocols']

Expand Down
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ end

group :kitchen_common do
gem 'test-kitchen', '~> 1.7'
gem 'kitchen-inspec', '~> 0.12.2'
end

group :kitchen_vagrant do
gem 'kitchen-vagrant', '~> 0.19'
end

group :kitchen_dokken do
gem 'kitchen-dokken'
end
56 changes: 50 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# activemq Cookbook
[![Build Status](https://travis-ci.org/chef-cookbooks/activemq.svg?branch=master)](https://travis-ci.org/chef-cookbooks/activemq) [![Cookbook Version](https://img.shields.io/cookbook/v/activemq.svg)](https://supermarket.chef.io/cookbooks/activemq)

Installs Apache ActiveMQ and sets up the service using the included init script.
Provides resources for installing Apache ActiveMQ and managing the Apache ActiveMQ service for use in wrapper cookbooks. Installs from tarballs from the Apache.org website by default.

## Requirements
### Platforms
- Debian/Ubuntu
- RHEL/CentOS/Scientific/Amazon/Oracle

- Debian / Ubuntu derivatives
- RHEL and derivatives
- Fedora

### Chef
- Chef 11+
- Chef 12.1+

### Cookbooks
- java
Expand All @@ -26,12 +28,54 @@ Installs Apache ActiveMQ and sets up the service using the included init script.
- `node['activemq']['enabled']` - Whether or not the ActiveMQ service should be started. Defaults to `true`.

## Usage
Simply add `recipe[activemq]` to a run list.
Due to the complexity of configuring ActiveMQ it's not possible to create a single solution that solves everyone's potential desired configuration. Instead this cookbook provides resources for installing and managing the ActiveMQ service, which are best used in your own wrapper cookbook. The best way to understand how this could be used is to look at the docs_example test recipe located at test/cookbooks/test/recipes/docs_example.rb

## Resources

### activemq_install

The activemq_install resource installs an instance of the Apache ActiveMQ binary direct from Apache's mirror site. As distro packages are not used we can easily deploy per-instance installations and any version available on the Apache archive site can be installed.

#### Properties

* `instance_name`, String
* `version`, String. The version to install. Default: '5.12.0'
* `home`, String. The top level directory to install software. Default: '/opt'
* `install_path`, String. The full level path to install software.
* `tarball_base_path`, String. The base path to the location containing the binary package of ActiveMQ. Default: 'http://archive.apache. org/dist/activemq/'
* `sha1_base_path`, String. The base path to the location containing the checksum file. default: 'http://archive.apache.org/dist/activemq/'

#### Example

```
# Install hello instance of activemq
activemq_install 'hello' do
version '5.12.0'
end
```

### activemq_service

The activemq_service resource sets up the installed activemq instance to run using the appropriate init system (sys-v, upstart, or systemd).

#### Properties

* `instance_name`, String.
* `install_path`, String. The full path to the install directory.
* `env_vars`, Array. An array of hashes containing the environmental variables for env script.

#### Example

# Set up activemq hello instance as a service
```
activemq_service 'hello' do
action [:start, :enable]
end
```
## License & Authors
**Author:** Cookbook Engineering Team ([[email protected]](mailto:[email protected]))

**Copyright:** 2008-2015, Chef Software, Inc.
**Copyright:** 2008-2016, Chef Software, Inc.

```
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@
# set to 'TLSv1,TLSv1.1,TLSv1.2'
# to disable sslv3 and protect against poodle
default['activemq']['transport_protocols'] = nil
default['activemq']['user'] = nil
default['activemq']['group'] = nil
26 changes: 26 additions & 0 deletions libraries/activemq.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Cookbook Name:: activemq
# Library:: activemq
#
#
# Copyright 2016, Chef Software, 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.
#

# the install path of this instance of activemq
# make sure it doesn't end in / as well as that causes issues in init scripts

def derived_install_path
new_resource.install_path ? new_resource.install_path.chomp('/') : "/opt/activemq_#{new_resource.instance_name}"
end
43 changes: 0 additions & 43 deletions libraries/chef_activemq.rb

This file was deleted.

35 changes: 35 additions & 0 deletions libraries/matchers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
if defined?(ChefSpec)
#################
# activemq_install
#################
ChefSpec.define_matcher :activemq_install

def install_activemq_install(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:activemq_install, :install, resource_name)
end

################
# activemq_service
################
ChefSpec.define_matcher :activemq_service

def start_activemq_service(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:activemq_service, :start, resource_name)
end

def enable_activemq_service(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:activemq_service, :enable, resource_name)
end

def restart_activemq_service(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:activemq_service, :restart, resource_name)
end

def stop_activemq_service(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:activemq_service, :stop, resource_name)
end

def disable_activemq_service(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:activemq_service, :disable, resource_name)
end
end
Loading