Puppet code for IBM MQ installation
We have done our best to make it as easy as possible to use Puppet to change your “stem-cell” system into a running ‘IBM MQ server. Let’s look at some of the Puppet code needed to do this.
In the editor tab, go to the directory hierdata\nodes
and open the file mq91.playground.enterprisemodules.com
. This file contains all the node-specific data.
At the top, you see:
This hiera definition tells Puppet that for this node, node mq91.enterprisemodules.com
, we want to apply the Puppet class role::mq
.
The role role::mq
Let’s see what this Puppet class is doing for us. In the editor tab, go to the directory modules\role\manifests
and open the file mq.pp
. For your convenience, I have included the contents here as well.
class role::mq()
{
contain ::profile::base
contain ::ibm_profile::mq_machine
Class['::profile::base']
-> Class['::ibm_profile::mq_machine']
}
As you can see, this role class contains (is special sort of include) two other classes. The ::profile::base
class is what we call the base profile. A base profile contains all Puppet definitions you would like to apply to all nodes in your organization. It includes all the standard settings you want to apply to your system, no matter what.
The second include is the ::ibm_profile::mq_machine
class. This Puppet class is where all the magic happens needed to transform this node into an IBM MQ server.
As you can see, this is pretty easy. Let’s see it in action!
Ensure prerequisites
In a normal situation, the ibm_profile
Puppet class would silently take care of all prerequisites for you. For teaching purposes, we have disabled this.
In the editor tab, go to the directory hierdata\nodes
and open the file mq91.playground.enterprisemodules.com
. This file contains all the node-specific data.
In tis file you see this:
ibm_profile::mq_machine::limits: skip
ibm_profile::mq_machine::groups_and_users: skip
ibm_profile::mq_machine::packages: skip
ibm_profile::mq_machine::software: skip
ibm_profile::mq_machine::fixpack: skip
ibm_profile::mq_machine::manager_setup: skip
ibm_profile::mq_machine::authorization_setup: skip
ibm_profile::mq_machine::messaging_setup: skip
ibm_profile::mq_machine::mq_web: skip
This is the hiera settings that tell ibm_profile
NOT to execute the software, autostart etc steps.
First Puppet run
With all the skips in place, let’s run Puppet and see what happens.
Well, that didn’t do a lot.
Notice: Compiled catalog for mq91.playground.enterprisemodules.com in environment production in 0.12 seconds
Notice: Applied catalog in 0.10 seconds
Actually, what it did, is executing only the base profile. And in this playground, the base profile is minimal.
Re-enable all prerequisite steps.
For the next step, we are going to remove some of the skip defintions in the hiera. Open the node yaml in the editor tab and remove or comment out all lines in the second block of skips. Your hiera should look something like this now:
#
# ibm_profile::mq_machine::limits: skip
# ibm_profile::mq_machine::groups_and_users: skip
# ibm_profile::mq_machine::packages: skip
#
ibm_profile::mq_machine::software: skip
ibm_profile::mq_machine::fixpack: skip
ibm_profile::mq_machine::manager_setup: skip
ibm_profile::mq_machine::authorization_setup: skip
ibm_profile::mq_machine::messaging_setup: skip
ibm_profile::mq_machine::mq_web: skip
Re-run Puppet
So now mq_machine
executes much more of its regular steps. Let’s see what a re-run of Puppet provides us.
The result is following:
Notice: Compiled catalog for mq91.playground.enterprisemodules.com in environment production in 0.44 seconds
Notice: MQ limits
Notice: MQ Groups and Users
Notice: MQ Packages
Notice: /Stage[main]/Limits/File[/etc/security/limits.d/20-nproc.conf]/ensure: removed
Notice: /Stage[main]/Ibm_profile::Mq_machine::Limits/Limits::Limits[mqm/nofile]/File[/etc/security/limits.d/mqm_nofile.conf]/ensure: defined content as '{md5}374afb4b0ec6eb8ff05ca85838166d8c'
Notice: /Stage[main]/Ibm_profile::Mq_machine::Limits/Limits::Limits[mqm/nproc]/File[/etc/security/limits.d/mqm_nproc.conf]/ensure: defined content as '{md5}d6573e5d14f62d8b76e9b742cfcf376a'
Notice: /Stage[main]/Ibm_profile::Mq_machine::Groups_and_users/Group[mqm]/ensure: created
Notice: /Stage[main]/Ibm_profile::Mq_machine::Groups_and_users/User[mqm]/ensure: created
Notice: /Stage[main]/Ibm_profile::Mq_machine::Packages/Package[unzip]/ensure: created
Notice: Applied catalog in 13.45 secon
Wow, that is a lot more. Puppet now:
- Set’s limits
- Installs required packages
- Creates the required IBM MQ users and groups
- Manages tmpfile settings for Mq named pipes
All prerequisites needed for a successful IBM MQ server installation are now fulfilled.
Next up: Install the IBM MQ software itself.
Install the IBM MQ software
With all of the prerequisites done, it is time to install some IBM software.
In the editor tab, go to the directory hierdata\nodes
and open the file mq91.playground.enterprisemodules.com
. This file contains all the node-specific data.
Let’s comment out the skip for the step ibm_profile::mq_machine::software
as well. Meaning do execute this step now.
Your hiera should look something like this now:
#
# ibm_profile::mq_machine::limits: skip
# ibm_profile::mq_machine::groups_and_users: skip
# ibm_profile::mq_machine::packages: skip
# ibm_profile::mq_machine::software: skip
#
ibm_profile::mq_machine::fixpack: skip
ibm_profile::mq_machine::manager_setup: skip
ibm_profile::mq_machine::authorization_setup: skip
ibm_profile::mq_machine::messaging_setup: skip
ibm_profile::mq_machine::mq_web: skip
Re-run Puppet
Let’s see what Puppet has got in store for us now and re-run Puppet.
Be aware that installing the IBM MQ software takes some time. It can take from two up to four minutes.
The result should be similar to following:
Notice: Compiled catalog for mq91.playground.enterprisemodules.com in environment production in 0.55 seconds
Notice: MQ limits
Notice: MQ Groups and Users
Notice: MQ Packages
Notice: MQ version 9.1.0.0 software from /install
Notice: /Stage[main]/Ibm_profile::Mq_machine::Groups_and_users/User[mqm]/password: changed [redacted] to [redacted]
Notice: /Stage[main]/Mq_install::Software/Mq_install::Software::Unix[mq_installation_9.1.0.0]/Archive[/tmp/IBM_MQ_9.1.0.0_LINUX_X86-64.tar.gz]/ensure: download archive from /install/IBM_MQ_9.1.0.0_LINUX_X86-64.tar.gz to /tmp/IBM_MQ_9.1.0.0_LINUX_X86-64.tar.gz and extracted in /tmp with cleanup
Notice: /Stage[main]/Mq_install::Software/Mq_install::Software::Unix[mq_installation_9.1.0.0]/Exec[Accept MQ License Requirements]/returns: executed successfully
Notice: /Stage[main]/Mq_install::Software/Mq_install::Software::Unix[mq_installation_9.1.0.0]/Package[MQSeriesRuntime-9.1.0-0]/ensure: created
Notice: /Stage[main]/Mq_install::Software/Mq_install::Software::Unix[mq_installation_9.1.0.0]/Package[MQSeriesJRE-9.1.0-0]/ensure: created
Notice: /Stage[main]/Mq_install::Software/Mq_install::Software::Unix[mq_installation_9.1.0.0]/Package[MQSeriesJava-9.1.0-0]/ensure: created
Notice: /Stage[main]/Mq_install::Software/Mq_install::Software::Unix[mq_installation_9.1.0.0]/Package[MQSeriesServer-9.1.0-0]/ensure: created
Notice: /Stage[main]/Mq_install::Software/Mq_install::Software::Unix[mq_installation_9.1.0.0]/File[Remove temporary files]/ensure: removed
Notice: Applied catalog in 36.85 seconds
So now ibm_profile
executes all of the steps needed to install the IBM software. Because it has already taken care of the prerequisites in the previous Puppet run, it will see everything is already set up correctly and report no additional changes on this.
For the actual IBM MQ software installation, it executes these steps:
1) Pick components to add and components to remove
2) Create all required directories
3) Fetch the IBM software zip from a file server and unzip it.
4) Run the installer specified for kernel.
5) Cleanup
Re-run Puppet and check idempotency
What happens now if we run Puppet again:
Puppet detects everything is as it is described in your Puppet manifest and hiera settings and changes nothing. It is idempotent.
Next up: Set IBM MQ machine settings.
Introducing the MQ packages
With MQ installed it is a good moment to see what extra components can be installed.
If you take a look at documentation of software class, unskipped in the previous page, you can see the following code:
install_ams => false,
install_ft => false,
install_client => false,
install_explorer => false,
install_xrserver => false,
install_samples => false,
install_sdk => false,
install_man => false,
install_gskit => false,
install_amqp => false,
These parameters tells puppet whether extra components should be installed with basic IBM MQ instance.
In the following table you can see short description of each parameter based on documentation.
|Parameter name|MQ component description|
|—|—|
|install_ams|Specify a value of true when you want to install Advanced Message Security (AMS) component.|
|install_ft|Specify a value of true when you want to install Managed File Transfer| component.|
|install_client|Specify a value of true when you want to install Standard Client component.|
|install_explorer|Specify a value of true when you want to install IBM MQ Explorer component.|
|install_xrserver|Specify a value of true when you want to install Telemetry Service component.|
|install_samples|Specify a value of true when you want to install Sample programs component.|
|install_sdk|Specify a value of true when you want to install SDK component.|
|install_man|Specify a value of true when you want to install Man pages component.|
|install_gskit|Specify a value of true when you want to install IBM Global Security Kit component.|
|install_amqp|Specify a value of true when you want to install AMQP Service component.|
More info about IBM MQ components, can be found on IBM website.
Adding MQ components to the installation
All components are not installed by default, in this example AMQP Service will be added. All other components can be added in the same way.
In the editor tab, go to the directory hierdata\nodes
and open the file mq91.playground.enterprisemodules.com
.
The third block of settings in this file looks like this now:
# ibm_profile::mq_machine::limits: skip
# ibm_profile::mq_machine::groups_and_users: skip
# ibm_profile::mq_machine::packages: skip
# ibm_profile::mq_machine::software: skip
ibm_profile::mq_machine::fixpack: skip
ibm_profile::mq_machine::manager_setup: skip
ibm_profile::mq_machine::authorization_setup: skip
ibm_profile::mq_machine::messaging_setup: skip
ibm_profile::mq_machine::mq_web: skip
Let’s add line to the yaml.
ibm_profile::mq_machine::software::install_amqp: true
Your third block of hiera code should look like this now:
# ibm_profile::mq_machine::limits: skip
# ibm_profile::mq_machine::groups_and_users: skip
# ibm_profile::mq_machine::packages: skip
# ibm_profile::mq_machine::software: skip
ibm_profile::mq_machine::software::install_amqp: true
ibm_profile::mq_machine::fixpack: skip
ibm_profile::mq_machine::manager_setup: skip
ibm_profile::mq_machine::authorization_setup: skip
ibm_profile::mq_machine::messaging_setup: skip
ibm_profile::mq_machine::mq_web: skip
#
With all the components in place, let’s run Puppet and see what happens.
The result should be similar to following:
Notice: Compiled catalog for mq91.playground.enterprisemodules.com in environment production in 0.79 seconds
Notice: MQ limits
Notice: MQ Groups and Users
Notice: MQ Packages
Notice: MQ version 9.1.0.0 software from /install
Notice: /Stage[main]/Ibm_profile::Mq_machine::Groups_and_users/User[mqm]/password: changed [redacted] to [redacted]
Notice: /Stage[main]/Mq_install::Software/Mq_install::Software::Unix[mq_installation_9.1.0.0]/Archive[/tmp/IBM_MQ_9.1.0.0_LINUX_X86-64.tar.gz]/ensure: download archive from /install/IBM_MQ_9.1.0.0_LINUX_X86-64.tar.gz to /tmp/IBM_MQ_9.1.0.0_LINUX_X86-64.tar.gz and extracted in /tmp with cleanup
Notice: /Stage[main]/Mq_install::Software/Mq_install::Software::Unix[mq_installation_9.1.0.0]/Exec[Accept MQ License Requirements]/returns: executed successfully
Notice: /Stage[main]/Mq_install::Software/Mq_install::Software::Unix[mq_installation_9.1.0.0]/Package[MQSeriesAMQP-9.1.0-0]/ensure: created
Notice: /Stage[main]/Mq_install::Software/Mq_install::Software::Unix[mq_installation_9.1.0.0]/File[Remove temporary files]/ensure: removed
Notice: Applied catalog in 19.89 seconds
From the logs above you can see, that AMQP component have been correctly added and installed. Other components can be installed in the same way.
Re-run Puppet and check idempotency
What happens now if we run Puppet again:
Puppet detects everything is as it is described in your Puppet manifest and hiera settings and changes nothing. It is idempotent.
Set up the server
Last but certainly not least is to ensure an MQ objects like managers, topics and queues are available.
In the editor tab, go to the directory hierdata\nodes
and open the file mq91.playground.enterprisemodules.com
. This file contains all the node-specific data.
Let’s remove or comment out all of the skips, so Puppet will apply a full manifest that ensures the creation of the MQ manager too.
Your second block of hiera code should look like this now:
# ibm_profile::mq_machine::limits: skip
# ibm_profile::mq_machine::groups_and_users: skip
# ibm_profile::mq_machine::packages: skip
# ibm_profile::mq_machine::software: skip
ibm_profile::mq_machine::software::install_amqp: true
ibm_profile::mq_machine::fixpack: skip
ibm_profile::mq_machine::manager_setup: skip
ibm_profile::mq_machine::authorization_setup: skip
ibm_profile::mq_machine::messaging_setup: skip
ibm_profile::mq_machine::mq_web: skip
This tell’s Puppet to skip all mq steps. Like I explained before, this is here for teaching purposes. Let’s remove or comment out all of these skips, so Puppet will apply a full manifest that ensures the creation of the mq too.
Your third block of hiera code should look like this now:
# ibm_profile::mq_machine::limits: skip
# ibm_profile::mq_machine::groups_and_users: skip
# ibm_profile::mq_machine::packages: skip
# ibm_profile::mq_machine::software: skip
ibm_profile::mq_machine::software::install_amqp: true
# ibm_profile::mq_machine::fixpack: skip
# ibm_profile::mq_machine::manager_setup: skip
# ibm_profile::mq_machine::authorization_setup: skip
# ibm_profile::mq_machine::messaging_setup: skip
# ibm_profile::mq_machine::mq_web: skip
#
What has been set?
- MQ service autostart with system start
- Fixpacks for specific IBM MQ version
- Creates MQ Manager (when defined)
- Sets MQ topics, queues etc (when defined)
- Sets MQ authorization (when defined)
- Sets MQ webs settings (when defined)
In the playground customising MQ, we will show you how you can add MQ managers queues and topics to your setup.
Re-run Puppet
Let’s see what Puppet has got in store for us now and re-run Puppet.
The result should be similar to following
Notice: Compiled catalog for mq91.playground.enterprisemodules.com in environment production in 0.57 seconds
Notice: MQ limits
Notice: MQ Groups and Users
Notice: MQ Packages
Notice: MQ version 9.1.0.0 software from /install
Notice: Ensure MQ Manager(s)
Notice: Applied catalog in 0.64 seconds
Re-run Puppet and check idempotency
What happens now if we run Puppet again:
Puppet detects everything is as it is described in your Puppet manifest and hiera settings and changes nothing. It is idempotent.
You like it?
Do you like what you see here and want to test this on your own infrastructure? No problem. You can sign up for a free trial.
If you have any questions, don’t hesitate to contact us.