Skip to content

Instantly share code, notes, and snippets.

@fishnix
Created July 10, 2012 15:58
Show Gist options
  • Select an option

  • Save fishnix/3084313 to your computer and use it in GitHub Desktop.

Select an option

Save fishnix/3084313 to your computer and use it in GitHub Desktop.
jbossNode bundle
# UNDER CFENGINE CONTROL! #
# Enable/Disable node
ENABLED=$(jbossNode.enabled)
# JBoss node name (node00, node01, node02, node03)
JBOSS_NODE="$(jbossNode.node_name)"
# JBoss partition name
JBOSS_PARTITION="$(jbossNode.partition)"
# IP on server to bind to
JBOSS_BIND="$(jbossNode.bind_addr)"
# User which runs JBoss
JBOSS_USER="$(jbossNode.app_user)"
# Where JBoss nodes live and where JBoss is installed
JBOSS_APPS="$(jbossNode.jboss_apps)"
JBOSS_HOME="$(jbossNode.jboss_home)"
# Where do logs go
JBOSS_LOGDIR="$(jbossNode.log_dir)/$(jbossNode.node_name)"
# Where to find my cacerts file
CACERTS="$(jbossNode.cacerts)"
# Where JVM is installed
JAVA_HOME="$(jbossNode.java_home)"
# Multicast addres for JBoss clustering
CLSTR_ADDR="$(jbossNode.cluster_addr)"
# Logging Level
LOGLVL="$(jbossNode.log_level)"
MSGSVRID="$(jbossNode.msg_id)";
# What binding set to use (ports-default, ports-01, ports-02, ports-03)
# HTTP: 8080, 8180, 8280, 8380
# HTTPS: 8440, 8441, 8442, 8443
BINDING="$(jbossNode.binding)"
HTTPPORT="$(jbossNode.http_port)"
HTTPSPORT="$(jbossNode.https_port)"
# Memory settings for JVM
MaxPermSize="$(jbossNode.maxperm)"
MAXHEAP="$(jbossNode.maxheap)"
MINHEAP="$(jbossNode.minheap)"
#
# What port to use for debug
DEBUGPORT="$(jbossNode.debug_port)"
# Additional options for JBoss and JAVA
ADDLJBOPTS="$(jbossNode.addtl_jb_opts)"
ADDLJVAOPTS="$(jbossNode.addtl_jv_opts)"
############################################################################
#
# JBoss Node management
#
# Configures individual Yale JBoss Node
#
# ECF 20120627
#
# Parameter list:
# jboss_ver = jboss version
# pkg_ver = (rpm) package version
# node_name = node name
# enabled = (0/1) enabled/disabled node
# app_user = user that runs JBoss node
# interface = interface to pull IP information for binding
# jboss_home = where jboss is installed
# jboss-apps = top-level dir where jboss nodes live
# jboss_deploy = top-level landing dir for installers
# log_dir = top-level log dir (node dirs are created under this)
# log_level = base logging level (TRACE,DEBUG,INFO,WARN,ERROR)
# prune_logs = how long to keep logs (in days)
# compress_logs = when to compress logs (in days)
# partition = JBoss Partition Name
# cluster_addr = Multicast cluster address
# binding = ports binding to use (ports-default, ports-01, ports-02, ports-03)
# http_port = port for HTTP connector
# https_port = port for HTTPS connector
# debug_port = port for remote debugging
# maxperm = Max PermGen size
# minheap = Min Heap Size
# maxheap = Max Heap Size
# java_home = JAVA_HOME, where java is installed
# cacerts = custom cacerts file, contains local CAs
# addtl_jb_opts = Additional JBoss Options (ie. "-Djboss.proxyname=xx -Djboss.proxyport=xx")
# addtl_jv_opts = Additional Java Options
#
############################################################################
bundle agent jbossNode( jboss_ver, pkg_ver, node_name, enabled, app_user, interface, jboss_home, jboss_apps,
jboss_deploy, log_dir, log_level, prune_logs, compress_logs, partition, cluster_addr,
binding, http_port, https_port, debug_port, maxperm, minheap, maxheap, java_home,
cacerts, addtl_jb_opts, addtl_jv_opts ) {
vars:
# To do local testing on this bundle, set fileserver to localhost
# "fileserver" slist => { "localhost" };
"fileserver" slist => { "@(var.fileserver)" };
"prefix" string => "$(var.masterfiles)/dcsunix/jbossNode/pub";
"secrets" string => "$(var.masterfiles)/dcsunix/jbossNode/pri";
# Message Server ID needs to be an integer and unique across a cluster
"msg_id" string => execresult("/bin/echo \"$(sys.fqhost)_$(jbossNode.node_name)\" | /usr/bin/cksum | /bin/cut -f1 -d\" \"", "useshell");
# Get the address to bind to via the interface name
"bind_addr" string => "$(sys.ipv4[$(jbossNode.interface)])";
# Node Dirs owned by $(app_user) along with all the content inside them
"jboss_apps_app_dirs" slist => {
"data",
"log",
"tmp",
"webapps",
"work"
};
# Node Dirs owned by root along with all the content inside them
"jboss_apps_root_dirs" slist => {
"conf",
"deploy",
"deployers",
"deploy-hasingleton",
"farm",
"lib"
};
# File patterns we want to compress in jboss log dirs (after some
# length of time specified in promises below)
"jboss_log_leaves_compress" slist => {
"access_log\..*\.log",
"server\.log\..*[^(gz)]"
};
satelliteClient::
"JBoss_pkg_x86_64_ver[jboss-eap]" string => "$(jbossNode.jboss_ver)-$(jbossNode.pkg_ver)";
"JBoss_pkgs_x86_64" slist => getindices("JBoss_pkg_x86_64_ver");
"JBoss_pkgs_noarch" slist => getindices("JBoss_pkg_noarch_ver");
methods:
"chkconfig_on"
usebundle => chkconfig_on("jboss_$(jbossNode.node_name)");
"template_etc_sysconfig_jboss_nodexx"
usebundle => template_std_full(,"/etc/sysconfig/jboss_nodexx", "/etc/sysconfig/jboss_$(jbossNode.node_name)", "$(prefix)", "$(fileserver)", "0644", "root", "root");
files:
"$(jbossNode.jboss_apps)/$(jbossNode.node_name)"
comment => "Private jboss content copies.",
copy_from => copy_std("$(secrets)/$(jbossNode.jboss_apps).$(jboss_ver)/nodexx",
"$(fileserver)", "false", "timestamp"),
depth_search => searchsettings_exclude("inf", "@(var.svn_metadata)", "false"),
action => actionsettings_fix_inform("inform");
"$(jbossNode.jboss_apps)/$(jbossNode.node_name)"
comment => "Public jboss content copies.",
copy_from => copy_std("$(prefix)/$(jbossNode.jboss_apps).$(jboss_ver)/nodexx",
"$(fileserver)", "false", "timestamp"),
depth_search => searchsettings_exclude("inf", "@(var.svn_metadata)", "false"),
action => actionsettings_fix_inform("inform");
"/etc/rc.d/init.d/jboss_$(jbossNode.node_name)"
copy_from => copy_std("$(prefix)/etc/rc.d/init.d/jboss_nodexx",
"$(fileserver)", "false", "timestamp"),
perms => mode_owner_group("0755", "root", "root"),
action => actionsettings_fix_inform("inform");
"$(jbossNode.cacerts)"
copy_from => copy_std("$(prefix)/$(jbossNode.cacerts)",
"$(fileserver)", "false", "timestamp"),
perms => mode_owner_group("0444", "root", "root"),
action => actionsettings_fix_inform("inform");
"$(jbossNode.jboss_apps)/."
create => "true",
perms => mode_owner_group("0755", "root", "root"),
action => actionsettings_fix_inform("inform");
"$(jbossNode.jboss_apps)"
comment => "Fix permissions on all datasources",
depth_search => searchsettings_exclude("inf", "@(var.svn_metadata)", "false"),
file_select => files_matching_leaf(".*-ds.xml","@(var.filetype_plain)"),
perms => mode_owner_group("0640", "root", "$(jbossNode.app_user)"),
action => actionsettings_fix_inform("inform");
"$(jbossNode.jboss_apps)"
comment => "Fix perms on jboss-apps",
perms => mode_owner_group("0755", "root", "root"),
action => actionsettings_fix_inform("inform");
"$(jbossNode.jboss_apps)/$(jbossNode.node_name)"
comment => "Fix perms on jboss node dir",
perms => mode_owner_group("0755", "root", "$(jbossNode.app_user)"),
action => actionsettings_fix_inform("inform");
"$(jbossNode.jboss_apps)/$(jbossNode.node_name)/$(jboss_apps_root_dirs)"
comment => "Enforce user root's ownership files + dirs inside $(jboss_apps_root_dirs)",
perms => mode_owner_group("0640", "root", "$(jbossNode.app_user)"),
depth_search => searchsettings_exclude("inf", "@(jboss_apps_root_excl_bypath)", "true"),
action => actionsettings_fix_inform("inform");
"$(jbossNode.jboss_apps)/$(jbossNode.node_name)/$(jboss_apps_app_dirs)"
comment => "Enforce user $(jbossNode.app_user)'s ownership of files in $(jboss_apps_app_dirs)",
perms => mode_owner_group("0644", "$(jbossNode.app_user)", "$(jbossNode.app_user)"),
file_select => files_matching_not_leaf(".*-ds.xml","@(var.filetype_plain)"),
depth_search => searchsettings_std("inf", "true"),
action => actionsettings_fix_inform("inform");
"$(jbossNode.jboss_apps)/$(jbossNode.node_name)/$(jboss_apps_app_dirs)"
comment => "Enforce app user's ownership of all dirs inside $(jboss_apps_app_dirs)",
perms => mode_owner_group("0755", "$(jbossNode.app_user)", "$(jbossNode.app_user)"),
file_select => files_matching_leaf(".*", "@(var.filetype_dir)"),
depth_search => searchsettings_std("inf", "true"),
action => actionsettings_fix_inform("inform");
"$(jbossNode.jboss_deploy)/."
create => "true",
perms => mode_owner_group("0755", "$(jbossNode.app_user)", "$(jbossNode.app_user)"),
action => actionsettings_fix_inform("inform");
"$(jbossNode.log_dir)/$(jbossNode.node_name)/."
create => "true",
perms => mode_owner_group("0755", "$(jbossNode.app_user)", "$(jbossNode.app_user)"),
action => actionsettings_fix_inform("inform");
### Tidy promises
"$(jbossNode.log_dir)/$(jbossNode.node_name)"
comment => "Prune out any files/dirs older than $(jbossNode.prune_logs) days",
file_select => files_older_than_x_days( "@(var.all_paths)",
"@(var.all_leaves)", "$(jbossNode.prune_logs)", "@(var.filetype_all)" ),
depth_search => searchsettings_std("inf", "false"),
delete => deletesettings_std,
action => actionsettings_fix_silent;
"$(jbossNode.log_dir)/$(jbossNode.node_name)"
comment => "Compress inactive jboss logs older than $(jbossNode.compress_logs)",
file_select => files_older_than_x_days( "@(var.all_paths)",
"@(jboss_log_leaves_compress)", "$(jbossNode.compress_logs)", "@(var.filetype_plain)" ),
depth_search => searchsettings_std("inf", "false"),
transformer => "/bin/gzip $(this.promiser)",
action => actionsettings_fix_silent;
JBossClusterNode::
"$(jbossNode.jboss_apps)/$(jbossNode.node_name)"
comment => "Private jboss content copies.",
copy_from => copy_std("$(secrets)/$(jbossNode.jboss_apps).cluster/nodexx",
"$(fileserver)", "false", "timestamp"),
depth_search => searchsettings_exclude("inf", "@(var.svn_metadata)", "false"),
action => actionsettings_fix_inform("inform");
"$(jbossNode.jboss_apps)/$(jbossNode.node_name)"
comment => "Public jboss content copies.",
copy_from => copy_std("$(prefix)/$(jbossNode.jboss_apps).cluster/nodexx",
"$(fileserver)", "false", "timestamp"),
depth_search => searchsettings_exclude("inf", "@(var.svn_metadata)", "false"),
action => actionsettings_fix_inform("inform");
packages:
satelliteClient::
"$(JBoss_pkgs_x86_64)"
package_policy => "add",
package_method => yum_rpm_exact,
package_version => "$(JBoss_pkg_x86_64_ver[$(JBoss_pkgs_x86_64)])",
package_architectures => { "x86_64" },
action => actionsettings_fix_inform(inform);
"$(Java_pkgs_noarch)"
package_policy => "add",
package_method => yum_rpm_exact,
package_version => "$(JBoss_pkg_noarch_ver[$(JBoss_pkgs_noarch)])",
package_architectures => { "noarch" },
action => actionsettings_fix_inform(inform);
}
# Populates $(file) based on a template $(template_file).template at $(prefix) on host
# $(fileserver). Note that $(template_file).template, as well as any Cfengine-created
# backup copies of $(file) and $(template_file).template land in the same dir as
# $(file), so this bundle is inappropriate for use where those files would be
# grokked by a process (/etc/httpd/conf.d, for example).
bundle agent template_std_full(template_file, file, prefix, fileserver, mode, owner, group) {
files:
"$(template_file)"
copy_from => copy_std("$(prefix)$(template_file).template",
"$(fileserver)", "false", "timestamp"),
perms => mode_owner_group("$(mode)", "$(owner)", "$(group)"),
action => actionsettings_fix_inform("inform");
"$(file)"
perms => mode_owner_group("$(mode)", "$(owner)", "$(group)"),
create => "true",
edit_line => expand_variables("$(template_file)"),
# Using the full-featured body here because we need to empty the file
# client-side first.
edit_defaults => editsettings("timestamp", "true", "100K"),
action => actionsettings_fix_inform("inform");
}
CASSbx.localDev::
"java"
usebundle => java("1.6.0_33", "1");
"maven"
usebundle => maven("2.2.1", "1");
"jbossNode"
usebundle => jbossNode( "5.1.2", "2", "node00", "1", "vagrant", "eth0", "/usr/local/jboss-eap-5.1.2/jboss-as", "/usr/local/jboss-apps",
"/usr/local/jboss-deploy", "/var/log/jboss", "INFO", "30", "5", "SBXPARTITIONCAS01", "224.1.1.77",
"ports-default", "8080", "8440", "8780", "256m", "1024m", "2048m", "/usr/local/jdk1.6.0_33",
"/usr/local/etc/cacerts",
"-Djboss.proxyname=localhost -Djboss.proxyport=8443",
"-Xdebug -Xrunjdwp:transport=dt_socket,address=${DEBUGPORT},server=y,suspend=n -Dcom.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=true -Dcom.sun.xml.internal.ws.transport.http.HttpAdapter.dump=true -Dcom.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true -Dcom.sun.xml.ws.transport.http.HttpAdapter.dump=true"
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment