[chef] RE: RE: Re: RE: Re: RE: Re: Re: Re: Re: Deploying .war files?


Chronological Thread 
  • From: Matthew Drobnak < >
  • To: " " < >
  • Subject: [chef] RE: RE: Re: RE: Re: RE: Re: Re: Re: Re: Deploying .war files?
  • Date: Fri, 24 Jun 2011 14:56:52 -0400
  • Accept-language: en-US
  • Acceptlanguage: en-US

I ended up not using the new version yet. I'm still understanding the 
complexities of things like LWRPs, so I tried just some simple modifications. 
Here's what I ended up with:

diff --git a/cookbooks/application/recipes/java_webapp.rb 
b/cookbooks/application/recipes/java_webapp.rb
index b008289..e9e7f92 100644
--- a/cookbooks/application/recipes/java_webapp.rb
+++ b/cookbooks/application/recipes/java_webapp.rb
@@ -80,12 +80,20 @@ if app["database_master_role"]
     if rows.length == 1
       dbm = rows[0]
     end
+    if app["database_master_details"]
+      dbm = app["database_master_details"][node.chef_environment]
+    end
   end

   # Assuming we have one...
   if dbm
     template "#{app['deploy_to']}/shared/#{app['id']}.xml" do
-      source "context.xml.erb"
+      if app["databases"][node.chef_environment]["adapter"] == "sqlserver"
+         source "sqlserver.context.xml.erb"
+      else
+         source "context.xml.erb"
+      end
+
       owner app["owner"]
       group app["group"]
       mode "644"
@@ -93,6 +101,7 @@ if app["database_master_role"]
         :host => dbm['fqdn'],
         :app => app['id'],
         :database => app['databases'][node.chef_environment],
+        :path => app['path'],
         :war => 
"#{app['deploy_to']}/releases/#{app['war'][node.chef_environment]['checksum']}.war"
       )
     end
diff --git a/cookbooks/application/recipes/tomcat.rb 
b/cookbooks/application/recipes/tomcat.rb
index f8a4d37..a7fe226 100644
--- a/cookbooks/application/recipes/tomcat.rb
+++ b/cookbooks/application/recipes/tomcat.rb
@@ -23,17 +23,17 @@ include_recipe "tomcat"

 # remove ROOT application
 # TODO create a LWRP to enable/disable tomcat apps
-directory "#{node['tomcat']['webapp_dir']}/ROOT" do
+directory "#{node['tomcat']['webapp_dir']}#{app['path']}" do
   recursive true
   action :delete
-  not_if "test -L #{node['tomcat']['context_dir']}/ROOT.xml"
+  not_if "test -L #{node['tomcat']['context_dir']}/#{app['id']}.xml"
 end
-link "#{node['tomcat']['context_dir']}/ROOT.xml" do
+link "#{node['tomcat']['context_dir']}/#{app['id']}.xml" do
   to "#{app['deploy_to']}/shared/#{app['id']}.xml"
   notifies :restart, resources(:service => "tomcat")
 end

-if ::File.symlink?(::File.join(node['tomcat']['context_dir'], "ROOT.xml"))
+if ::File.symlink?(::File.join(node['tomcat']['context_dir'], 
"#{app['id']}.xml"))
   d = resources(:remote_file => app['id'])
   d.notifies :restart, resources(:service => "tomcat")
 end
diff --git a/cookbooks/application/templates/default/context.xml.erb 
b/cookbooks/application/templates/default/context.xml.erb
index d6301af..0d94d5a 100644
--- a/cookbooks/application/templates/default/context.xml.erb
+++ b/cookbooks/application/templates/default/context.xml.erb
@@ -1,4 +1,4 @@
-<Context docBase="<%= @war %>" path="/"
+<Context docBase="<%= @war %>" path="<%= @path %>"
         debug="5" reloadable="true" crossContext="true" allowLinking="true">
   <Environment name="appEnvironment" value="<%= node.chef_environment %>"
           type="java.lang.String" override="false"/>
diff --git a/data_bags/apps/spark_server.json 
b/data_bags/apps/spark_server.json
new file mode 100644
index 0000000..00df21c
--- /dev/null
+++ b/data_bags/apps/spark_server.json
@@ -0,0 +1,65 @@
+{
+  "id": "AppName",
+    "server_roles": [
+      "spark_server"
+      ],
+    "type": {
+      "spark_server": [
+        "java_webapp",
+        "tomcat"
+        ]
+    },
+    "path": [
+      "/AppName"
+    ],
+    "database_master_role": [
+      "spark_database_master"
+    ],
+    "database_master_details": {
+      "_default": {
+        "fqdn": "redacted.abc.local"
+      }
+    },
+    "war": {
+      "_default": {
+        "source": "http://redacted/spark_server.war";,
+        "checksum": 
"06880edebbf24c4000da4d45d26aa97ddc2a6ad1ae3e4365c755fdb5a1ad481a"
+      }
+    },
+    "databases": {
+      "_default": {
+        "max_active": "100",
+        "max_idle": "30",
+        "max_wait": "10000",
+        "username": "redacted",
+        "adapter": "sqlserver",
+        "driver": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
+        "port" : "3273",
+        "password": "redacted",
+        "database": "appname"
+      },
+      "dev": {
+        "max_active": "100",
+        "max_idle": "30",
+        "max_wait": "10000",
+        "username": "redacted",
+        "adapter": "sqlserver",
+        "driver": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
+        "port" : "1433",
+        "password": "redacted",
+        "database": "appname"
+      }
+    },
+    "mysql_root_password": {
+      "_default": "mysql_root"
+    },
+    "mysql_debian_password": {
+      "_default": "mysql_debian"
+    },
+    "mysql_repl_password": {
+      "_default": "mysql_repl"
+    },
+    "deploy_to": "/srv/spark_server",
+    "owner": "nobody",
+    "group": "nogroup"
+}
diff --git a/roles/spark_server.rb b/roles/spark_server.rb
new file mode 100644
index 0000000..cdc3df9
--- /dev/null
+++ b/roles/spark_server.rb
@@ -0,0 +1,12 @@
+name "spark_server"
+description "Spark Tomcat Server"
+run_list(
+  "recipe[application]",
+  "recipe[spark_server]"
+)
+
+default_attributes(
+  :tomcat => {
+    :java_options => "-Xms384M -Xmx1536M"
+  }
+)

And then the spark_server recipe has this for default.rb:

cookbook_file "/etc/tomcat6/AppName.dtd" do
  source "AppName.dtd"
  mode "0644"
  notifies :restart, resources(:service => "tomcat")
end

cookbook_file "/etc/tomcat6/appname.properties" do
  source "appname.properties"
  mode "0644"
  notifies :restart, resources(:service => "tomcat")
end

cookbook_file "/etc/tomcat6/custom-reports-csv.ini" do
  source "custom-reports-csv.ini"
  mode "0644"
  notifies :restart, resources(:service => "tomcat")
end

cookbook_file "/etc/tomcat6/custom-reports-html.ini" do
  source "custom-reports-html.ini"
  mode "0644"
  notifies :restart, resources(:service => "tomcat")
end

cookbook_file "/etc/tomcat6/div-superuser-map.ini" do
  source "div-superuser-map.ini"
  mode "0644"
  notifies :restart, resources(:service => "tomcat")
end

cookbook_file "/etc/tomcat6/div-user-map.ini" do
  source "div-user-map.ini"
  mode "0644"
  notifies :restart, resources(:service => "tomcat")
end

cookbook_file "/etc/tomcat6/load-balancer.properties" do
  source "load-balancer.properties"
  mode "0644"
  notifies :restart, resources(:service => "tomcat")
end

cookbook_file "/etc/tomcat6/log4j.dtd" do
  source "log4j.dtd"
  mode "0644"
  notifies :restart, resources(:service => "tomcat")
end

cookbook_file "/etc/tomcat6/log4j.xml" do
  source "log4j.xml"
  mode "0644"
  notifies :restart, resources(:service => "tomcat")
end


Obviously the cookbook_file for appname.properties will be changing to a 
template based on my other email..


Items to do:
Fix the SQLServer context hack thing. I think I can use some ruby in the 
template to say if drivername = sqlserver put this line, otherwise the 
default, right?
Get my template & script working for appname.properties

After that, I think I've got my first piece of infrastructure Chef'd!

Thanks for everyone's help so far.

-Matt

-----Original Message-----
From: Matthew Drobnak 
[mailto:
 
Sent: Thursday, June 23, 2011 12:39 PM
To: 

Subject: [chef] RE: Re: RE: Re: RE: Re: Re: Re: Re: Deploying .war files?

Edmund, I just got your version from git, and I'm going to try and merge your 
context changes in..

I'll let you know how it goes.

Thanks a lot.

-Matt

-----Original Message-----
From: Haselwanter Edmund 
[mailto:
 
Sent: Thursday, June 23, 2011 12:26 PM
To: 

Subject: [chef] Re: RE: Re: RE: Re: Re: Re: Re: Deploying .war files?


On 23.06.2011, at 17:04, Matthew Drobnak wrote:

> Seth,
> 
> Thanks for the response.
> 
> I did figure out the data bag item issue shortly after...at which point I 
> tried to create a node and manually specify fqdn and ip address, since it's 
> SQL Server, production, and not ready to install chef on quite yet. ;)
> 
> At that point, when I tried updating the client definition...I killed my 
> server. The node list never returned. It could be I tried editing it in the 
> Web UI between exporting the client as json and re-importing it...
> 
> So I learned a lesson: Don't mess with nodes manually, LOL. What should I 
> do in this situation? Is installing the Chef client the only way around it, 
> or should I modify the recipe to take an override from json?
> 
> I'm going to look at the mods made by Haselwanter Edmund to see if that 
> gets me what I need.

You can set the context in my improved version. Try the vagrant box example 
and play with it. You could create another app by adding a role and a databag 
item (just copy and modify the files)

cu edi

--
DI Edmund Haselwanter, 
,
 http://edmund.haselwanter.com/
http://www.iteh.at ;| http://facebook.com/iTeh.solutions ;| 
http://at.linkedin.com/in/haselwanteredmund ;








Archive powered by MHonArc 2.6.16.

§