Skip to content
This repository was archived by the owner on Oct 21, 2025. It is now read-only.

Commit eee4b74

Browse files
committed
Initial version
1 parent 94b3eb4 commit eee4b74

File tree

15 files changed

+530
-0
lines changed

15 files changed

+530
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.vagrant
2+
Berksfile.lock
3+
.kitchen/
4+
.kitchen.local.yml
5+
Thumbs.db

.kitchen.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# (C) Copyright IBM Corporation 2016.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
---
15+
driver:
16+
name: vagrant
17+
18+
provisioner:
19+
name: chef_zero
20+
21+
verifier:
22+
name: inspec
23+
24+
platforms:
25+
- name: ubuntu-14.04-chef-latest
26+
provisioner:
27+
require_chef_omnibus: 12.6.0
28+
driver:
29+
box: opscode-ubuntu-14.04
30+
31+
suites:
32+
- name: goodpath
33+
attributes:
34+
ibm_mq_test:
35+
# You need to set up a web server with the MQ packages on for the
36+
# tests to use, and reference the full URI as an environment variable.
37+
source: "<%= ENV['MQ_URI'] %>"
38+
queue_manager:
39+
name: qm1
40+
run_list:
41+
- recipe[apt::default]
42+
- recipe[ibm_mq_test::install]

Berksfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
source 'https://supermarket.chef.io'
2+
3+
metadata
4+
5+
group :integration do
6+
cookbook 'apt'
7+
cookbook 'ibm_mq_test', path: 'test/cookbooks/ibm_mq_test'
8+
end

CLA.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
IBM Contributor License Agreement
2+
=================================
3+
4+
Version 1.0.0 January 14, 2014
5+
6+
In order for You (as defined below) to make intellectual property Contributions (as defined below) now or in the future to IBM GitHub repositories,
7+
You must agree to this Contributor License Agreement ("CLA").
8+
9+
Please read this CLA carefully before accepting its terms. By accepting the CLA, You are agreeing to be bound by its terms.
10+
If You submit a Pull Request against an IBM repository on GitHub You must include in the Pull Request a statement of Your acceptance of this CLA.
11+
12+
As used in this CLA:
13+
(i) "You" (or "Your") shall mean the entity that is making this Agreement with IBM;
14+
(ii)"Contribution" shall mean any original work of authorship, including any modifications or additions to an existing work, that is submitted by You to IBM for inclusion in,
15+
or documentation of, any of the IBM GitHub repositories;
16+
(iii) "Submit" (or "Submitted") means any form of communication sent to IBM (e.g. the content You post in a GitHub Issue or submit as part of a GitHub Pull Request).
17+
18+
This agreement applies to all Contributions You Submit.
19+
20+
This CLA, and the license(s) associated with the particular IBM GitHub repositories You are contributing to, provides a license to Your Contributions to IBM and downstream consumers,
21+
but You still own Your Contributions, and except for the licenses provided for in this CLA, You reserve all right, title and interest in Your Contributions.
22+
23+
IBM requires that each Contribution You Submit now or in the future comply with the following four commitments.
24+
25+
1) You will only Submit Contributions where You have authored 100% of the content.
26+
2) You will only Submit Contributions to which You have the necessary rights. This means that if You are employed You have received the necessary permissions from Your employer to make the
27+
Contributions.
28+
3) Whatever content You Contribute will be provided under the license(s) associated with the particular IBM GitHub repository You are contributing to.
29+
4) You understand and agree that IBM GitHub repositories and Your contributions are public, and that a record of the contribution (including all personal information You submit with it)
30+
is maintained indefinitely and may be redistributed consistent with the license(s) involved.
31+
You will promptly notify IBM if You become aware of any facts or circumstances that would make these commitments inaccurate in any way.
32+
To do so, please create an Issue in the appropriate GitHub repository.

README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
IBM MQ cookbook
2+
===============
3+
4+
The IBM MQ cookbook is a library cookbook that provides custom resources for use in your own recipes. This cookbook is currently experimental, therefore we recommend that if you want to use this cookbook, that you either pin the version you use, or create your own fork first.
5+
6+
Requirements
7+
------------
8+
- Chef 12.6+
9+
- Network accessible web server hosting the MQ installer package
10+
11+
Platform Support
12+
----------------
13+
The following platforms have been tested with Test Kitchen:
14+
15+
- Ubuntu 14.04
16+
17+
Cookbook Dependencies
18+
---------------------
19+
- [limits](https://supermarket.chef.io/cookbooks/limits)
20+
- [yum](https://supermarket.chef.io/cookbooks/yum)
21+
22+
Usage
23+
-----
24+
1. Add ```depends 'ibm_mq'``` to your cookbook's metadata.rb
25+
2. Use the resources shipped in cookbook in a recipe, the same way you'd
26+
use core Chef resources (file, template, directory, package, etc).
27+
28+
```ruby
29+
ibm_mq_installation 'Installation1' do
30+
source 'http://10.0.2.15:8000/WS_MQ_V8.0.0.4_LINUX_ON_X86_64_IM.tar.gz'
31+
accept_license true
32+
end
33+
34+
ibm_mq_queue_manager 'qm1' do
35+
action [:create, :start]
36+
end
37+
```
38+
39+
Resources
40+
---------
41+
42+
## ibm_mq_installation
43+
The `ibm_mq_installation` resource downloads an IBM MQ download package file,
44+
specified by a URI.
45+
46+
#### Example
47+
```ruby
48+
ibm_mq_installation 'Installation1' do
49+
source 'http://10.0.2.15:8000/WS_MQ_V8.0.0.4_LINUX_ON_X86_64_IM.tar.gz'
50+
accept_license true
51+
action :create
52+
end
53+
```
54+
55+
#### Properties
56+
- `source` - Path to network accessible IBM MQ installation package.
57+
- `accept_license` - Set this to `true` if you accept the terms of the IBM MQ license.
58+
- `packages` - An array of package names to install. Defaults to:
59+
`%w(MQSeriesServer MQSeriesGSKit)`
60+
- `uid` - The UID to use for the `mqm` user
61+
- `gid` - The GID to use for the `mqm` user
62+
63+
## ibm_mq_queue_manager
64+
The `ibm_mq_queue_manager` resource creates and starts IBM MQ queue managers.
65+
66+
#### Example
67+
```ruby
68+
ibm_mq_queue_manager 'qm1' do
69+
action [:create, :start]
70+
end
71+
```
72+
73+
#### Properties
74+
- `user` - User to run MQ commands as. Defaults to `mqm`
75+
76+
77+
## Maintainers
78+
79+
* Arthur Barr (<[email protected]>)
80+
81+
## Developing
82+
If you do submit a Pull Request related to this cookbook, please indicate in the Pull Request that you accept and agree to be bound by the terms of the [IBM Contributor License Agreement](CLA.md).
83+
84+
In order to run the Test-Kitchen tests, you need to set an environment variable for the MQ download. For example, on Linux, you might do the following:
85+
86+
```shell
87+
export MQ_URI=http://10.0.2.15:8000/WS_MQ_V8.0.0.4_LINUX_ON_X86_64_IM.tar.gz
88+
```
89+
90+
## License
91+
Licensed under the Apache License, Version 2.0 (the "License");
92+
you may not use this file except in compliance with the License.
93+
You may obtain a copy of the License at
94+
95+
http://www.apache.org/licenses/LICENSE-2.0
96+
97+
Unless required by applicable law or agreed to in writing, software
98+
distributed under the License is distributed on an "AS IS" BASIS,
99+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
100+
See the License for the specific language governing permissions and
101+
limitations under the License.

chefignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.vagrant
2+
Berksfile
3+
Berksfile.lock
4+
.kitchen*
5+
spec/*
6+
test/*
7+
.git
8+
.gitignore
9+
Thumbs.db

metadata.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name 'ibm_mq'
2+
maintainer 'IBM'
3+
maintainer_email '[email protected]'
4+
license 'Apache 2.0'
5+
description 'Installs/Configures IBM MQ'
6+
long_description 'Installs/Configures IBM MQ'
7+
version '0.1.0'
8+
depends 'limits'
9+
depends 'yum'
10+
supports 'ubuntu'

resources/installation.rb

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# (C) Copyright IBM Corporation 2016.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
property :source, kind_of: String, required: true
16+
property :accept_license, kind_of: [TrueClass, FalseClass], default: false
17+
property :packages, kind_of: Array, default: %w(MQSeriesServer MQSeriesGSKit)
18+
property :default, kind_of: [TrueClass, FalseClass], default: false
19+
property :uid, kind_of: [String, Integer], default: nil
20+
property :gid, kind_of: [String, Integer], default: nil
21+
22+
default_action :create
23+
24+
# This action does the following:
25+
# * Downloads the MQ install package
26+
# * Extracts the install package
27+
# * Adds a Yum repository pointing at the MQ RPM files
28+
# * Accepts the license, as specified
29+
# * Installs the MQ packages, as specified
30+
# * Sets the default MQ installation, as specified
31+
action :create do
32+
fail 'You must accept the license to install IBM MQ.' unless accept_license
33+
fail 'Non-default installations are not currently supported' unless default
34+
35+
# include_recipe 'sysctl::ohai_plugin'
36+
#
37+
# sysctl_param 'fs.file-max' do
38+
# value 524_289
39+
# only_if node['sys']['fs']['file-max'] < value
40+
# end
41+
42+
download_dir = "#{Chef::Config[:file_cache_path]}/ibm_mq"
43+
download_path = "#{download_dir}/#{name}.tar.gz"
44+
unpack_dir = "#{download_dir}/extract-#{name}"
45+
46+
directory download_dir do
47+
owner 'root'
48+
group 'root'
49+
mode '0755'
50+
action :create
51+
end
52+
53+
directory unpack_dir do
54+
owner 'root'
55+
group 'root'
56+
mode '0755'
57+
action :create
58+
end
59+
60+
package %w(rpm yum createrepo) do
61+
action :install
62+
end
63+
64+
remote_file download_path do
65+
source new_resource.source
66+
action :create
67+
notifies :run, 'execute[extract-mq-package]', :immediately
68+
notifies :run, 'execute[createrepo-mq]', :immediately
69+
backup false
70+
action :create
71+
end
72+
73+
execute 'extract-mq-package' do
74+
command "tar -xvf #{download_path}"
75+
cwd unpack_dir
76+
# Only run after notified by remote_file download
77+
action :nothing
78+
end
79+
80+
execute 'createrepo-mq' do
81+
user 'root'
82+
cwd "#{unpack_dir}/MQServer"
83+
command 'createrepo .'
84+
end
85+
86+
group 'mqm' do
87+
gid new_resource.gid
88+
action :create
89+
end
90+
91+
user 'mqm' do
92+
uid new_resource.uid
93+
group 'mqm'
94+
home '/var/mqm'
95+
action :create
96+
end
97+
98+
set_limit 'mqm' do
99+
type 'soft'
100+
item 'nofile'
101+
value 10_240
102+
end
103+
104+
set_limit 'mqm' do
105+
type 'hard'
106+
item 'nofile'
107+
value 10_240
108+
end
109+
110+
execute 'Accept the mqlicense' do
111+
user 'root'
112+
cwd "#{unpack_dir}/MQServer"
113+
command './mqlicense.sh -accept -text_only'
114+
end
115+
116+
# Work around bug in 'yum' cookbook
117+
# See https://github.com/chef-cookbooks/yum/issues/144
118+
directory '/etc/yum.repos.d' do
119+
owner 'root'
120+
group 'root'
121+
mode '0755'
122+
action :create
123+
end
124+
125+
# Add a local yum repository
126+
yum_repository "ibm-mq-chef-#{name}" do
127+
description 'Packages for IBM MQ, used by Chef cookbook'
128+
baseurl "file://#{unpack_dir}/MQServer"
129+
gpgcheck false
130+
action :create
131+
end
132+
133+
# Install MQ
134+
yum_package packages do
135+
action :install
136+
end
137+
138+
# TODO: Unset as default installation, if no longer default
139+
execute 'setmqinst' do
140+
command '/opt/mqm/bin/setmqinst -n Installation1 -i'
141+
only_if { default }
142+
end
143+
end
144+
145+
action :remove do
146+
# Uninstall MQ
147+
yum_package packages do
148+
action :remove
149+
end
150+
151+
# Remove our Yum repository
152+
yum_repository "ibm-mq-chef-#{name}" do
153+
action :remove
154+
end
155+
end

0 commit comments

Comments
 (0)