Puppet Module for JBOSS

Recently one of my colleague called me up with a problem statement where he was finding difficulty configuring JBOSS through puppet. I tried to help him through one of VMware Workstation box on my Dell Inspiron.

puppetlabs_1304099092_11

I tried to google but couldn’t find the working example. I tried my hands of my own and YES…I did it finally.

I am sharing the overall idea how to deploy and configure JBOSS through Puppet.

Let’s say you have the following steps which you manually perform for installing JBOSS on your Linux machine:

1.$ su -c “yum install java-1.6.0-openjdk-devel”

2.$ java –version

3.wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip

4.$ unzip jboss-as-7.1.1.Final.zip -d /usr/share

5.$ adduser jboss

6.$ chown -fR jboss.jboss /usr/share/jboss-as-7.1.1.Final/

7.$ su jboss

8.$ cd /usr/share/jboss-as-7.1.1.Final/bin/

9.$ ./add-user.sh

You should see the following message on the console after executing the command:

What type of user do you wish to add?

a) Management User (mgmt-users.properties)

b) Application User (application-users.properties)

(a): a

We select “a”, next you should see the following message:

Enter the details of the new user to add.

Realm (ManagementRealm) :

Username : jboss

Password :

Re-enter Password :

* hit enter for Realm to use default, then provide a username and password

We select the default value for the Realm (ManagementRealm), by hitting enter, and select “jboss” as our username. By default, we supply “jb0ss” as our password, of course, you can provide any password you prefer here.

Step 4: Start the JBoss AS 7 server:

Once the appropriate JBoss users are created, we are now ready to start our new JBoss AS 7 server. With JBoss AS 7, a new standalone and domain model has been introduced. In this tutorial, we focus on starting up a standalone server. The domain server will be part of a future tutorial.

Startup a JBoss 7, standalone instance:

A standalone instance of JBoss 7 can be starting by executing:

$ ./standalone.sh -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0.0.0.

We can automate those steps for client through Puppet.Let’s start writing puppet init.pp from scratch. I will be delivering step by step of init.pp to achieve every components of init.pp.

Line 1 – 4

The Line 1 to 4 does nothing but downloading JBOSS to /usr/share directory. What we are going to do is put the downloaded jboss-as-7.1.1.Final on /var/lib/puppet/files directory on puppet master and push it to the puppet-client at /usr/share/jboss-as directory.

Here is the below init.pp

The above init.pp define a class jboss-custom, takes JBOSS-as-7.1.1-Final from the puppet-master /var/lib/puppet/files/ and push it to the puppet-client.

Que: How does it know which directory to pull the files from?

Answer: Under /etc/puppet/fileserver.conf, we define those path and permission as shown below:

Shall we start?

Ensure that you have put JBOSS-as-7.1.1-Final under /var/lib/puppet/files directory with permission:

#chown –R puppet:puppet /var/lib/puppet

The permission is very important and shouldn’t be skipped.

Now run the command from the puppet-client to check if it runs without any issue:

Wow !!! Our first program went well and the server has pushed the file to the puppet-client successfully.

Line:5 to 9

The easiest way of performing the overall step is writing a shell script which will run on the remote machine:

Go to /var/lib/puppet/files and create a script called jbossdeploy.sh

#!/bin/bash

groupadd jbossas

useradd -g jbossas -p deQcvEr1PRPSM jbossas

chown -fR jbossas:jbossas /usr/share/jboss-as-7.1.1.Final/

cd /usr/share/jboss-as/

#!/usr/bin/expect

spawn ./add-user.sh

expect “(a):”

send “a”

expect “Realm (ManagementRealm):”

send “ManagementRealm”

expect “Username:”

send “jbossas”

expect “Password:”

send “jbossas”

expect “Re-enter Password:”

send “jbossas”

cd /usr/share/jboss-as-7.1.1.Final/bin

./standalone.sh -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0.0.0.0&

The above script will create jboss user and group, run add-user.sh command under /usr/share/jboss-as/jboss-as-7.1.1.Final/bin directory. I have used expect library (ensure it is already installed) in perl.

Lets modify the init.pp so as to accommodate this script execution as shown:

class jboss-custom {

file {‘/usr/share/jboss-as/jboss-7.1.1.Final’:

owner => ‘root’,

group => ‘root’,

mode => ‘0440’,

source => ‘puppet://puppet-server.test.com/files/jboss-as-7.1.1.Final’

}

file { ‘/usr/share/jboss-as/jbossdeploy.sh’:

source => ‘puppet://puppet-server.test.com/files/jbossdeploy.sh’

}

exec { “/usr/share/jboss-as/jbossdeploy.sh”:}

}

If you run now the following it goes all fine and start the JBOSS application server.

Lets test it.

puppet agent –test –verbose –server puppet-server.test.com

info: Caching catalog for puppet-client.test.com

info: Applying configuration version ‘1345944985’

notice: /File[/usr/share/jboss-as/jbossdeploy.sh]/content:

— /usr/share/jboss-as/jbossdeploy.sh 2012-08-29 17:37:01.365003616 -0400

+++ /tmp/puppet-file20120829-18751-81r0p8-0 2012-08-29 17:44:40.993732919 -0 400

@@ -1,12 +1,10 @@

#!/bin/bash

groupadd jbossas

useradd -g jbossas -p deQcvEr1PRPSM jbossas

chown -fR jbossas:jbossas /usr/share/jboss-as-7.1.1.Final/

-cd /usr/share/jboss-as/jboss-as-7.1.1.Final/bin

+cd /usr/share/jboss-as/

#!/usr/bin/expect

-/usr/bin/expect << EOD

-spawn sh add-user.sh

+spawn ./add-user.sh

expect “(a):”

send “a”

expect “Realm (ManagementRealm):”

@@ -17,7 +15,6 @@

send “jbossas”

expect “Re-enter Password:”

send “jbossas”

-EOD

cd /usr/share/jboss-as-7.1.1.Final/bin

./standalone.sh -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0. 0.0.0&

info: FileBucket adding {md5}afc9bd6b8229da628396b90f2759f41f

info: /File[/usr/share/jboss-as/jbossdeploy.sh]: Filebucketed /usr/share/jboss-a s/jbossdeploy.sh to puppet with sum afc9bd6b8229da628396b90f2759f41f

notice: /File[/usr/share/jboss-as/jbossdeploy.sh]/content: content changed ‘{md5 }afc9bd6b8229da628396b90f2759f41f’ to ‘{md5}140ab2a8605d1164793c2175aa972675’

notice: /Stage[main]/Jboss-custom/Exec[/usr/share/jboss-as/jbossdeploy.sh]/retur ns: executed successfully

notice: /File[/usr/share/jboss-as/jboss-7.1.1.Final]/ensure: created

notice: Finished catalog run in 0.79 seconds

[root@puppet-client ~]#

Please follow and like us:
0

53 thoughts on “Puppet Module for JBOSS

  1. You really make it seem so easy together with your presentation however I to find this topic to be actually one thing that I feel I might by no means understand. It seems too complex and very extensive for me. I’m taking a look forward to your subsequent publish, I’ll attempt to get the dangle of it!

  2. I’m extremely inspired along with your writing skills and also with the layout to your blog. Is this a paid subject or did you modify it yourself? Anyway keep up the nice quality writing, it’s uncommon to peer a nice blog like this one today..

  3. There are some interesting time limits on this article however I don’t know if I see all of them middle to heart. There may be some validity but I’ll take maintain opinion till I look into it further. Good article , thanks and we wish more! Added to FeedBurner as properly

  4. Today, while I was at work, my cousin stole my apple ipad and tested to see if it can survive a twenty five foot drop, just so she can be a youtube sensation. My iPad is now destroyed and she has 83 views. I know this is completely off topic but I had to share it with someone!

  5. I have been browsing on-line more than 3 hours these days, but I never found any interesting article like yours. It is lovely worth sufficient for me. In my opinion, if all site owners and bloggers made good content material as you did, the internet will probably be much more helpful than ever before. “Now I see the secret of the making of the best persons.” by Walt Whitman.

  6. I’m really loving the theme/design of your blog. Do you ever run into any internet browser compatibility problems? A few of my blog audience have complained about my site not operating correctly in Explorer but looks great in Opera. Do you have any tips to help fix this issue?

  7. I like the valuable info you provide in your articles. I’ll bookmark your weblog and check again here frequently. I’m quite sure I’ll learn lots of new stuff right here! Best of luck for the next!

  8. I think this is among the most significant info for me. And i am glad reading your article. But wanna remark on some general things, The web site style is great, the articles is really nice : D. Good job, cheers

  9. Wow that was strange. I just wrote an extremely long comment but after I clicked submit my comment didn’t show up. Grrrr… well I’m not writing all that over again. Anyway, just wanted to say superb blog!

  10. Woah! I’m really loving the template/theme of this website. It’s simple, yet effective. A lot of times it’s hard to get that “perfect balance” between superb usability and visual appearance. I must say that you’ve done a excellent job with this. Additionally, the blog loads super quick for me on Internet explorer. Superb Blog!

  11. Thanks for your marvelous posting! I truly enjoyed reading it, you are a great author.I will always bookmark your blog and may come back later in life. I want to encourage that you continue your great writing, have a nice holiday weekend!

  12. Excellent blog here! Also your web site so much up fast! What host are you the usage of? Can I am getting your affiliate hyperlink in your host? I desire my web site loaded up as quickly as yours lol

  13. What i do not realize is actually how you are now not actually a lot more smartly-favored than you might be right now. You are so intelligent. You know thus considerably in relation to this matter, made me individually consider it from so many varied angles. Its like men and women don’t seem to be fascinated until it is something to do with Girl gaga! Your personal stuffs nice. All the time handle it up!

  14. Thank you for sharing superb informations. Your web site is so cool. I am impressed by the details that you have on this site. It reveals how nicely you understand this subject. Bookmarked this website page, will come back for extra articles. You, my pal, ROCK! I found just the information I already searched all over the place and simply could not come across. What a great website.

  15. Good ?V I should definitely pronounce, impressed with your web site. I had no trouble navigating through all the tabs and related information ended up being truly easy to do to access. I recently found what I hoped for before you know it at all. Reasonably unusual. Is likely to appreciate it for those who add forums or something, web site theme . a tones way for your client to communicate. Nice task..

  16. Thanx for the effort, keep up the good work Great work, I am going to start a small Blog Engine course work using your site I hope you enjoy blogging with the popular BlogEngine.net.Thethoughts you express are really awesome. Hope you will right some more posts.

  17. There are some fascinating points in time in this article but I don’t know if I see all of them heart to heart. There may be some validity however I’ll take maintain opinion until I look into it further. Good article , thanks and we want more! Added to FeedBurner as well

Leave a Reply to Anonymous Cancel reply