diff --git a/.fixtures.yml b/.fixtures.yml
new file mode 100644
index 0000000..e74c86f
--- /dev/null
+++ b/.fixtures.yml
@@ -0,0 +1,14 @@
+fixtures:
+ repositories:
+ stdlib:
+ repo: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
+ ref: "3.2.0"
+ concat:
+ repo: "https://github.com/puppetlabs/puppetlabs-concat.git"
+ ref: "1.0.0"
+ java:
+ repo: "https://github.com/puppetlabs/puppetlabs-java.git"
+ ref: "1.3.0"
+ symlinks:
+ jboss: "#{source_dir}"
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..9e9b3ab
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,13 @@
+pkg/
+Gemfile.lock
+.vendor
+spec/fixtures/
+.vagrant/
+.bundle/
+coverage/
+doc/
+.tmp/
+Puppetfile.lock
+.librarian/
+log
+Vagrantfile
diff --git a/.project b/.project
index aa46bb4..7f79aeb 100644
--- a/.project
+++ b/.project
@@ -1,12 +1,18 @@
- Puppet Module coi-jboss
+ jboss
+ Forge Module puppetlabs-java
- org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder
+ com.aptana.ide.core.unifiedBuilder
+
+
+
+
+ com.puppetlabs.geppetto.pp.dsl.ui.modulefileBuilder
@@ -17,7 +23,8 @@
- org.cloudsmith.geppetto.pp.dsl.ui.puppetNature
+ com.puppetlabs.geppetto.pp.dsl.ui.puppetNature
org.eclipse.xtext.ui.shared.xtextNature
+ com.aptana.ruby.core.rubynature
diff --git a/.rspec b/.rspec
new file mode 100644
index 0000000..210a1d6
--- /dev/null
+++ b/.rspec
@@ -0,0 +1,2 @@
+--format documentation
+--color
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..7a22d69
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,30 @@
+---
+language: ruby
+# TODO: GH Issue #4 - Try to execute standard Ruby builds on Travis CI on container infrastructure
+sudo: required
+install:
+ - sudo add-apt-repository -y ppa:raphink/augeas
+ - sudo apt-get update
+ - sudo apt-get install -y libaugeas-dev libxml2-dev
+ - bundle install --without development --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
+script: bundle exec rake test
+before_install: rm -f Gemfile.lock
+matrix:
+ fast_finish: true
+ include:
+ - rvm: '1.8'
+ env: PUPPET_VERSION="~> 2.7.0" FACTER_VERSION="~> 1.6.0"
+ - rvm: '1.8'
+ env: PUPPET_VERSION="~> 2.7.0" FACTER_VERSION="~> 1.7.0"
+ - rvm: '1.9'
+ env: PUPPET_VERSION="~> 3.0"
+ - rvm: '2.0'
+ env: PUPPET_VERSION="~> 3.0"
+ - rvm: '2.1'
+ env: PUPPET_VERSION="~> 3.0"
+ - rvm: '2.1'
+ env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES=yes
+ # FIXME: GH Issue #2 - Activate acceptance tests for centos-6, debian-7 and ubuntu-14.04 on Travis CI's Docker
+ # FIXME: GH Issue #3 - Activate acceptance tests on Travis CI for Puppet Enterprise, at least 2.8.8 and 3.8.2
+notifications:
+ email: false
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..b4a8f51
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,90 @@
+This module has grown over time based on a range of contributions from
+people using it. If you follow these contributing guidelines your patch
+will likely make it into a release a little quicker.
+
+
+## Contributing
+
+1. Fork the repo.
+
+2. Create your feature branch (`git checkout -b feature/my-new-feature`)
+
+3. Run the tests. We only take pull requests with passing tests, and
+ it's great to know that you have a clean slate
+
+4. Add a test for your change. Only refactoring and documentation
+ changes require no new tests. If you are adding functionality
+ or fixing a bug, please add a test.
+
+5. Make the test pass.
+
+6. Push to your fork and submit a pull request.
+
+
+## Dependencies
+
+The testing and development tools have a bunch of dependencies,
+all managed by [bundler](http://bundler.io/) according to the
+[Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions).
+
+By default the tests use a baseline version of Puppet.
+
+If you have Ruby 2.x or want a specific version of Puppet,
+you must set an environment variable such as:
+
+ export PUPPET_VERSION="~> 3.2.0"
+
+Install the dependencies like so... (you can also ass `--path /fs/path/for/deps` to fetch dependencies to other directory)
+
+ bundle install
+
+## Syntax and style
+
+The test suite will run [Puppet Lint](http://puppet-lint.com/) and
+[Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to
+check various syntax and style things. You can run these locally with:
+
+ bundle exec rake lint
+ bundle exec rake syntax
+
+## Running the unit tests
+
+The unit test suite covers most of the code, as mentioned above please
+add tests if you're adding new functionality. If you've not used
+[rspec-puppet](http://rspec-puppet.com/) before then feel free to ask
+about how best to test your new feature. Running the test suite is done
+with:
+
+ bundle exec rake spec
+
+Note also you can run the syntax, style and unit tests in one go with:
+
+ bundle exec rake test
+
+## Automatically run the Integration tests
+
+During development of your puppet module you might want to run your unit tests a couple of times. You can use the following command to automate running the unit tests on every change made in the manifests folder.
+
+ bundle exec guard
+
+## Integration tests
+
+The unit tests just check the code runs, not that it does exactly what
+we want on a real machine. For that we're using
+[beaker](https://github.com/puppetlabs/beaker).
+
+This fires up a new virtual machine (using vagrant) and runs a series of
+simple tests against it after applying the module. You can run this
+with:
+
+ bundle exec rake acceptance
+
+This will run the tests on an Ubuntu 14.04 virtual machine. You can also
+run the integration tests against Centos 6.5 with.
+
+ RS_SET=centos-65-x64-docker bundle exec rake acceptance
+
+If you don't want to have to recreate the virtual machine every time you
+can use `BEAKER_DESTROY=no` and `BEAKER_PROVISION=no`. On the first run you will
+at least need `BEAKER_PROVISION` set to yes (the default). The Vagrantfile
+for the created virtual machines will be in `.vagrant/beaker_vagrant_files`.
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..65db808
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,54 @@
+source ENV['GEM_SOURCE'] || 'https://rubygems.org'
+
+group :test do
+ gem 'rake', :require => false
+ gem 'rspec-puppet', :require => false
+ gem 'puppetlabs_spec_helper', :require => false
+ gem 'puppet-lint', :require => false
+ gem 'metadata-json-lint', :require => false
+ gem 'json', :require => false
+
+ if RUBY_VERSION >= '1.9.0'
+ gem 'beaker', :require => false
+ gem 'beaker-rspec', :require => false
+ gem 'docker-api', :require => false
+ gem 'coveralls', :require => false
+ gem 'codeclimate-test-reporter', :require => false
+ gem 'simplecov', :require => false
+ end
+ if facterver = ENV['FACTER_VERSION']
+ gem 'facter', facterver, :require => false
+ else
+ gem 'facter', :require => false
+ end
+ puppetver = if RUBY_VERSION < '1.9.0' then '~> 2.7.0' else ENV['PUPPET_VERSION'] end
+ if puppetver
+ gem 'puppet', puppetver, :require => false
+ if Gem::Requirement.new(puppetver) =~ Gem::Version.new('2.7.0')
+ gem 'hiera-puppet', :require => false
+ end
+ else
+ gem 'puppet', '~> 3.0', :require => false
+ end
+ gem 'ruby-augeas', :require => false
+ gem 'augeas', :require => false
+end
+
+group :development do
+ gem 'inch', :require => false
+ gem 'vagrant-wrapper', :require => false
+ if RUBY_VERSION >= '1.9.0'
+ gem 'travis', :require => false
+ gem 'puppet-blacksmith', :require => false
+ gem 'guard-rake', :require => false
+ if RUBY_VERSION >= '2.0.0'
+ gem 'pry-byebug', :require => false
+ else
+ gem 'pry-debugger', :require => false
+ end
+ end
+end
+
+eval(IO.read(File.join(File.dirname(__FILE__), 'Gemfile.ruby18')), binding) if RUBY_VERSION < '1.9.0'
+
+# vim:ft=ruby
diff --git a/Gemfile.ruby18 b/Gemfile.ruby18
new file mode 100644
index 0000000..549893c
--- /dev/null
+++ b/Gemfile.ruby18
@@ -0,0 +1,11 @@
+#!/usr/bin/env ruby
+# This is extra Gemfile for dependencies in old Ruby 1.8.x
+
+group :test do
+ gem 'rspec-its', :require => false
+ gem 'rspec', '~> 3.1.0', :require => false
+end
+
+group :development do
+ gem 'pry', '~> 0.9.12.0', :require => false
+end
diff --git a/Guardfile b/Guardfile
new file mode 100644
index 0000000..0d424a8
--- /dev/null
+++ b/Guardfile
@@ -0,0 +1,8 @@
+guard 'rake', :task => :spec_ruby do
+ watch(%r{spec/(unit|functions|hosts|integration|types)/.+_spec\.rb})
+ watch(%r{lib/.+\.rb})
+end
+guard 'rake', :task => :spec_puppet_prepared do
+ watch(%r{spec/(classes|defines)/.+_spec\.rb})
+ watch(%r{manifests/.+\.pp})
+end
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..557bb79
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2015 Centralny Ośrodek Informatyki
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/Modulefile b/Modulefile
deleted file mode 100644
index 16d0211..0000000
--- a/Modulefile
+++ /dev/null
@@ -1,9 +0,0 @@
-name 'coi-jboss'
-version '0.0.1'
-
-author 'pawel'
-license ''
-project_page ''
-source ''
-summary ''
-description ''
diff --git a/README.markdown b/README.markdown
deleted file mode 100644
index 7174814..0000000
--- a/README.markdown
+++ /dev/null
@@ -1,3 +0,0 @@
-# jboss #
-
-
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..abef4fc
--- /dev/null
+++ b/README.md
@@ -0,0 +1,449 @@
+# Puppet Module for JBoss EAP and Wildfly application servers
+
+[![Build Status](https://travis-ci.org/coi-gov-pl/puppet-jboss.svg?branch=develop)](https://travis-ci.org/coi-gov-pl/puppet-jboss) [![Code Climate](https://codeclimate.com/github/coi-gov-pl/puppet-jboss/badges/gpa.svg)](https://codeclimate.com/github/coi-gov-pl/puppet-jboss) [![Dependency Status](https://gemnasium.com/coi-gov-pl/puppet-jboss.svg)](https://gemnasium.com/coi-gov-pl/puppet-jboss) [![Coverage Status](https://coveralls.io/repos/coi-gov-pl/puppet-jboss/badge.svg?branch=develop&service=github)](https://coveralls.io/github/coi-gov-pl/puppet-jboss?branch=develop) [![Inline docs](http://inch-ci.org/github/coi-gov-pl/puppet-jboss.svg?branch=develop)](http://inch-ci.org/github/coi-gov-pl/puppet-jboss)
+
+#### Table of Contents
+
+1. [Overview](#overview)
+2. [Module Description - What the module does and why it is useful](#module-description)
+3. [Setup - The basics of getting started with JBoss](#setup)
+ * [What JBoss module affects](#what-jboss-module-affects)
+ * [Beginning with JBoss module](#beginning-with-jboss-module)
+4. [Class usage - Configuration options and additional functionality](#class-usage)
+5. [Defined Types Reference - Description for custom types given by this module](#defined-types-reference)
+6. [JBoss module standard metaparameters - description of metaparameters being used in most of the types](#jboss-module-standard-metaparameters)
+6. [Limitations - OS compatibility, etc.](#limitations)
+7. [Development - Guide for contributing to the module](#development)
+
+## Overview
+
+Installs and manages resources of JBoss EAP and Wildfly application servers. Supports resources like datasources, security domains, JMS queues, deployments and any other custom CLI based attributes and path.
+
+## Module Description
+
+The Center for Information Technology in Poland manage the JBoss application server farm. We were looking for a simple tool to support and automate the management of these servers in the spirit of DevOps. It should also be powerful enough to satisfy all, even future requirements. Nothing was able to meet our requirements, so we have designed and wrote the corresponding Puppet module.
+
+The module allows user to perform all necessary operations for JBoss such as:
+
+ * install and update application servers in several modes,
+ * support for JBoss AS, EAP, and WildFly,
+ * support for the family of operating systems: Red Hat and Debian,
+ * installation of internal JBoss modules and their generation of a set of libraries,
+ * a domain configuration mode (including the creation of virtual servers and groups of servers) and in standalone mode,
+ * JBoss user management,
+ * management of JBoss network interfaces,
+ * JPA datasource management, Security Domain JBoss, JMS queues, resource adapters and messages logging
+ * deployment and removing of artifacts
+
+In addition to the above list ready, convenient instructions, you can configure any JBoss CLI paths, along with the entire set of parameters. This allows you to configure any parameter supported by JBoss.
+
+## Setup
+
+### What JBoss module affects
+
+* This module installs JBoss Application Servers from zip files distributed by Red Hat. Those files are being extracted to target directory, by default: `/usr/lib/-/` for ex.: `/usr/lib/wildfly-8.2.0.Final`.
+* Module will also add service with name of `$jboss::product` for ex.: `/etc/init.d/wildfly`
+* By default module will install default Java JDK using `puppetlabs/java` module. This can be turned off by using `$jboss::java_autoinstall` variable or hiera key: `jboss::params::java_autoinstall`
+* By default module will install and use `wget` package to download zip files
+
+### Beginning with JBoss module
+
+To install JBoss Application Server you can use just, it will install Wildfly 8.2.0.Final by default:
+
+```puppet
+include jboss
+```
+
+To install JBoss EAP or older JBoss AS use:
+
+```puppet
+class { 'jboss':
+ product => 'jboss-eap',
+ version => '6.4.0.GA',
+}
+```
+
+or use hiera:
+
+```yaml
+jboss::params::product: 'jboss-as'
+jboss::params::version: '7.1.1.Final'
+```
+
+
+## Class usage
+
+### `jboss` class
+
+The `jboss` main class is used to install the application server itself. It can install it on default parameters but you can use then to customize installation procedure.
+
+Example:
+
+```puppet
+include jboss
+```
+
+**Parameters for `jboss` class:**
+
+#### `hostname`
+
+It is used to name jboss main `host.xml` key to distinguish from other hosts in distributed environment. By default is equals to `$::hostname` fact.
+
+Applicable Hiera key: `jboss::params::hostname`
+
+#### `product`
+
+Name of the JBoss product. Can be one of: `jboss-eap`, `jboss-as` or `wildfly`. By default this is equals to `wildfly`.
+
+Applicable Hiera key: `jboss::params::product`
+
+#### `jboss_user`
+
+The name of the user to be used as owner of JBoss files in filesystem. It will be also used to run JBoss processes. Be default it is equal to `jboss` for `jboss-eap` and `jboss-as` server and `wildfly` for `wildfly` server.
+
+Applicable Hiera key: `jboss::params::jboss_user`
+
+#### `jboss_group`
+
+The filesystem group to be used as a owner of JBoss files. By default it is equal to the same value as `$jboss::jboss_user`.
+
+#### `download_url`
+
+The download URL from which JBoss zip file will be downloaded. Be default it is equal to `http://download.jboss.org///-.zip`
+
+#### `java_autoinstall`
+
+This parameter is by default equal to `true` and if so it will install default Java JDK using `puppetlabs/java`
+
+Applicable Hiera key: `jboss::params::java_autoinstall`
+
+#### `java_version`
+
+This parameter is by default equals to `latest` and it is passed to `puppetlabs/java` module. You can give other values. For details look in [Puppetlabs/Java dodumentation](https://github.com/puppetlabs/puppetlabs-java)
+
+Applicable Hiera key: `jboss::params::java_version`
+
+#### `java_package`
+
+The name of Java JDK package to use. Be default it is used to `undef` and it is passed to `puppetlabs/java`. Possible values are: `jdk`, `jre`. For details look in [Puppetlabs/Java dodumentation](https://github.com/puppetlabs/puppetlabs-java)
+
+Applicable Hiera key: `jboss::params::java_package`
+
+#### `install_dir`
+
+The directory to use as installation home for JBoss Application Server. By default it is equal to `/usr/lib/-`
+
+Applicable Hiera key: `jboss::params::install_dir`
+
+#### `runasdomain`
+
+This parameter is used to configure JBoss server to run in domain or standalone mode. By default is equal to `false`, so JBoss runs in standalone mode. Set it to `true` to setup domain mode.
+
+Applicable Hiera key: `jboss::params::runasdomain`
+
+#### `enableconsole`
+
+This parameter is used to enable or disable access to JBoss management web console. It is equal to `false` by default, so the console is turned off.
+
+Applicable Hiera key: `jboss::params::enableconsole`
+
+#### `profile`
+
+JBoss profile to use. By default it is equal to `full`, which is the default profile in JBoss server. You can use any other default profile to start with: `full`, `ha`, `full-ha`.
+
+Applicable Hiera key: `jboss::params::profile`
+
+#### `prerequisites`
+
+The class to use as a JBoss prerequisites which will be processed before installation. By default is equal to `Class['jboss::internal::prerequisites']`. The default class is used to install `wget` package. If you would like to install `wget` in diffrent way, please write your class that does that and pass reference to it as this parameter
+
+#### `fetch_tool`
+
+This parameter is by default equal to `jboss::internal::util::download`. This is a default implementation for fetching files (mostly JBoss zip files) with `wget`. If you would like to use your own implementation, please write your custom define with the same interface as `jboss::internal::util::download` and pass it's name to this parameter.
+
+Applicable Hiera key: `jboss::params::fetch_tool`
+
+### `jboss::domain::controller` class
+
+This class will setup JBoss server to run as controller of the domain. It has no parameters.
+
+```puppet
+include jboss::domain::controller
+```
+### `jboss::domain::node` class
+
+This class will setup JBoss server to run as node of the domain. It takes two parameters: `ctrluser` and `ctrlpassword`. User name and password must be setup to JBoss controller. Easiest way to add jboss management user with `jboss::user` type.
+
+```puppet
+# same on both
+$user = 'jb-user'
+$passwd = 'SeC3eT!1'
+
+# on controller
+jboss::user { $user:
+ ensure => 'present',
+ password => $passwd,
+}
+
+# on node
+class { 'jboss::domain::node':
+ ctrluser => $user,
+ ctrlpassword => $passwd,
+}
+```
+
+## Defined Types Reference
+
+### `jboss::datasource` defined type
+
+This defined type can be used to add and remove JBoss data sources. It support both XA and Non-XA data sources. It can setup data sources and manage required drivers.
+
+```puppet
+# Non-XA data source
+jboss::datasource { 'test-datasource':
+ ensure => 'present',
+ username => 'test-username',
+ password => 'test-password',
+ jdbcscheme => 'h2:mem',
+ dbname => 'testing;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE',
+ host => '',
+ port => '',
+ driver => {
+ 'name' => 'h2',
+ }
+}
+# XA data source
+jboss::datasource { 'test-xa-datasource':
+ ensure => 'present',
+ xa => true,
+ username => 'test-username',
+ password => 'test-password',
+ jdbcscheme => 'h2:mem',
+ dbname => 'testing-xa;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE',
+ host => '',
+ port => '',
+ driver => {
+ 'name' => 'h2',
+ 'driver-xa-datasource-class-name' => 'org.h2.jdbcx.JdbcDataSource'
+ }
+}
+```
+
+**Parameters for `jboss::datasource`:**
+
+This type uses [JBoss module standard metaparameters](#jboss-module-standard-metaparameters)
+
+#### `jdbcscheme` parameter
+
+**Required parameter.** This is the JDBC scheme for ex.: `postgresql`, `oracle`, `mysql`, `mssql` or `h2:mem`. All accepted by JBoss JDBC shemes are valid.
+
+#### `host` parameter
+
+**Required parameter.** This is the name of the database host or it's IP address. Pass empty string `''` if host isn't needed.
+
+#### `port` parameter
+
+**Required parameter.** This is the port of the database. Pass empty string `''` if port isn't needed.
+
+#### `username` parameter
+
+**Required parameter.** This is the user name that will be used to connect to database.
+
+#### `password` parameter
+
+**Required parameter.** This is the password that will be used to connect to database.
+
+#### `dbname` parameter
+
+**This is the namevar.** Name of the database to be used.
+
+#### `ensure` parameter
+
+Standard ensure parameter. Can be either `present` or `absent`.
+
+#### `jndiname` parameter
+
+Java JNDI name of the datasource. Be default it is equals to `java:jboss/datasources/`
+
+#### `xa` parameter
+
+This parameters indicate that given data source should XA or Non-XA type. Be default this is equal to `false`
+
+#### `jta` parameter
+
+This parameters indicate that given data source should support Java JTA transactions. Be default this is equal to `true`
+
+#### `minpoolsize` parameter
+
+Minimum connections in connection pool. By default it is equal to `1`.
+
+#### `maxpoolsize` parameter
+
+Maximum connections in connection pool. By default it is equal to `50`.
+
+#### `enabled` parameter
+
+This parameter control whether given data source should be enabled or not. By default it is equal to `true`.
+
+#### `options` parameter
+
+This is an extra options hash. You can give any additional options that will be passed directly to JBoss data source. Any supported by JBoss values will be accepted and enforced. Values that are not mentioned are not processed.
+
+Default options added to every data source (they can be overwritten):
+
+ - `validate-on-match` => `false`
+ - `background-validation` => `false`
+ - `share-prepared-statements` => `false`
+ - `prepared-statements-cache-size` => `0`
+
+Default options added to every XA data source (they can be overwritten):
+
+ - `same-rm-override` => `true`
+ - `wrap-xa-resource` => `true`
+
+### `jboss::jmsqueue` defined type
+
+Use this defined type to add and remove JBoss JMS Queues.
+
+```puppet
+jboss::jmsqueue { 'app-mails':
+ ensure => 'present',
+ durable => true,
+ entries => [
+ 'queue/app-mails',
+ 'java:jboss/exported/jms/queue/app-mails',
+ ],
+}
+```
+
+**Parameters for `jboss::jmsqueue`:**
+
+This type uses [JBoss module standard metaparameters](#jboss-module-standard-metaparameters)
+
+#### `entries` parameter
+
+A list of JNDI entries for JBoss JMS Queue. You can specify any number of entries from which your queue will be visible inside your application.
+
+#### `ensure` parameter
+
+Standard ensure parameter. Can be either `present` or `absent`.
+
+#### `durable` parameter
+
+This parameter indicate that given JMS queue should be durable or not. By default this is equal to `false`.
+
+### `jboss::user` defined type
+
+Use this defined type to add and remove JBoss management and application users, manage their passwords and roles.
+
+```puppet
+jboss::user { 'admin':
+ ensure => 'present',
+ realm => 'ManagementRealm',
+ password => 'seCret1!',
+}
+```
+
+**Parameters of `jboss::user`:**
+
+#### `password` parameter
+
+**Required parameter.** This is password that will be used for user.
+
+#### `ensure` parameter
+
+Standard ensure parameter. Can be either `present` or `absent`.
+
+#### `user` parameter
+
+This is the namevar. Name of user to manage.
+
+#### `realm` parameter
+
+This is by default equal to `ManagementRealm`. It can be equal also to `ApplicationRealm`.
+
+#### `roles` parameter
+
+This is by default equal to `undef`. You can pass a list of roles in form of string delimited by `,` sign.
+
+### `jboss::clientry` defined type
+
+This define is very versitale. It can be used to add or remove any JBoss CLI entry. You can pass any number of properties for given CLI path and each one will be manage, other parameters will not be changed.
+
+```puppet
+jboss::clientry { '/subsystem=messaging/hornetq-server=default':
+ ensure => 'present',
+ properties => {
+ 'security-enabled' => false,
+ }
+}
+```
+
+**Parameters of `jboss::clientry`**:
+
+This type uses [JBoss module standard metaparameters](#jboss-module-standard-metaparameters)
+
+#### `ensure` parameter
+
+Standard ensure parameter. Can be either `present` or `absent`.
+
+#### `path` parameter
+
+This is the namevar. Path of the CLI entry. This is path accepted by JBoss CLI. The path must be passed without `/profile=` in domain mode as well (for that `profile` parameter must be used).
+
+#### `properties` parameter
+
+This is optional properties hash. You can pass any valid JBoss properties for given `path`. For valid ones head to the JBoss Application Server documentation. Must be hash object or `undef` value.
+
+#### `dorestart` parameter
+
+This parameter forces to execute command `:restart()` on this CLI entry.
+
+## JBoss module standard metaparameters
+
+
+### `runasdomain` parameter
+
+Describe that this define should be evaluated as domain or standalone. Default value is taken from `jboss` class. If you override `runasdomain` parameter there you do not need to set it with this parameter explicitly.
+
+### `profile` parameter
+
+On with JBoss profile do apply. Default value is taken from `jboss` class. If you override `profile` parameter there you do not need to set it with this parameter explicitly.
+
+### `controller` parameter
+
+To with controller connect to. By default it is equals to `127.0.0.1:9999` on jboss servers and `127.0.0.1:9990` on wildfly server. Default value is taken from `jboss` class. If you override `controller` parameter there you do not need to set it with this parameter explicitly.
+
+
+## Limitations
+
+This module is explicitly tested on:
+
+* Oracle Linux 6.x, CentOS 6.x
+* Ubuntu Server LTS 14.04
+
+Compatible with:
+
+* Red Hat Enterprise Linux: 5.x, 6.x
+* CentOS: 5.x, 6.x
+* Scientific: 5.x, 6.x
+* Oracle Linux: 5.x
+* Debian: 6.x, 7.x
+* Ubuntu Server LTS 12.04, 10.04
+
+Supported Puppet versions:
+
+* Puppet OSS: 2.7.x, 3.x
+* Puppet Enterprise: 2.8.x, 3.x
+
+## Development
+
+To contribute to this module please read carefully the [CONTRIBUTING.md](https://github.com/coi-gov-pl/puppet-jboss/blob/develop/CONTRIBUTING.md)
+
+## Release Notes
+
+* `1.0.0`
+ * First publicly available version
+ * Support for JBoss EAP, JBoss AS and Wildfly
+ * Support for JPA datasource management, Security Domain JBoss, JMS queues, resource adapters and messages logging
+ * Supoort for deploying artifacts
diff --git a/Rakefile b/Rakefile
index 14f1c24..9cdc236 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,2 +1,73 @@
require 'rubygems'
require 'puppetlabs_spec_helper/rake_tasks'
+require 'puppet-lint/tasks/puppet-lint'
+
+# These two gems aren't always present, for instance
+# on Travis with --without development
+begin
+ require 'puppet_blacksmith/rake_tasks'
+rescue LoadError
+end
+
+PuppetLint.configuration.send('disable_80chars')
+PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
+PuppetLint.configuration.fail_on_warnings = true
+
+desc "Validate manifests, templates, and ruby files"
+task :validate do
+ Dir['manifests/**/*.pp'].each do |manifest|
+ sh "puppet parser validate --noop #{manifest}"
+ end
+ Dir['templates/**/*.erb'].each do |template|
+ sh "erb -P -x -T '-' #{template} | ruby -c"
+ end
+end
+
+Rake::Task[:spec_standalone].clear
+desc "Run spec tests on an existing fixtures directory (for Puppet code)"
+RSpec::Core::RakeTask.new(:spec_puppet) do |t|
+ t.rspec_opts = ['--color --order rand']
+ t.pattern = 'spec/{classes,defines}/**/*_spec.rb'
+end
+desc "Run spec tests on an existing fixtures directory (for Ruby code)"
+RSpec::Core::RakeTask.new(:spec_ruby) do |t|
+ t.rspec_opts = ['--color --order rand']
+ t.verbose = true
+ t.pattern = 'spec/{unit,functions,hosts,integration,types}/**/*_spec.rb'
+end
+desc 'Run spec tests on an existing fixtures directory'
+task :spec_standalone => [
+ :spec_puppet,
+ :spec_ruby
+]
+
+task :spec_puppet_prepared => [
+ :spec_prep,
+ :spec_puppet
+]
+
+begin
+ require 'beaker'
+ desc "Run acceptance tests"
+ RSpec::Core::RakeTask.new(:acceptance) do |t|
+ t.pattern = 'spec/acceptance'
+ end
+rescue LoadError
+ task :acceptance do
+ $stderr.puts 'Beaker is not avialable, skipping acceptance tests'
+ end
+end
+
+desc "Clean fixtures"
+task :clean_fixtures do
+ FileUtils.rmtree 'spec/fixtures/modules'
+end
+
+desc "Run syntax, lint, and spec tests."
+task :test => [
+ :metadata,
+ :validate,
+ :clean_fixtures,
+ :lint,
+ :spec,
+]
diff --git a/files/jbxml.aug b/files/jbxml.aug
new file mode 100644
index 0000000..c950462
--- /dev/null
+++ b/files/jbxml.aug
@@ -0,0 +1,144 @@
+(* XML lens for Augeas
+ Author: Francis Giraldeau
+
+ Reference: http://www.w3.org/TR/2006/REC-xml11-20060816/
+*)
+
+module JBXml =
+
+autoload xfm
+
+(************************************************************************
+ * Utilities lens
+ *************************************************************************)
+
+let dels (s:string) = del s s
+let spc = /[ \t\n]+/
+let osp = /[ \t\n]*/
+let sep_spc = del /[ \t\n]+/ " "
+let sep_osp = del /[ \t\n]*/ ""
+let sep_eq = del /[ \t\n]*=[ \t\n]*/ "="
+
+let nmtoken = /[a-zA-Z:_][a-zA-Z0-9:_.-]*/
+let word = /[a-zA-Z][a-zA-Z0-9._-]*/
+let char = /.|\n/
+(* if we hide the quotes, then we can only accept single or double quotes *)
+(* otherwise a put ambiguity is raised *)
+let sto_dquote = dels "\"" . store /[^"]*/ . dels "\""
+let sto_squote = dels "'" . store /[^']*/ . dels "'"
+
+let comment = [ label "#comment" .
+ dels "" ]
+
+let pi_target = nmtoken - /[Xx][Mm][Ll]/
+let empty = Util.empty
+let del_end = del />[\n]?/ ">\n"
+let del_end_simple = dels ">"
+
+(* This is siplified version of processing instruction
+ * pi has to not start or end with a white space and the string
+ * must not contain "?>". We restrict too much by not allowing any
+ * "?" nor ">" in PI
+ *)
+let pi = /[^ \n\t]|[^ \n\t][^?>]*[^ \n\t]/
+
+(************************************************************************
+ * Attributes
+ *************************************************************************)
+
+
+let decl = [ label "#decl" . sep_spc .
+ store /[^> \t\n\r]|[^> \t\n\r][^>\t\n\r]*[^> \t\n\r]/ ]
+
+let decl_def (r:regexp) (b:lens) = [ dels "<" . key r .
+ sep_spc . store word .
+ b . sep_osp . del_end_simple ]
+
+let elem_def = decl_def /!ELEMENT/ decl
+
+let enum = "(" . osp . nmtoken . ( osp . "|" . osp . nmtoken )* . osp . ")"
+
+let att_type = /CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/ |
+ enum
+
+let id_def = [ sep_spc . key /PUBLIC/ .
+ [ label "#literal" . sep_spc . sto_dquote ]* ] |
+ [ sep_spc . key /SYSTEM/ . sep_spc . sto_dquote ]
+
+let notation_def = decl_def /!NOTATION/ id_def
+
+let att_def = counter "att_id" .
+ [ sep_spc . seq "att_id" .
+ [ label "#name" . store word . sep_spc ] .
+ [ label "#type" . store att_type . sep_spc ] .
+ ([ key /#REQUIRED|#IMPLIED/ ] |
+ [ label "#FIXED" . del /#FIXED[ \n\t]*|/ "" . sto_dquote ]) ]*
+
+let att_list_def = decl_def /!ATTLIST/ att_def
+
+let entity_def = decl_def /!ENTITY/ ([sep_spc . label "#decl" . sto_dquote ])
+
+let decl_def_item = elem_def | entity_def | att_list_def | notation_def
+
+let decl_outer = sep_osp . del /\[[ \n\t\r]*/ "[\n" .
+ (decl_def_item . sep_osp )* . dels "]"
+
+(* let dtd_def = [ sep_spc . key "SYSTEM" . sep_spc . sto_dquote ] *)
+
+let doctype = decl_def /!DOCTYPE/ (decl_outer|id_def)
+
+let attributes = [ label "#attribute" .
+ [ sep_spc . key nmtoken . sep_eq . sto_dquote ]+ ]
+let attributes_sq = [ label "#attribute" .
+ [ sep_spc . key nmtoken . sep_eq . sto_squote ]+ ]
+
+
+let prolog = [ label "#declaration" .
+ dels "" ]
+
+
+(************************************************************************
+ * Tags
+ *************************************************************************)
+
+(* we consider entities as simple text *)
+let text_re = /[^<]+/ - /([^<]*\]\]>[^<]*)/
+let text = [ label "#text" . store text_re ]
+let cdata = [ label "#CDATA" . dels "" . char*)) . dels "]]>" ]
+
+let element (body:lens) =
+ let h = attributes? . sep_osp . dels ">" . body* . dels "" in
+ [ dels "<" . square nmtoken h . sep_osp . del_end ]
+
+let empty_element = [ dels "<" . key nmtoken . value "#empty" .
+ attributes? . sep_osp . del /\/>[\n]?/ "/>\n" ]
+
+let pi_instruction = [ dels "" . label "#pi" .
+ [ label "#target" . store pi_target ] .
+ [ sep_spc . label "#instruction" . store pi ]? .
+ sep_osp . del /\?>/ "?>" ]
+
+(* Typecheck is weaker on rec lens, detected by unfolding *)
+(*
+let content1 = element text
+let rec content2 = element (content1|text|comment)
+*)
+
+let rec content = element (text|comment|content|empty_element|pi_instruction)
+
+(* Constraints are weaker here, but it's better than being too strict *)
+let doc = (sep_osp . (prolog | comment | doctype | pi_instruction))* .
+ ((sep_osp . content) | (sep_osp . empty_element)) .
+ (sep_osp . (comment | pi_instruction ))* . sep_osp
+
+let lns = doc
+
+let filter = (excl "*")
+
+let xfm = transform lns filter
diff --git a/files/rhel-initd-functions.sh b/files/rhel-initd-functions.sh
new file mode 100644
index 0000000..e857864
--- /dev/null
+++ b/files/rhel-initd-functions.sh
@@ -0,0 +1,815 @@
+# -*-Shell-script-*-
+#
+# functions This file contains functions to be used by most or all
+# shell scripts in the /etc/init.d directory.
+#
+
+TEXTDOMAIN=initscripts
+
+# Make sure umask is sane
+umask 022
+
+# Set up a default search path.
+PATH="/sbin:/usr/sbin:/bin:/usr/bin"
+export PATH
+
+# Get a sane screen width
+[ -z "${COLUMNS:-}" ] && COLUMNS=80
+
+[ -z "${CONSOLETYPE:-}" ] && CONSOLETYPE="$(/sbin/consoletype)"
+
+if [ -f /etc/sysconfig/i18n -a -z "${NOLOCALE:-}" -a -z "${LANGSH_SOURCED:-}" ] ; then
+ . /etc/profile.d/lang.sh 2>/dev/null
+ # avoid propagating LANGSH_SOURCED any further
+ unset LANGSH_SOURCED
+fi
+
+# Read in our configuration
+if [ -z "${BOOTUP:-}" ]; then
+ if [ -f /etc/sysconfig/init ]; then
+ . /etc/sysconfig/init
+ else
+ # This all seem confusing? Look in /etc/sysconfig/init,
+ # or in /usr/doc/initscripts-*/sysconfig.txt
+ BOOTUP=color
+ RES_COL=60
+ MOVE_TO_COL="echo -en \\033[${RES_COL}G"
+ SETCOLOR_SUCCESS="echo -en \\033[1;32m"
+ SETCOLOR_FAILURE="echo -en \\033[1;31m"
+ SETCOLOR_WARNING="echo -en \\033[1;33m"
+ SETCOLOR_NORMAL="echo -en \\033[0;39m"
+ LOGLEVEL=1
+ fi
+ if [ "$CONSOLETYPE" = "serial" ]; then
+ BOOTUP=serial
+ MOVE_TO_COL=
+ SETCOLOR_SUCCESS=
+ SETCOLOR_FAILURE=
+ SETCOLOR_WARNING=
+ SETCOLOR_NORMAL=
+ fi
+fi
+
+# Interpret escape sequences in an fstab entry
+fstab_decode_str() {
+ fstab-decode echo "$1"
+}
+
+# Check if any of $pid (could be plural) are running
+checkpid() {
+ local i
+
+ for i in $* ; do
+ [ -d "/proc/$i" ] && return 0
+ done
+ return 1
+}
+
+__readlink() {
+ ls -bl "$@" 2>/dev/null| awk '{ print $NF }'
+}
+
+__fgrep() {
+ s=$1
+ f=$2
+ while read line; do
+ if strstr "$line" "$s"; then
+ echo $line
+ return 0
+ fi
+ done < $f
+ return 1
+}
+
+# __umount_loop awk_program fstab_file first_msg retry_msg retry_umount_args
+# awk_program should process fstab_file and return a list of fstab-encoded
+# paths; it doesn't have to handle comments in fstab_file.
+__umount_loop() {
+ local remaining sig=
+ local retry=3 count
+
+ remaining=$(LC_ALL=C awk "/^#/ {next} $1" "$2" | sort -r)
+ while [ -n "$remaining" -a "$retry" -gt 0 ]; do
+ if [ "$retry" -eq 3 ]; then
+ action "$3" fstab-decode umount $remaining
+ else
+ action "$4" fstab-decode umount $5 $remaining
+ fi
+ count=4
+ remaining=$(LC_ALL=C awk "/^#/ {next} $1" "$2" | sort -r)
+ while [ "$count" -gt 0 ]; do
+ [ -z "$remaining" ] && break
+ count=$(($count-1))
+ usleep 500000
+ remaining=$(LC_ALL=C awk "/^#/ {next} $1" "$2" | sort -r)
+ done
+ [ -z "$remaining" ] && break
+ kill $sig $(fstab-decode /sbin/fuser -m $remaining 2>/dev/null | sed -e "s/\b$$\b//g") > /dev/null
+ sleep 3
+ retry=$(($retry -1))
+ sig=-9
+ done
+}
+
+# Similar to __umount loop above, specialized for loopback devices
+__umount_loopback_loop() {
+ local remaining devremaining sig=
+ local retry=3
+
+ remaining=$(awk '$1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts)
+ devremaining=$(awk '$1 ~ /^\/dev\/loop/ && $2 != "/" {print $1}' /proc/mounts)
+ while [ -n "$remaining" -a "$retry" -gt 0 ]; do
+ if [ "$retry" -eq 3 ]; then
+ action $"Unmounting loopback filesystems: " \
+ fstab-decode umount $remaining
+ else
+ action $"Unmounting loopback filesystems (retry):" \
+ fstab-decode umount $remaining
+ fi
+ for dev in $devremaining ; do
+ losetup $dev > /dev/null 2>&1 && \
+ action $"Detaching loopback device $dev: " \
+ losetup -d $dev
+ done
+ remaining=$(awk '$1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts)
+ devremaining=$(awk '$1 ~ /^\/dev\/loop/ && $2 != "/" {print $1}' /proc/mounts)
+ [ -z "$remaining" ] && break
+ fstab-decode /sbin/fuser -k -m $sig $remaining >/dev/null
+ sleep 3
+ retry=$(($retry -1))
+ sig=-9
+ done
+}
+
+# __proc_pids {program} [pidfile]
+# Set $pid to pids from /var/run* for {program}. $pid should be declared
+# local in the caller.
+# Returns LSB exit code for the 'status' action.
+__pids_var_run() {
+ local base=${1##*/}
+ local pid_file=${2:-/var/run/$base.pid}
+ local pid_dir=$(/usr/bin/dirname $pid_file)
+ local binary=$3
+
+ [ -d "$pid_dir" -a ! -r "$pid_dir" ] && return 4
+
+ pid=
+ if [ -f "$pid_file" ] ; then
+ local line p
+
+ [ ! -r "$pid_file" ] && return 4 # "user had insufficient privilege"
+ while : ; do
+ read line
+ [ -z "$line" ] && break
+ for p in $line ; do
+ if [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] ; then
+ if [ -n "$binary" ] ; then
+ local b=$(readlink /proc/$p/exe | sed -e 's/\s*(deleted)$//')
+ [ "$b" != "$binary" ] && continue
+ fi
+ pid="$pid $p"
+ fi
+ done
+ done < "$pid_file"
+
+ if [ -n "$pid" ]; then
+ return 0
+ fi
+ return 1 # "Program is dead and /var/run pid file exists"
+ fi
+ return 3 # "Program is not running"
+}
+
+# Output PIDs of matching processes, found using pidof
+__pids_pidof() {
+ pidof -c -o $$ -o $PPID -o %PPID -x "$1" || \
+ pidof -c -o $$ -o $PPID -o %PPID -x "${1##*/}"
+}
+
+
+# A function to start a program.
+daemon() {
+ # Test syntax.
+ local gotbase= force= nicelevel corelimit
+ local pid base= user= nice= bg= pid_file=
+ local cgroup=
+ nicelevel=0
+ while [ "$1" != "${1##[-+]}" ]; do
+ case $1 in
+ '') echo $"$0: Usage: daemon [+/-nicelevel] {program}"
+ return 1;;
+ --check)
+ base=$2
+ gotbase="yes"
+ shift 2
+ ;;
+ --check=?*)
+ base=${1#--check=}
+ gotbase="yes"
+ shift
+ ;;
+ --user)
+ user=$2
+ shift 2
+ ;;
+ --user=?*)
+ user=${1#--user=}
+ shift
+ ;;
+ --pidfile)
+ pid_file=$2
+ shift 2
+ ;;
+ --pidfile=?*)
+ pid_file=${1#--pidfile=}
+ shift
+ ;;
+ --force)
+ force="force"
+ shift
+ ;;
+ [-+][0-9]*)
+ nice="nice -n $1"
+ shift
+ ;;
+ *) echo $"$0: Usage: daemon [+/-nicelevel] {program}"
+ return 1;;
+ esac
+ done
+
+ # Save basename.
+ [ -z "$gotbase" ] && base=${1##*/}
+
+ # See if it's already running. Look *only* at the pid file.
+ __pids_var_run "$base" "$pid_file"
+
+ [ -n "$pid" -a -z "$force" ] && return
+
+ # make sure it doesn't core dump anywhere unless requested
+ corelimit="ulimit -S -c ${DAEMON_COREFILE_LIMIT:-0}"
+
+ # if they set NICELEVEL in /etc/sysconfig/foo, honor it
+ [ -n "${NICELEVEL:-}" ] && nice="nice -n $NICELEVEL"
+
+ # if they set CGROUP_DAEMON in /etc/sysconfig/foo, honor it
+ if [ -n "${CGROUP_DAEMON}" ]; then
+ if [ ! -x /bin/cgexec ]; then
+ echo -n "Cgroups not installed"; warning
+ echo
+ else
+ cgroup="/bin/cgexec";
+ for i in $CGROUP_DAEMON; do
+ cgroup="$cgroup -g $i";
+ done
+ fi
+ fi
+
+ # Echo daemon
+ [ "${BOOTUP:-}" = "verbose" -a -z "${LSB:-}" ] && echo -n " $base"
+
+ # And start it up.
+ if [ -z "$user" ]; then
+ $cgroup $nice /bin/bash -c "$corelimit >/dev/null 2>&1 ; $*"
+ else
+ $cgroup $nice runuser -s /bin/bash $user -c "$corelimit >/dev/null 2>&1 ; $*"
+ fi
+
+ [ "$?" -eq 0 ] && success $"$base startup" || failure $"$base startup"
+}
+
+# A function to stop a program.
+killproc() {
+ local RC killlevel= base pid pid_file= delay try binary=
+
+ RC=0; delay=3; try=0
+ # Test syntax.
+ if [ "$#" -eq 0 ]; then
+ echo $"Usage: killproc [-p pidfile] [ -d delay] {program} [-signal]"
+ return 1
+ fi
+ if [ "$1" = "-p" ]; then
+ pid_file=$2
+ shift 2
+ fi
+ if [ "$1" = "-b" ]; then
+ if [ -z $pid_file ]; then
+ echo $"-b option can be used only with -p"
+ echo $"Usage: killproc -p pidfile -b binary program"
+ return 1
+ fi
+ binary=$2
+ shift 2
+ fi
+ if [ "$1" = "-d" ]; then
+ delay=$(echo $2 | awk -v RS=' ' -v IGNORECASE=1 '{if($1!~/^[0-9.]+[smhd]?$/) exit 1;d=$1~/s$|^[0-9.]*$/?1:$1~/m$/?60:$1~/h$/?60*60:$1~/d$/?24*60*60:-1;if(d==-1) exit 1;delay+=d*$1} END {printf("%d",delay+0.5)}')
+ if [ "$?" -eq 1 ]; then
+ echo $"Usage: killproc [-p pidfile] [ -d delay] {program} [-signal]"
+ return 1
+ fi
+ shift 2
+ fi
+
+
+ # check for second arg to be kill level
+ [ -n "${2:-}" ] && killlevel=$2
+
+ # Save basename.
+ base=${1##*/}
+
+ # Find pid.
+ __pids_var_run "$1" "$pid_file" "$binary"
+ RC=$?
+ if [ -z "$pid" ]; then
+ if [ -z "$pid_file" ]; then
+ pid="$(__pids_pidof "$1")"
+ else
+ [ "$RC" = "4" ] && { failure $"$base shutdown" ; return $RC ;}
+ fi
+ fi
+
+ # Kill it.
+ if [ -n "$pid" ] ; then
+ [ "$BOOTUP" = "verbose" -a -z "${LSB:-}" ] && echo -n "$base "
+ if [ -z "$killlevel" ] ; then
+ if checkpid $pid 2>&1; then
+ # TERM first, then KILL if not dead
+ kill -TERM $pid >/dev/null 2>&1
+ usleep 100000
+ if checkpid $pid ; then
+ try=0
+ while [ $try -lt $delay ] ; do
+ checkpid $pid || break
+ sleep 1
+ let try+=1
+ done
+ if checkpid $pid ; then
+ kill -KILL $pid >/dev/null 2>&1
+ usleep 100000
+ fi
+ fi
+ fi
+ checkpid $pid
+ RC=$?
+ [ "$RC" -eq 0 ] && failure $"$base shutdown" || success $"$base shutdown"
+ RC=$((! $RC))
+ # use specified level only
+ else
+ if checkpid $pid; then
+ kill $killlevel $pid >/dev/null 2>&1
+ RC=$?
+ [ "$RC" -eq 0 ] && success $"$base $killlevel" || failure $"$base $killlevel"
+ elif [ -n "${LSB:-}" ]; then
+ RC=7 # Program is not running
+ fi
+ fi
+ else
+ if [ -n "${LSB:-}" -a -n "$killlevel" ]; then
+ RC=7 # Program is not running
+ else
+ failure $"$base shutdown"
+ RC=0
+ fi
+ fi
+
+ # Remove pid file if any.
+ if [ -z "$killlevel" ]; then
+ rm -f "${pid_file:-/var/run/$base.pid}"
+ fi
+ return $RC
+}
+
+# A function to find the pid of a program. Looks *only* at the pidfile
+pidfileofproc() {
+ local pid
+
+ # Test syntax.
+ if [ "$#" = 0 ] ; then
+ echo $"Usage: pidfileofproc {program}"
+ return 1
+ fi
+
+ __pids_var_run "$1"
+ [ -n "$pid" ] && echo $pid
+ return 0
+}
+
+# A function to find the pid of a program.
+pidofproc() {
+ local RC pid pid_file=
+
+ # Test syntax.
+ if [ "$#" = 0 ]; then
+ echo $"Usage: pidofproc [-p pidfile] {program}"
+ return 1
+ fi
+ if [ "$1" = "-p" ]; then
+ pid_file=$2
+ shift 2
+ fi
+ fail_code=3 # "Program is not running"
+
+ # First try "/var/run/*.pid" files
+ __pids_var_run "$1" "$pid_file"
+ RC=$?
+ if [ -n "$pid" ]; then
+ echo $pid
+ return 0
+ fi
+
+ [ -n "$pid_file" ] && return $RC
+ __pids_pidof "$1" || return $RC
+}
+
+status() {
+ local base pid lock_file= pid_file= binary=
+
+ # Test syntax.
+ if [ "$#" = 0 ] ; then
+ echo $"Usage: status [-p pidfile] {program}"
+ return 1
+ fi
+ if [ "$1" = "-p" ]; then
+ pid_file=$2
+ shift 2
+ fi
+ if [ "$1" = "-l" ]; then
+ lock_file=$2
+ shift 2
+ fi
+ if [ "$1" = "-b" ]; then
+ if [ -z $pid_file ]; then
+ echo $"-b option can be used only with -p"
+ echo $"Usage: status -p pidfile -b binary program"
+ return 1
+ fi
+ binary=$2
+ shift 2
+ fi
+ base=${1##*/}
+
+ # First try "pidof"
+ __pids_var_run "$1" "$pid_file" "$binary"
+ RC=$?
+ if [ -z "$pid_file" -a -z "$pid" ]; then
+ pid="$(__pids_pidof "$1")"
+ fi
+ if [ -n "$pid" ]; then
+ echo $"${base} (pid $pid) is running..."
+ return 0
+ fi
+
+ case "$RC" in
+ 0)
+ echo $"${base} (pid $pid) is running..."
+ return 0
+ ;;
+ 1)
+ echo $"${base} dead but pid file exists"
+ return 1
+ ;;
+ 4)
+ echo $"${base} status unknown due to insufficient privileges."
+ return 4
+ ;;
+ esac
+ if [ -z "${lock_file}" ]; then
+ lock_file=${base}
+ fi
+ # See if /var/lock/subsys/${lock_file} exists
+ if [ -f /var/lock/subsys/${lock_file} ]; then
+ echo $"${base} dead but subsys locked"
+ return 2
+ fi
+ echo $"${base} is stopped"
+ return 3
+}
+
+echo_success() {
+ [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
+ echo -n "["
+ [ "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS
+ echo -n $" OK "
+ [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
+ echo -n "]"
+ echo -ne "\r"
+ return 0
+}
+
+echo_failure() {
+ [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
+ echo -n "["
+ [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
+ echo -n $"FAILED"
+ [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
+ echo -n "]"
+ echo -ne "\r"
+ return 1
+}
+
+echo_passed() {
+ [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
+ echo -n "["
+ [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
+ echo -n $"PASSED"
+ [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
+ echo -n "]"
+ echo -ne "\r"
+ return 1
+}
+
+echo_warning() {
+ [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
+ echo -n "["
+ [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
+ echo -n $"WARNING"
+ [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
+ echo -n "]"
+ echo -ne "\r"
+ return 1
+}
+
+# Inform the graphical boot of our current state
+update_boot_stage() {
+ if [ -x /bin/plymouth ]; then
+ /bin/plymouth --update="$1"
+ fi
+ return 0
+}
+
+# Log that something succeeded
+success() {
+ [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_success
+ return 0
+}
+
+# Log that something failed
+failure() {
+ local rc=$?
+ [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_failure
+ [ -x /bin/plymouth ] && /bin/plymouth --details
+ return $rc
+}
+
+# Log that something passed, but may have had errors. Useful for fsck
+passed() {
+ local rc=$?
+ [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_passed
+ return $rc
+}
+
+# Log a warning
+warning() {
+ local rc=$?
+ [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_warning
+ return $rc
+}
+
+# Run some action. Log its output.
+action() {
+ local STRING rc
+
+ STRING=$1
+ echo -n "$STRING "
+ shift
+ "$@" && success $"$STRING" || failure $"$STRING"
+ rc=$?
+ echo
+ return $rc
+}
+
+# returns OK if $1 contains $2
+strstr() {
+ [ "${1#*$2*}" = "$1" ] && return 1
+ return 0
+}
+
+# Confirm whether we really want to run this service
+confirm() {
+ [ -x /bin/plymouth ] && /bin/plymouth --hide-splash
+ while : ; do
+ echo -n $"Start service $1 (Y)es/(N)o/(C)ontinue? [Y] "
+ read answer
+ if strstr $"yY" "$answer" || [ "$answer" = "" ] ; then
+ return 0
+ elif strstr $"cC" "$answer" ; then
+ rm -f /var/run/confirm
+ [ -x /bin/plymouth ] && /bin/plymouth --show-splash
+ return 2
+ elif strstr $"nN" "$answer" ; then
+ return 1
+ fi
+ done
+}
+
+# resolve a device node to its major:minor numbers in decimal or hex
+get_numeric_dev() {
+(
+ fmt="%d:%d"
+ if [ "$1" == "hex" ]; then
+ fmt="%x:%x"
+ fi
+ ls -lH "$2" | awk '{ sub(/,/, "", $5); printf("'"$fmt"'", $5, $6); }'
+) 2>/dev/null
+}
+
+# Check whether file $1 is a backup or rpm-generated file and should be ignored
+is_ignored_file() {
+ case "$1" in
+ *~ | *.bak | *.orig | *.rpmnew | *.rpmorig | *.rpmsave)
+ return 0
+ ;;
+ esac
+ return 1
+}
+
+# Evaluate shvar-style booleans
+is_true() {
+ case "$1" in
+ [tT] | [yY] | [yY][eE][sS] | [tT][rR][uU][eE])
+ return 0
+ ;;
+ esac
+ return 1
+}
+
+# Evaluate shvar-style booleans
+is_false() {
+ case "$1" in
+ [fF] | [nN] | [nN][oO] | [fF][aA][lL][sS][eE])
+ return 0
+ ;;
+ esac
+ return 1
+}
+
+# Apply sysctl settings, including files in /etc/sysctl.d
+apply_sysctl() {
+ sysctl -e -p /etc/sysctl.conf >/dev/null 2>&1
+ for file in /etc/sysctl.d/* ; do
+ is_ignored_file "$file" && continue
+ test -f "$file" && sysctl -e -p "$file" >/dev/null 2>&1
+ done
+}
+
+key_is_random() {
+ [ "$1" = "/dev/urandom" -o "$1" = "/dev/hw_random" \
+ -o "$1" = "/dev/random" ]
+}
+
+find_crypto_mount_point() {
+ local fs_spec fs_file fs_vfstype remaining_fields
+ local fs
+ while read fs_spec fs_file remaining_fields; do
+ if [ "$fs_spec" = "/dev/mapper/$1" ]; then
+ echo $fs_file
+ break;
+ fi
+ done < /etc/fstab
+}
+
+# Because of a chicken/egg problem, init_crypto must be run twice. /var may be
+# encrypted but /var/lib/random-seed is needed to initialize swap.
+init_crypto() {
+ local have_random dst src key opt mode owner params makeswap skip arg opt
+ local param value rc ret mke2fs mdir prompt mount_point
+
+ ret=0
+ have_random=$1
+ while read dst src key opt; do
+ [ -z "$dst" -o "${dst#\#}" != "$dst" ] && continue
+ [ -b "/dev/mapper/$dst" ] && continue;
+ if [ "$have_random" = 0 ] && key_is_random "$key"; then
+ continue
+ fi
+ if [ -n "$key" -a "x$key" != "xnone" ]; then
+ if test -e "$key" ; then
+ owner=$(ls -l $key | (read a b owner rest; echo $owner))
+ if ! key_is_random "$key"; then
+ mode=$(ls -l "$key" | cut -c 5-10)
+ if [ "$mode" != "------" ]; then
+ echo $"INSECURE MODE FOR $key"
+ fi
+ fi
+ if [ "$owner" != root ]; then
+ echo $"INSECURE OWNER FOR $key"
+ fi
+ else
+ echo $"Key file for $dst not found, skipping"
+ ret=1
+ continue
+ fi
+ else
+ key=""
+ fi
+ params=""
+ makeswap=""
+ mke2fs=""
+ skip=""
+ # Parse the src field for UUID= and convert to real device names
+ if [ "${src%%=*}" == "UUID" ]; then
+ src=$(/sbin/blkid -t "$src" -l -o device)
+ elif [ "${src/^\/dev\/disk\/by-uuid\/}" != "$src" ]; then
+ src=$(__readlink $src)
+ fi
+ # Is it a block device?
+ [ -b "$src" ] || continue
+ # Is it already a device mapper slave? (this is gross)
+ devesc=${src##/dev/}
+ devesc=${devesc//\//!}
+ for d in /sys/block/dm-*/slaves ; do
+ [ -e $d/$devesc ] && continue 2
+ done
+ # Parse the options field, convert to cryptsetup parameters and
+ # contruct the command line
+ while [ -n "$opt" ]; do
+ arg=${opt%%,*}
+ opt=${opt##$arg}
+ opt=${opt##,}
+ param=${arg%%=*}
+ value=${arg##$param=}
+
+ case "$param" in
+ cipher)
+ params="$params -c $value"
+ if [ -z "$value" ]; then
+ echo $"$dst: no value for cipher option, skipping"
+ skip="yes"
+ fi
+ ;;
+ size)
+ params="$params -s $value"
+ if [ -z "$value" ]; then
+ echo $"$dst: no value for size option, skipping"
+ skip="yes"
+ fi
+ ;;
+ hash)
+ params="$params -h $value"
+ if [ -z "$value" ]; then
+ echo $"$dst: no value for hash option, skipping"
+ skip="yes"
+ fi
+ ;;
+ verify)
+ params="$params -y"
+ ;;
+ swap)
+ makeswap=yes
+ ;;
+ tmp)
+ mke2fs=yes
+ esac
+ done
+ if [ "$skip" = "yes" ]; then
+ ret=1
+ continue
+ fi
+ if [ -z "$makeswap" ] && cryptsetup isLuks "$src" 2>/dev/null ; then
+ if key_is_random "$key"; then
+ echo $"$dst: LUKS requires non-random key, skipping"
+ ret=1
+ continue
+ fi
+ if [ -n "$params" ]; then
+ echo "$dst: options are invalid for LUKS partitions," \
+ "ignoring them"
+ fi
+ if [ -n "$key" ]; then
+ /sbin/cryptsetup -d $key luksOpen "$src" "$dst" <&1 2>/dev/null && success || failure
+ rc=$?
+ else
+ mount_point="$(find_crypto_mount_point $dst)"
+ [ -n "$mount_point" ] || mount_point=${src##*/}
+ prompt=$(printf $"%s is password protected" "$mount_point")
+ plymouth ask-for-password --prompt "$prompt" --command="/sbin/cryptsetup luksOpen -T1 $src $dst" <&1
+ rc=$?
+ fi
+ else
+ [ -z "$key" ] && plymouth --hide-splash
+ /sbin/cryptsetup $params ${key:+-d $key} create "$dst" "$src" <&1 2>/dev/null && success || failure
+ rc=$?
+ [ -z "$key" ] && plymouth --show-splash
+ fi
+ if [ $rc -ne 0 ]; then
+ ret=1
+ continue
+ fi
+ if [ -b "/dev/mapper/$dst" ]; then
+ if [ "$makeswap" = "yes" ]; then
+ mkswap "/dev/mapper/$dst" 2>/dev/null >/dev/null
+ fi
+ if [ "$mke2fs" = "yes" ]; then
+ if mke2fs "/dev/mapper/$dst" 2>/dev/null >/dev/null \
+ && mdir=$(mktemp -d /tmp/mountXXXXXX); then
+ mount "/dev/mapper/$dst" "$mdir" && chmod 1777 "$mdir"
+ umount "$mdir"
+ rmdir "$mdir"
+ fi
+ fi
+ fi
+ done < /etc/crypttab
+ return $ret
+}
+
+# A sed expression to filter out the files that is_ignored_file recognizes
+__sed_discard_ignored_files='/\(~\|\.bak\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d'
diff --git a/lib/facter/jboss_configfile.rb b/lib/facter/jboss_configfile.rb
new file mode 100644
index 0000000..b0a28b4
--- /dev/null
+++ b/lib/facter/jboss_configfile.rb
@@ -0,0 +1,5 @@
+require File.expand_path(File.join(File.dirname(__FILE__), '../puppet_x/coi/jboss/configuration'))
+
+Facter.add(:jboss_configfile) do
+ setcode { Puppet_X::Coi::Jboss::Configuration::configfile }
+end
\ No newline at end of file
diff --git a/lib/facter/jboss_fullconfig.rb b/lib/facter/jboss_fullconfig.rb
new file mode 100644
index 0000000..f418a02
--- /dev/null
+++ b/lib/facter/jboss_fullconfig.rb
@@ -0,0 +1,21 @@
+require File.expand_path(File.join(File.dirname(__FILE__), '../puppet_x/coi/jboss/configuration'))
+
+config = Puppet_X::Coi::Jboss::Configuration::read
+unless config.nil?
+ config.each do |key, value|
+ fact_symbol = "jboss_#{key}".to_sym
+ Facter.add(fact_symbol) do
+ setcode { value }
+ end
+ end
+ Facter.add(:jboss_fullconfig) do
+ setcode do
+ if RUBY_VERSION < '1.9.0'
+ class << config
+ define_method(:to_s, proc { self.inspect })
+ end
+ end
+ config
+ end
+ end
+end
diff --git a/lib/facter/jboss_running.rb b/lib/facter/jboss_running.rb
new file mode 100644
index 0000000..09a39fc
--- /dev/null
+++ b/lib/facter/jboss_running.rb
@@ -0,0 +1,13 @@
+Facter.add(:jboss_running) do
+ setcode do
+ def search pattern
+ result = Dir['/proc/[0-9]*/cmdline'].inject({}) do |h, file|
+ (h[File.read(file).gsub(/\000/, ' ')] ||= []).push(file.match(/\d+/)[0].to_i)
+ h
+ end.map { |k, v| v if k.match(pattern) }.compact.flatten
+ result if result.any?
+ end
+ status = search(/java .* -server .* org\.jboss\.as/).nil?.equal? false
+ status.inspect
+ end
+end
diff --git a/lib/puppet/parser/functions/jboss_basename.rb b/lib/puppet/parser/functions/jboss_basename.rb
new file mode 100644
index 0000000..0d1f147
--- /dev/null
+++ b/lib/puppet/parser/functions/jboss_basename.rb
@@ -0,0 +1,17 @@
+# Jboss AS private basename function
+#
+# jboss_basename(string) : string
+# jboss_basename(string[]) : string[]
+#
+# Returns the last component of the filename given as argument, which must be
+# formed using forward slashes (``/..) regardless of the separator used on the
+# local file system.
+module Puppet::Parser::Functions
+ newfunction(:jboss_basename, :type => :rvalue) do |args|
+ if args[0].is_a?(Array)
+ args.collect do |a| File.basename(a) end
+ else
+ File.basename(args[0])
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/puppet/parser/functions/jboss_dirname.rb b/lib/puppet/parser/functions/jboss_dirname.rb
new file mode 100644
index 0000000..a124580
--- /dev/null
+++ b/lib/puppet/parser/functions/jboss_dirname.rb
@@ -0,0 +1,17 @@
+# Jboss AS private dirname function
+#
+# jboss_dirname(string) : string
+# jboss_dirname(string[]) : string[]
+#
+# Returns all but the last component of the filename given as argument, which must be
+# formed using forward slashes (``/..) regardless of the separator used on the
+# local file system.
+module Puppet::Parser::Functions
+ newfunction(:jboss_dirname, :type => :rvalue) do |args|
+ if args[0].is_a?(Array)
+ args.collect do |a| File.dirname(a) end
+ else
+ File.dirname(args[0])
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/puppet/parser/functions/jboss_hash_setvalue.rb b/lib/puppet/parser/functions/jboss_hash_setvalue.rb
new file mode 100644
index 0000000..4d36ad6
--- /dev/null
+++ b/lib/puppet/parser/functions/jboss_hash_setvalue.rb
@@ -0,0 +1,11 @@
+# Jboss AS private set value function
+#
+# jboss_hash_setvalue(Hash, string, Object) : void
+#
+# Sets value to Puppet hash
+module Puppet::Parser::Functions
+ newfunction(:jboss_hash_setvalue) do |args|
+ hash, key, value = args
+ hash[key] = value
+ end
+end
\ No newline at end of file
diff --git a/lib/puppet/parser/functions/jboss_short_version.rb b/lib/puppet/parser/functions/jboss_short_version.rb
new file mode 100644
index 0000000..86487d0
--- /dev/null
+++ b/lib/puppet/parser/functions/jboss_short_version.rb
@@ -0,0 +1,14 @@
+# Jboss AS private short version function
+#
+# jboss_short_version(string) : string
+#
+# Returns short version of JBoss version from full version string ex.: 'as-7.1.1.Final' -> '7.1',
+# 'eap-6.2.0.GA' -> '6.2'
+module Puppet::Parser::Functions
+ newfunction(:jboss_short_version, :type => :rvalue) do |args|
+ version = args[0]
+ re = /^(?:[a-z]+-)?(\d+\.\d+)\.\d+(?:\.[A-Za-z]+)?$/
+ m = re.match(version)
+ if m then m[1] else nil end
+ end
+end
\ No newline at end of file
diff --git a/lib/puppet/parser/functions/jboss_to_bool.rb b/lib/puppet/parser/functions/jboss_to_bool.rb
new file mode 100644
index 0000000..852bceb
--- /dev/null
+++ b/lib/puppet/parser/functions/jboss_to_bool.rb
@@ -0,0 +1,12 @@
+require File.join(File.dirname(__FILE__), '../../../puppet_x/coi/jboss/functions/jboss_to_bool')
+
+# Jboss AS private to_bool function
+#
+# jboss_to_bool(object) : bool
+#
+# Cast any object to boolean
+module Puppet::Parser::Functions
+ newfunction(:jboss_to_bool, :type => :rvalue) do |args|
+ Puppet_X::Coi::Jboss::Functions.jboss_to_bool args
+ end
+end
\ No newline at end of file
diff --git a/lib/puppet/parser/functions/jboss_to_i.rb b/lib/puppet/parser/functions/jboss_to_i.rb
new file mode 100644
index 0000000..5791c3b
--- /dev/null
+++ b/lib/puppet/parser/functions/jboss_to_i.rb
@@ -0,0 +1,12 @@
+require File.join(File.dirname(__FILE__), '../../../puppet_x/coi/jboss/functions/jboss_to_i')
+
+# Jboss AS private to_i function
+#
+# jboss_to_i(string) : int
+#
+# Cast string to integer
+module Puppet::Parser::Functions
+ newfunction(:jboss_to_i, :type => :rvalue) do |args|
+ Puppet_X::Coi::Jboss::Functions.jboss_to_i args
+ end
+end
\ No newline at end of file
diff --git a/lib/puppet/parser/functions/jboss_to_s.rb b/lib/puppet/parser/functions/jboss_to_s.rb
new file mode 100644
index 0000000..e0938b0
--- /dev/null
+++ b/lib/puppet/parser/functions/jboss_to_s.rb
@@ -0,0 +1,12 @@
+require File.join(File.dirname(__FILE__), '../../../puppet_x/coi/jboss/functions/jboss_to_s')
+
+# Jboss AS private to_s function
+#
+# jboss_to_s(object) : string
+#
+# Cast any object to string
+module Puppet::Parser::Functions
+ newfunction(:jboss_to_s, :type => :rvalue) do |args|
+ Puppet_X::Coi::Jboss::Functions.jboss_to_s args
+ end
+end
\ No newline at end of file
diff --git a/lib/puppet/parser/functions/jboss_type_version.rb b/lib/puppet/parser/functions/jboss_type_version.rb
new file mode 100644
index 0000000..ad91f77
--- /dev/null
+++ b/lib/puppet/parser/functions/jboss_type_version.rb
@@ -0,0 +1,14 @@
+# Jboss AS private type version function
+#
+# jboss_type_version(string) : string
+#
+# Returns version type of JBoss version from full version string ex.: 'as-7.1.1.Final' -> 'as',
+# 'eap-6.2.0.GA' -> 'eap'
+module Puppet::Parser::Functions
+ newfunction(:jboss_type_version, :type => :rvalue) do |args|
+ version = args[0]
+ re = /^([a-z]+)-(?:\d+\.\d+)\.\d+(?:\.[A-Za-z]+)?$/
+ m = re.match(version)
+ if m then m[1] else nil end
+ end
+end
\ No newline at end of file
diff --git a/lib/puppet/provider/jboss_confignode/jbosscli.rb b/lib/puppet/provider/jboss_confignode/jbosscli.rb
new file mode 100644
index 0000000..6e5f33b
--- /dev/null
+++ b/lib/puppet/provider/jboss_confignode/jbosscli.rb
@@ -0,0 +1,301 @@
+require File.expand_path(File.join(File.dirname(File.dirname(__FILE__)), 'jbosscli.rb'))
+
+Puppet::Type.type(:jboss_confignode).provide(:jbosscli, :parent => Puppet::Provider::Jbosscli) do
+ desc "JBoss CLI configuration node provider"
+
+ @clean = false
+ @data = nil
+
+ def create
+ trace 'create'
+ if exists?
+ return
+ end
+ ret = bringUp 'Configuration node', "#{compiledpath}:add(#{compileprops})"
+ invalidate
+ return ret
+ end
+
+ def destroy
+ trace 'destroy'
+ if not exists?
+ return
+ end
+ if status == :running
+ doStop
+ end
+ ret = bringDown 'Configuration node', "#{compiledpath}:remove()"
+ invalidate
+ return ret
+ end
+
+ def exists?
+ trace 'exists?'
+
+ if @clean
+ return (not @data.nil?)
+ end
+ if @resource[:path].nil?
+ @resource[:path] = @resource[:name]
+ end
+ @resource[:properties] = {} if @resource[:properties].nil?
+ @resource[:properties].each do |key, value|
+ if value == "undef" or value == :undef
+ @resource[:properties][key] = nil
+ end
+ end
+
+ res = executeAndGet "#{compiledpath}:read-resource(include-runtime=true, include-defaults=false)"
+ if res[:result]
+ @data = {}
+ res[:data].each do |key, value|
+ props = @resource[:properties]
+ @data[key] = value
+ if not @property_hash.key? :properties
+ @property_hash[:properties] = {}
+ end
+ if props.key? key
+ @property_hash[:properties][key] = value
+ end
+ end
+ @clean = true
+ traceout 'status()', true
+ return true
+ end
+ @clean = true
+ @data = nil
+ traceout 'status()', false
+ return false
+ end
+
+ def status
+ trace 'status'
+ meth = self.method 'ensure'
+ ret = meth.call
+ traceout 'status()', ret
+ return ret
+ end
+
+ def ensure
+ trace 'ensure'
+
+ exists?
+ if @data.nil?
+ @property_hash[:ensure] = :absent
+ traceout 'ensure()', :absent
+ return :absent
+ end
+ if not @data['status'].nil?
+ st = @data['status'].upcase
+ if st == 'DISABLED'
+ @property_hash[:ensure] = :disabled
+ traceout 'ensure()', :disabled
+ return :disabled
+ end
+ if ['RUNNING', 'STARTED'].include? st
+ @property_hash[:ensure] = :running
+ traceout 'ensure()', :running
+ return :running
+ else
+ @property_hash[:ensure] = :stopped
+ traceout 'ensure()', :stopped
+ return :stopped
+ end
+ end
+ if not @data['enabled'].nil?
+ if @data['enabled']
+ @property_hash[:ensure] = :enabled
+ traceout 'ensure()', :enabled
+ return :enabled
+ else
+ @property_hash[:ensure] = :disabled
+ traceout 'ensure()', :disabled
+ return :disabled
+ end
+ end
+ if @data.length > 0
+ @property_hash[:ensure] = :present
+ traceout 'ensure()', :present
+ return :present
+ end
+ end
+
+ def ensure= value
+ trace 'ensure=(%s)' % [ value.inspect ]
+ case value
+ when :present then create
+ when :absent then destroy
+ when :running then doStart
+ when :stopped then doStop
+ when :enabled then doEnable
+ when :disabled then doDisable
+ end
+ traceout 'ensure=(%s)' % value.inspect, value.inspect
+ return value
+ end
+
+ def enabled?
+ trace 'enabled?'
+
+ return status == :running
+ end
+
+ def stopped?
+ trace 'stopped?'
+
+ return status == :stopped
+ end
+
+ def enabled?
+ trace 'enabled?'
+
+ return status == :enabled
+ end
+
+ def disabled?
+ trace 'disabled?'
+
+ return status == :disabled
+ end
+
+ def present?
+ trace 'present?'
+
+ return status == :present
+ end
+
+ def absent?
+ trace 'absent?'
+
+ return status == :absent
+ end
+
+ def properties
+ trace 'properties()'
+
+ if @data.nil?
+ traceout 'properties()', {}
+ return {}
+ else
+ hash = {}
+ @property_hash[:properties] = {} if @property_hash[:properties].nil?
+ @property_hash[:properties].each do |k, v|
+ if v.nil? or !!v == v or v.is_a? Numeric or v.is_a? Hash or v.is_a? Array
+ hash[k.to_s] = v
+ else
+ hash[k.to_s] = v.to_s
+ end
+ end
+ traceout 'properties()', hash
+ return hash
+ end
+ end
+
+ def properties= newprops
+ trace 'properties=(%s)' % newprops.inspect
+
+ # Sorting by value to process `nil` values first
+ sorted = newprops.sort do |a, b|
+ if a[1] == b[1]
+ 0
+ elsif a[1].nil? and not b[1].nil?
+ -1
+ elsif not a[1].nil? and b[1].nil?
+ 1
+ else
+ 0
+ end
+ end
+ sorted.each do |arr|
+ key, value = arr
+ if not @data.key? key or @data[key] != value
+ writekey key, value
+ Puppet.notice "JBoss::Property: Key `#{key}` with value `#{value.inspect}` for path `#{compiledpath}` has been set."
+ end
+ end
+ end
+
+ private
+
+ def doStart
+ trace 'doStart'
+
+ if status == :absent
+ create
+ end
+ ret = bringUp 'Configuration node START', "#{compiledpath}:start(blocking=true)"
+ invalidate
+ traceout 'doStart', ret
+ return ret
+ end
+
+ def doStop
+ trace 'doStop'
+
+ if status == :absent
+ create
+ end
+ ret = bringDown 'Configuration node STOP', "#{compiledpath}:stop(blocking=true)"
+ invalidate
+ return ret
+ end
+
+ def doEnable
+ trace 'doEnable'
+
+ if status == :absent
+ create
+ end
+ ret = bringUp 'Configuration node ENABLE', "#{compiledpath}:enable()"
+ invalidate
+ return ret
+ end
+
+ def doDisable
+ trace 'doDisable'
+
+ if status == :absent
+ create
+ end
+ ret = bringDown 'Configuration node DISABLE', "#{compiledpath}:disable()"
+ invalidate
+ return ret
+ end
+
+ def invalidate
+ trace 'invalidate'
+
+ @clean = false
+ end
+
+ def writekey key, value
+ trace 'writekey(%s,%s)' % [key.inspect, value.inspect]
+
+ invalidate
+ if value.nil?
+ bringDown 'Configuration node property', "#{compiledpath}:undefine-attribute(name=#{key})"
+ else
+ preparedval = escape value
+ bringUp 'Configuration node property', "#{compiledpath}:write-attribute(name=#{key}, value=#{preparedval})"
+ end
+ end
+
+ def compiledpath
+ trace 'compiledpath'
+
+ path = @resource[:path]
+ cmd = compilecmd path
+ end
+
+ def compileprops
+ trace 'compileprops'
+
+ props = @resource[:properties]
+ arr = []
+ props.each do |key, value|
+ preparedval = escape value
+ arr.push "#{key}=#{preparedval}"
+ end
+ arr.join ', '
+ end
+end
diff --git a/lib/puppet/provider/jboss_datasource/jbosscli.rb b/lib/puppet/provider/jboss_datasource/jbosscli.rb
new file mode 100644
index 0000000..06dfd98
--- /dev/null
+++ b/lib/puppet/provider/jboss_datasource/jbosscli.rb
@@ -0,0 +1,556 @@
+require File.expand_path(File.join(File.dirname(File.dirname(__FILE__)), 'jbosscli.rb'))
+require File.expand_path(File.join(File.dirname(__FILE__), '../../../puppet_x/coi/jboss/configuration'))
+require File.expand_path(File.join(File.dirname(__FILE__), '../../../puppet_x/coi/jboss/provider/datasource/pre_wildfly_provider'))
+require File.expand_path(File.join(File.dirname(__FILE__), '../../../puppet_x/coi/jboss/provider/datasource/post_wildfly_provider'))
+require 'uri'
+
+Puppet::Type.type(:jboss_datasource).provide(:jbosscli, :parent => Puppet::Provider::Jbosscli) do
+ desc "JBoss CLI datasource provider"
+
+ @data = nil
+ @readed = false
+ @impl = nil
+
+ def create
+ cmd = [ "#{create_delete_cmd} add --name=#{@resource[:name]}" ]
+ jta_opt(cmd)
+ cmd.push "--jndi-name=#{@resource[:jndiname].inspect}"
+ cmd.push "--driver-name=#{@resource[:drivername].inspect}"
+ cmd.push "--min-pool-size=#{@resource[:minpoolsize].inspect}"
+ cmd.push "--max-pool-size=#{@resource[:maxpoolsize].inspect}"
+ cmd.push "--user-name=#{@resource[:username].inspect}"
+ cmd.push "--password=#{@resource[:password].inspect}"
+ if @resource[:xa]
+ xa_properties = xa_datasource_properties_wrapper(createXaProperties)
+ cmd.push "--xa-datasource-properties=#{xa_properties}"
+ else
+ cmd.push "--connection-url=#{connectionUrl.inspect}"
+ end
+ @resource[:options].each do |attribute, value|
+ cmd.push "--#{attribute}=#{value.inspect}"
+ end
+
+ bringUp 'Datasource', cmd.join(' ')
+ setenabled true
+ end
+
+ def destroy
+ cmd = "#{create_delete_cmd} remove --name=#{@resource[:name]}"
+ bringDown 'Datasource', cmd
+ end
+
+ def self.instances
+ runasdomain = self.config_runasdomain
+ profile = self.config_profile
+ controller = self.config_controller
+ ctrlconfig = self.controllerConfig({ :controller => controller })
+ list = []
+ cmd = self.compilecmd runasdomain, profile, "/subsystem=datasources:read-children-names(child-type=#{self.datasource_type true})"
+ res = self.executeAndGet cmd, runasdomain, ctrlconfig, 0, 0
+ if res[:result]
+ res[:data].each do |name|
+ inst = self.create_rubyobject name, true, runasdomain, profile, controller
+ list.push inst
+ end
+ end
+ cmd = self.compilecmd runasdomain, profile, "/subsystem=datasources:read-children-names(child-type=#{self.datasource_type false})"
+ res = self.executeAndGet cmd, runasdomain, ctrlconfig, 0, 0
+ if res[:result]
+ res[:data].each do |name|
+ inst = self.create_rubyobject name, false, runasdomain, profile, controller
+ list.push inst
+ end
+ end
+ return list
+ end
+
+ def setenabled setting
+ Puppet.debug "setenabled #{setting.inspect}"
+ cmd = compilecmd "#{datasource_path}:read-attribute(name=enabled)"
+ res = executeAndGet cmd
+ enabled = res[:data]
+ Puppet.debug "Enabling datasource #{@resource[:name]} = #{enabled}: #{setting}"
+ if enabled != setting
+ if setting
+ cmd = compilecmd "#{datasource_path}:enable(persistent=true)"
+ else
+ cmd = compilecmd "#{datasource_path}:disable(persistent=true)"
+ end
+ bringUp "Datasource enable set to #{setting.to_s}", cmd
+ end
+ end
+
+ def prepare_resource
+ if @resource.nil?
+ @resource = {}
+ end
+ if @resource[:name].nil?
+ @resource[:name] = @property_hash[:name]
+ end
+ if @resource[:controller].nil?
+ @resource[:controller] = controller
+ end
+ if @resource[:runasdomain].nil?
+ @resource[:runasdomain] = runasdomain
+ end
+ if @resource[:profile].nil?
+ @resource[:profile] = profile
+ end
+ if @resource[:xa].nil?
+ @resource[:xa] = xa
+ end
+ end
+
+ def exists?
+ prepare_resource
+ if @resource[:dbname].nil?
+ @resource[:dbname] = @resource[:name]
+ end
+ @data = nil
+ cmd = compilecmd "#{datasource_path}:read-resource(recursive=true)"
+ res = executeAndGet cmd
+ if(res[:result] == false)
+ Puppet.debug "Datasorce (xa: #{xa?}) `#{@resource[:name]}` does NOT exist"
+ return false
+ end
+ Puppet.debug "Datasorce (xa: #{xa?}) `#{@resource[:name]}` exists: #{res[:data].inspect}"
+ @data = res[:data]
+ return true
+ end
+
+ def name
+ @property_hash[:name]
+ end
+
+ def getproperty name, default=nil
+ if @property_hash.nil? or (@property_hash.respond_to? :key? and not @property_hash.key? name) or @property_hash[name].nil?
+ return default
+ end
+ return @property_hash[name]
+ end
+ def xa
+ setting = getproperty :xa, nil
+ if not setting.nil?
+ return setting
+ else
+ return xa?
+ end
+ end
+ def xa= value
+ actual = getproperty :xa, false
+ if actual.to_s != value.to_s
+ destroy
+ create
+ end
+ end
+ def controller
+ getproperty :controller
+ end
+ def profile
+ getproperty :profile, default_profile
+ end
+ def runasdomain
+ getproperty :runasdomain
+ end
+
+ def jndiname
+ getattrib 'jndi-name'
+ end
+
+ def jndiname= value
+ setattrib 'jndi-name', value
+ end
+
+ def drivername
+ getattrib 'driver-name'
+ end
+
+ def drivername= value
+ setattrib 'driver-name', value
+ end
+
+ def minpoolsize
+ getattrib('min-pool-size').to_s
+ end
+
+ def minpoolsize= value
+ setattrib 'min-pool-size', value
+ end
+
+ def maxpoolsize
+ getattrib('max-pool-size').to_s
+ end
+
+ def maxpoolsize= value
+ setattrib 'max-pool-size', value
+ end
+
+ def username
+ getattrib('user-name')
+ end
+
+ def username= value
+ setattrib 'user-name', value
+ end
+
+ def password
+ getattrib('password')
+ end
+
+ def password= value
+ setattrib 'password', value
+ end
+
+ def options
+ managed_fetched_options
+ end
+
+ def options= value
+ managed_fetched_options.each do |key, fetched_value|
+ expected_value = value[key]
+ setattrib(key, expected_value) if expected_value != fetched_value
+ end
+ end
+
+ def enabled
+ getattrib('enabled').to_s
+ end
+
+ def enabled= value
+ Puppet.debug "Enabling datasource #{@resource[:name]} to #{value}"
+ setenabled value
+ end
+
+ def jdbcscheme
+ connectionHash()[:Scheme]
+ end
+
+ def jdbcscheme= value
+ writeConnection :Scheme, value
+ end
+
+ def host
+ connectionHash()[:ServerName].to_s
+ end
+
+ def host= value
+ writeConnection :ServerName, value
+ end
+
+ def port
+ connectionHash()[:PortNumber].to_i
+ end
+
+ def port= value
+ writeConnection :PortNumber, value
+ end
+
+ def dbname
+ connectionHash()[:DatabaseName]
+ end
+
+ def dbname= value
+ writeConnection :DatabaseName, value
+ end
+
+ def getattrib name, default=nil
+ if not @readed
+ exists?
+ @readed = true
+ end
+ if not @data.nil? and @data.key? name
+ return @data[name]
+ end
+ return default
+ end
+
+ def setattrib name, value
+ setattribute datasource_path, name, value
+ @data[name] = value
+ end
+
+ def jta
+ provider_impl.jta
+ end
+
+ def jta= value
+ provider_impl.jta = value
+ end
+
+ def xa?
+ if not @resource[:xa].nil?
+ return @resource[:xa]
+ else
+ return false
+ end
+ end
+
+ def xa_datasource_properties_wrapper(parameters)
+ provider_impl.xa_datasource_properties_wrapper(parameters)
+ end
+
+ def jta_opt(cmd)
+ provider_impl.jta_opt(cmd)
+ end
+
+ protected
+
+ def default_profile
+ 'full'
+ end
+
+ private
+
+ def provider_impl
+ if @impl.nil?
+ if Puppet_X::Coi::Jboss::Configuration::is_pre_wildfly?
+ @impl = Puppet_X::Coi::Jboss::Provider::Datasource::PreWildFlyProvider.new(self)
+ else
+ @impl = Puppet_X::Coi::Jboss::Provider::Datasource::PostWildFlyProvider.new(self)
+ end
+ end
+ @impl
+ end
+
+ def managed_fetched_options
+ fetched = {}
+ @resource[:options].each do |k, v|
+ fetched[k] = getattrib(k)
+ end
+ fetched
+ end
+
+ def self.create_rubyobject name, xa, runasdomain, profile, controller
+ props = {
+ :name => name,
+ :ensure => :present,
+ :provider => :jbosscli,
+ :xa => xa,
+ :runasdomain => runasdomain,
+ :profile => profile,
+ :controller => controller
+ }
+ obj = new(props)
+ return obj
+ end
+
+ def createXaProperties
+ if @resource[:drivername] == 'h2'
+ "URL=#{connectionUrl.inspect}"
+ else
+ out = []
+ props = [:ServerName, :PortNumber, :DatabaseName]
+ props.each do |prop|
+ value = @resource[getPuppetKey prop]
+ out.push "#{prop.to_s}=#{value.inspect}"
+ end
+ if oracle?
+ out.push 'DriverType="thin"'
+ end
+ out.join ','
+ end
+ end
+
+ def writeConnection property, value
+ if xa?
+ if h2?
+ writeXaProperty 'URL', connectionUrl
+ else
+ writeXaProperty property, value
+ end
+ else
+ readed = getattrib('connection-url')
+ url = connectionUrl
+ if readed.nil? or readed != url
+ setattrib 'connection-url', url
+ end
+ end
+ end
+
+ def getPuppetKey property
+ case property
+ when :Scheme
+ return :jdbcscheme
+ when :ServerName
+ return :host
+ when :PortNumber
+ return :port
+ when :DatabaseName
+ return :dbname
+ else
+ raise 'Unknown property: ' + property
+ end
+ end
+
+ def writeXaProperty property, value
+ if property == :Scheme
+ getattrib('xa-datasource-properties')[property.to_s]['value'] = value
+ return
+ end
+ cmd = compilecmd "#{datasource_path}/xa-datasource-properties=#{property.to_s}:read-resource()"
+ if execute(cmd)[:result]
+ cmd = compilecmd "#{datasource_path}/xa-datasource-properties=#{property.to_s}:remove()"
+ bringDown "XA Datasource Property " + property.to_s, cmd
+ end
+ cmd = compilecmd "#{datasource_path}/xa-datasource-properties=#{property.to_s}:add(value=#{escape value})"
+ bringUp "XA Datasource Property set " + property.to_s, cmd
+ props = getattrib 'xa-datasource-properties'
+ props = {} if props.nil?
+ props[property.to_s] = {} if props[property.to_s].nil?
+ props[property.to_s]['value'] = value
+ end
+
+ def readXaProperty property
+ if property == :Scheme
+ key = getPuppetKey property
+ scheme = @resource[key]
+ if getattrib('xa-datasource-properties')[property.to_s].nil?
+ getattrib('xa-datasource-properties')[property.to_s] = {}
+ end
+ getattrib('xa-datasource-properties')[property.to_s]['value'] = scheme
+ return scheme
+ end
+ readed = getattrib('xa-datasource-properties')
+ key = property.to_s
+ if readed.nil? or readed[key].nil? or readed[key]['value'].blank?
+ name = @resource[:name]
+ cmd = compilecmd "#{datasource_path}/xa-datasource-properties=#{key}:read-attribute(name=value)"
+ result = executeAndGet cmd
+ readed[key]['value'] = result[:data]
+ end
+ return readed[key]['value']
+ end
+
+ def connectionHashFromXa
+ if h2?
+ parseConnectionUrl(readXaProperty 'URL')
+ else
+ props = [:Scheme, :ServerName, :PortNumber, :DatabaseName]
+ out = {}
+ props.each do |sym|
+ property = readXaProperty sym
+ out[sym] = property
+ end
+ out
+ end
+ end
+
+ def connectionHashFromStd
+ parseConnectionUrl getattrib('connection-url').to_s
+ end
+
+ def connectionHash
+ empty = {
+ :Scheme => nil,
+ :ServerName => nil,
+ :PortNumber => nil,
+ :DatabaseName => nil,
+ }
+ begin
+ if xa? then connectionHashFromXa else connectionHashFromStd end
+ rescue ArgumentError => e
+ Puppet.debug e
+ return empty
+ end
+ end
+
+ def oracle?
+ scheme = @resource[:jdbcscheme]
+ scheme[0, 6] == 'oracle'
+ end
+
+ def h2?
+ scheme = @resource[:jdbcscheme]
+ scheme[0, 2] == 'h2'
+ end
+
+ def create_delete_cmd
+ cmd = "data-source"
+ if xa?
+ cmd = "xa-#{cmd}"
+ end
+ if @resource[:runasdomain]
+ cmd = "#{cmd} --profile=#{@resource[:profile]}"
+ end
+ return cmd
+ end
+
+ def datasource_type
+ if xa?
+ "xa-data-source"
+ else
+ "data-source"
+ end
+ end
+
+ def self.datasource_type xa
+ if xa
+ "xa-data-source"
+ else
+ "data-source"
+ end
+ end
+
+ def datasource_path
+ "/subsystem=datasources/#{datasource_type}=#{@resource[:name]}"
+ end
+
+ def parseOracleConnectionUrl(url)
+ splited = url.split '@'
+ scheme = splited[0].sub 'jdbc:', ''
+ host, port, dbname = splited[1].split ':'
+ return {
+ :Scheme => scheme,
+ :ServerName => host,
+ :PortNumber => port.to_i,
+ :DatabaseName => dbname,
+ }
+ end
+
+ def parseH2ConnectionUrl(url)
+ repl = url.sub('h2:', 'h2-')
+ parsed = parseOtherDbConnectionUrl(repl)
+ parsed[:Scheme] = parsed[:Scheme].sub('h2-', 'h2:')
+ parsed
+ end
+
+ def parseOtherDbConnectionUrl(url)
+ uri = URI(url.sub('jdbc:', ''))
+ return {
+ :Scheme => uri.scheme,
+ :ServerName => uri.host,
+ :PortNumber => uri.port,
+ :DatabaseName => uri.path[1..-1],
+ }
+ end
+
+ def parseConnectionUrl url
+ begin
+ if oracle?
+ parseOracleConnectionUrl(url)
+ elsif h2?
+ parseH2ConnectionUrl(url)
+ else
+ parseOtherDbConnectionUrl(url)
+ end
+ rescue NoMethodError, ArgumentError, RuntimeError => e
+ raise ArgumentError, "Invalid connection url: #{url}: #{e}"
+ end
+ end
+
+ def connectionUrl
+ scheme = @resource[:jdbcscheme]
+ host = @resource[:host]
+ port = @resource[:port]
+ dbname = @resource[:dbname]
+ if oracle?
+ port = 1521 if port <= 0
+ url = "#{scheme}@#{host}:#{port}:#{dbname}"
+ else
+ port_with_colon = if port > 0 then ":#{port}" else '' end
+ url = "#{scheme}://#{host}#{port_with_colon}/#{dbname}"
+ end
+ return "jdbc:#{url}"
+ end
+
+end
diff --git a/lib/puppet/provider/jboss_deploy/jbosscli.rb b/lib/puppet/provider/jboss_deploy/jbosscli.rb
new file mode 100644
index 0000000..6e9b080
--- /dev/null
+++ b/lib/puppet/provider/jboss_deploy/jbosscli.rb
@@ -0,0 +1,99 @@
+require File.expand_path(File.join(File.dirname(File.dirname(__FILE__)), 'jbosscli.rb'))
+
+Puppet::Type.type(:jboss_deploy).provide(:jbosscli, :parent => Puppet::Provider::Jbosscli) do
+
+ def create
+ cmd = "deploy #{@resource[:source]} --name=#{@resource[:name]}"
+ if @resource[:runasdomain]
+ servergroups = @resource[:servergroups]
+ if servergroups.nil? or servergroups.empty? or servergroups == ['']
+ cmd = "#{cmd} --all-server-groups"
+ else
+ cmd = "#{cmd} --server-groups=#{servergroups.join(',')}"
+ end
+ end
+ if @resource[:redeploy]
+ cmd = "#{cmd} --force"
+ end
+ isprintinglog = 100
+ bringUp 'Deployment', cmd
+ end
+
+ def destroy
+ cmd = "undeploy #{@resource[:name]}"
+ if @resource[:runasdomain]
+ servergroups = @resource[:servergroups]
+ if servergroups.nil? or servergroups.empty? or servergroups == ['']
+ cmd = "#{cmd} --all-relevant-server-groups"
+ else
+ cmd = "#{cmd} --server-groups=#{@resource[:servergroup]}"
+ end
+ end
+ isprintinglog = 0
+ bringDown 'Deployment', cmd
+ end
+
+ def name_exists?
+ res = executeWithoutRetry "deployment-info --name=#{@resource[:name]}"
+ if res[:result] == false
+ return false
+ end
+ for line in res[:lines]
+ line.strip!
+ if line =~ /^#{@resource[:name]}[ ]+/
+ Puppet.debug "Deployment found: #{line}"
+ return true
+ end
+ end
+ Puppet.debug "No deployment matching #{@resource[:name]} found."
+ return false
+ end
+
+ def is_exact_deployment?
+ true
+ end
+
+ def exists?
+ if name_exists?
+ is_exact_deployment?
+ else
+ false
+ end
+ end
+
+ def servergroups
+ if not @resource[:runasdomain]
+ return @resource[:servergroups]
+ end
+ servergroups = @resource[:servergroups]
+ res = execute("deployment-info --name=#{@resource[:name]}")
+ if not res[:result]
+ return []
+ end
+ groups = []
+ for line in res[:lines]
+ line.strip!
+ depinf = line.split
+ if(depinf[1] == "enabled" || depinf[1] == "added")
+ groups.push(depinf[0])
+ end
+ end
+ if servergroups.nil? or servergroups.empty? or servergroups == ['']
+ return servergroups
+ end
+ return groups
+ end
+
+ def servergroups=(value)
+ if not @resource[:runasdomain]
+ return nil
+ end
+ current = servergroups()
+ Puppet.debug(current.inspect())
+ Puppet.debug(value.inspect())
+
+ toset = value - current
+ cmd = "deploy --name=#{@resource[:name]} --server-groups=#{toset.join(',')}"
+ res = bringUp('Deployment', cmd)
+ end
+end
diff --git a/lib/puppet/provider/jboss_jdbcdriver/jbosscli.rb b/lib/puppet/provider/jboss_jdbcdriver/jbosscli.rb
new file mode 100644
index 0000000..3ab499e
--- /dev/null
+++ b/lib/puppet/provider/jboss_jdbcdriver/jbosscli.rb
@@ -0,0 +1,102 @@
+require File.expand_path(File.join(File.dirname(File.dirname(__FILE__)), 'jbosscli.rb'))
+
+Puppet::Type.type(:jboss_jdbcdriver).provide(:jbosscli, :parent => Puppet::Provider::Jbosscli) do
+
+ @data = {}
+
+ def create
+ name = @resource[:name]
+ map = get_attribs_map
+
+ cmd = compilecmd "/subsystem=datasources/jdbc-driver=#{name}:add(#{cmdlize_attribs_map map})"
+ bringUp 'JDBC-Driver', cmd
+ end
+
+ def destroy
+ cmd = compilecmd "/subsystem=datasources/jdbc-driver=#{@resource[:name]}:remove"
+ bringDown 'JDBC-Driver', cmd
+ end
+
+ def exists?
+ @data = {}
+ cmd = compilecmd "/subsystem=datasources/jdbc-driver=#{@resource[:name]}:read-resource(recursive=true)"
+ res = executeAndGet cmd
+ if(res[:result] == false)
+ Puppet.debug("JDBC Driver #{@resource[:name]} does NOT exist")
+ return false
+ end
+ Puppet.debug("JDBC Driver exists: #{res[:data].inspect}")
+ @data = res[:data]
+ return true
+ end
+
+ def setattrib name, value
+ Puppet.debug(name + ' setting to ' + value)
+ cmd = compilecmd "/subsystem=datasources/jdbc-driver=#{@resource[:name]}:write-attribute(name=#{name}, value=#{value})"
+ res = executeAndGet cmd
+ Puppet.debug res.inspect
+ if not res[:result]
+ raise "Cannot set #{name}: #{res[:data]}"
+ end
+ @data[name] = value
+ end
+
+ def classname
+ @data['driver-class-name']
+ end
+
+ def classname= value
+ setattrib 'driver-class-name', value
+ end
+
+ def modulename
+ @data['driver-module-name']
+ end
+
+ def modulename= value
+ setattrib 'driver-module-name', value
+ end
+
+ def datasourceclassname
+ @data['driver-datasource-class-name']
+ end
+
+ def datasourceclassname= value
+ setattrib 'driver-datasource-class-name', value
+ end
+
+ def xadatasourceclassname
+ @data['driver-xa-datasource-class-name']
+ end
+
+ def xadatasourceclassname= value
+ setattrib 'driver-xa-datasource-class-name', value
+ end
+
+ private
+
+ def get_attribs_map
+ name = @resource[:name]
+ modulename = @resource[:modulename]
+ datasourceclassname = @resource[:datasourceclassname]
+ xadatasourceclassname = @resource[:xadatasourceclassname]
+ classname = @resource[:classname]
+ map = {
+ 'driver-name' => name,
+ 'driver-module-name' => modulename
+ }
+ map['driver-datasource-class-name'] = datasourceclassname if datasourceclassname
+ map['driver-xa-datasource-class-name'] = xadatasourceclassname if xadatasourceclassname
+ map['driver-class-name'] = classname if classname
+ map
+ end
+
+ def cmdlize_attribs_map input
+ list = []
+ input.each do |key, value|
+ list.push "#{key}=#{value.inspect}"
+ end
+ list.join ','
+ end
+
+end
diff --git a/lib/puppet/provider/jboss_jmsqueue/jbosscli.rb b/lib/puppet/provider/jboss_jmsqueue/jbosscli.rb
new file mode 100644
index 0000000..ddb3152
--- /dev/null
+++ b/lib/puppet/provider/jboss_jmsqueue/jbosscli.rb
@@ -0,0 +1,89 @@
+require File.expand_path(File.join(File.dirname(File.dirname(__FILE__)), 'jbosscli.rb'))
+
+Puppet::Type.type(:jboss_jmsqueue).provide(:jbosscli, :parent => Puppet::Provider::Jbosscli) do
+ def create
+ if runasdomain?
+ profile = "--profile=#{@resource[:profile]}"
+ else
+ profile = ''
+ end
+ entries = @resource[:entries].join '", "'
+ if not entries.empty?
+ entries = '["%s"]' % entries
+ else
+ raise "Array of entries can not be empty"
+ end
+ durable = @resource[:durable].to_bool
+ extcmd = "/extension=org.jboss.as.messaging"
+ if not execute("#{extcmd}:read-resource()")[:result]
+ bringUp "Extension - messaging", "#{extcmd}:add()"
+ end
+ syscmd = compilecmd "/subsystem=messaging"
+ if not execute("#{syscmd}:read-resource()")[:result]
+ bringUp "Subsystem - messaging", "#{syscmd}:add()"
+ end
+ hornetcmd = compilecmd "/subsystem=messaging/hornetq-server=default"
+ if not execute("#{hornetcmd}:read-resource()")[:result]
+ bringUp "Default HornetQ", "#{hornetcmd}:add()"
+ end
+ cmd = "jms-queue #{profile} add --queue-address=#{@resource[:name]} --entries=#{entries} --durable=\"#{durable.to_s}\""
+ bringUp "JMS Queue", cmd
+ end
+
+ def destroy
+ if runasdomain?
+ profile = "--profile=#{@resource[:profile]}"
+ else
+ profile = ''
+ end
+ cmd = "jms-queue #{profile} remove --queue-address=#{@resource[:name]}"
+ bringDown "JMS Queue", cmd
+ end
+
+ #
+ def exists?
+ $data = nil
+ cmd = compilecmd "/subsystem=messaging/hornetq-server=default/jms-queue=#{@resource[:name]}:read-resource()"
+ res = executeAndGet cmd
+
+ if not res[:result]
+ Puppet.debug "JMS Queue do not exists"
+ return false
+ end
+ $data = res[:data]
+ return true
+ end
+
+ def durable
+ trace 'durable'
+ Puppet.debug "Durable given: #{@resource[:durable].inspect}"
+ $data['durable'].to_bool.to_s
+ end
+
+ def durable= value
+ trace 'durable= %s' % value.to_s
+ setattr 'durable', ('"%s"' % value.to_bool)
+ end
+
+ def entries
+ trace 'entries'
+ $data['entries']
+ end
+
+ def entries= value
+ trace 'entries= %s' % value.inspect
+ entries = value.join '", "'
+ if not entries.empty?
+ entries = '["%s"]' % entries
+ else
+ raise "Array of entries can not be empty"
+ end
+ setattr 'entries', entries
+ end
+
+ private
+
+ def setattr name, value
+ setattribute_raw "/subsystem=messaging/hornetq-server=default/jms-queue=#{@resource[:name]}", name, value
+ end
+end
diff --git a/lib/puppet/provider/jboss_resourceadapter/jbosscli.rb b/lib/puppet/provider/jboss_resourceadapter/jbosscli.rb
new file mode 100644
index 0000000..c6679ea
--- /dev/null
+++ b/lib/puppet/provider/jboss_resourceadapter/jbosscli.rb
@@ -0,0 +1,262 @@
+require File.expand_path(File.join(File.dirname(__FILE__), '../../../puppet_x/coi/jboss/functions/jboss_to_bool'))
+require File.expand_path(File.join(File.dirname(File.dirname(__FILE__)), 'jbosscli.rb'))
+
+Puppet::Type.type(:jboss_resourceadapter).provide(:jbosscli, :parent => Puppet::Provider::Jbosscli) do
+
+ def create
+ name = @resource[:name]
+ jndiname = @resource[:jndiname]
+ params = prepareconfig()
+ basicsParams = makejbprops params[:basics]
+ cmd = compilecmd "/subsystem=resource-adapters/resource-adapter=#{name}:add(#{basicsParams})"
+ bringUp "Resource adapter", cmd
+ createConnections
+ end
+
+ def destroy
+ cmd = compilecmd "/subsystem=resource-adapters/resource-adapter=#{@resource[:name]}:remove()"
+ bringDown "Resource adapter", cmd
+ end
+
+ def exists?
+ $data = nil
+ cmd = compilecmd "/subsystem=resource-adapters/resource-adapter=#{@resource[:name]}:read-resource(recursive=true)"
+ res = executeAndGet(cmd)
+ if not res[:result]
+ Puppet.debug "Resource Adapter is not set"
+ return false
+ end
+ $data = res[:data]
+ return true
+ end
+
+ def archive
+ $data['archive']
+ end
+
+ def archive= value
+ setbasicattr 'archive', value
+ end
+
+ def transactionsupport
+ $data['transaction-support']
+ end
+
+ def transactionsupport= value
+ setbasicattr 'transaction-support', value
+ end
+
+ def jndiname
+ jndis = []
+ if $data['connection-definitions'].nil?
+ $data['connection-definitions'] = {}
+ end
+ $data['connection-definitions'].each do |jndi, config|
+ jndis.push jndi
+ end
+ given = @resource[:jndiname]
+ if jndis - given == [] and given - jndis == []
+ # Returning in apopriate order to prevent changes
+ jndis = given
+ end
+ Puppet.debug "JNDI getter -------- POST! => #{jndis.inspect}"
+ return jndis
+ end
+
+ def jndiname= value
+ Puppet.debug "JNDI setter -------- PRE!"
+ names = jndiname
+ toremove = names - value # Existing array minus new provides array to be removed
+ trace 'jndiname=(%s) :: toremove=%s' % [value.inspect, toremove.inspect]
+ toadd = value - names # New array minus existing provides array to be added
+ trace 'jndiname=(%s) :: toadd=%s' % [value.inspect, toadd.inspect]
+ toremove.each do |jndi|
+ destroyconn jndi
+ end
+ toadd.each do |jndi|
+ config = prepareconfig()
+ createconn jndi, config[:connections][jndi]
+ end
+ exists? # Re read configuration
+ end
+
+ def classname
+ getconnectionattr 'class-name'
+ end
+
+ def classname= value
+ setconnectionattr 'class-name', value
+ end
+
+ def backgroundvalidation
+ getconnectionattr 'background-validation'
+ end
+
+ def backgroundvalidation= value
+ setconnectionattr 'background-validation', value
+ end
+
+ def security
+ if Puppet_X::Coi::Jboss::Functions.jboss_to_bool(getconnectionattr 'security-application')
+ return 'application'
+ end
+ if Puppet_X::Coi::Jboss::Functions.jboss_to_bool(getconnectionattr 'security-domain-and-application')
+ return 'domain-and-application'
+ end
+ if Puppet_X::Coi::Jboss::Functions.jboss_to_bool(getconnectionattr 'security-domain')
+ return 'domain'
+ end
+ return nil
+ end
+
+ def security= value
+ if value == 'application'
+ setconnectionattr 'security-application', true
+ setconnectionattr 'security-domain-and-application', nil
+ setconnectionattr 'security-domain', nil
+ elsif value == 'domain-and-application'
+ setconnectionattr 'security-application', nil
+ setconnectionattr 'security-domain-and-application', true
+ setconnectionattr 'security-domain', nil
+ elsif value == 'domain'
+ setconnectionattr 'security-application', nil
+ setconnectionattr 'security-domain-and-application', nil
+ setconnectionattr 'security-domain', true
+ else
+ raise "Invalid value for security: #{value}. Supported values are: application, domain-and-application, domain"
+ end
+ end
+
+ protected
+
+ def createConnections
+ if $data.nil?
+ exists? # Re read configuration
+ end
+ prepareconfig()[:connections].each do |jndi, config|
+ if not connExists? jndi
+ createconn jndi, config
+ end
+ end
+ end
+
+ def connExists? jndi
+ if $data['connection-definitions'].nil?
+ $data['connection-definitions'] = {}
+ end
+ if not $data['connection-definitions'][jndi].nil?
+ return true
+ end
+ name = @resource[:name]
+ connectionName = escapeforjbname jndi
+ cmd = compilecmd "/subsystem=resource-adapters/resource-adapter=#{name}/connection-definitions=#{connectionName}:read-resource()"
+ res = executeAndGet cmd
+ if res[:result]
+ $data['connection-definitions'][jndi] = res[:data]
+ end
+ return res[:result]
+ end
+
+ def createconn jndi, config
+ name = @resource[:name]
+ connectionParams = makejbprops config
+ connectionName = escapeforjbname jndi
+ cmd = compilecmd "/subsystem=resource-adapters/resource-adapter=#{name}/connection-definitions=#{connectionName}:add(#{connectionParams})"
+ bringUp "Resource adapter connection-definition", cmd
+ end
+
+ def destroyconn jndi
+ name = @resource[:name]
+ connectionName = escapeforjbname jndi
+ cmd = compilecmd "/subsystem=resource-adapters/resource-adapter=#{name}/connection-definitions=#{connectionName}:remove()"
+ bringDown "Resource adapter connection-definition", cmd
+ end
+
+ def prepareconfig
+ params = {
+ :basics => {
+ 'archive' => @resource[:archive],
+ 'transaction-support' => @resource[:transactionsupport],
+ },
+ :connections => {},
+ }
+ if @resource[:jndiname].nil?
+ @resource[:jndiname] = []
+ end
+ @resource[:jndiname].each do |jndiname|
+ params[:connections][jndiname] = {
+ 'jndi-name' => jndiname,
+ 'class-name' => @resource[:classname],
+ 'background-validation' => @resource[:backgroundvalidation],
+ }
+ case @resource[:security]
+ when 'application'
+ params[:connections][jndiname]['security-application'] = true
+ params[:connections][jndiname]['security-domain-and-application'] = nil
+ params[:connections][jndiname]['security-domain'] = nil
+ when 'domain-and-application'
+ params[:connections][jndiname]['security-application'] = nil
+ params[:connections][jndiname]['security-domain-and-application'] = true
+ params[:connections][jndiname]['security-domain'] = nil
+ when 'domain'
+ params[:connections][jndiname]['security-application'] = nil
+ params[:connections][jndiname]['security-domain-and-application'] = nil
+ params[:connections][jndiname]['security-domain'] = true
+ end
+ end
+ return params
+ end
+
+ def escapeforjbname input
+ input.gsub(/([^\\])\//, '\1\\/').gsub(/([^\\]):/, '\1\\:')
+ end
+
+ def unescapeforjbname input
+ input.gsub(/\\\//, '/').gsub(/\\:/, ':')
+ end
+
+ def makejbprops input
+ inp = {}
+ input.each do |k, v|
+ if not v.nil?
+ inp[k] = v
+ end
+ end
+ inp.inspect.gsub('=>', '=').gsub(/[\{\}]/, '').gsub(/\"([^\"]+)\"=/,'\1=')
+ end
+
+ def setbasicattr name, value
+ setattribute "/subsystem=resource-adapters/resource-adapter=#{@resource[:name]}", name, value
+ $data[name] = value
+ end
+
+ def setconnectionattr name, value
+ prepareconfig()[:connections].each do |jndi, config|
+ if not connExists? jndi
+ createconn jndi, config
+ next
+ end
+ connectionName = escapeforjbname jndi
+ if value.nil?
+ cmd = compilecmd "/subsystem=resource-adapters/resource-adapter=#{@resource[:name]}/connection-definitions=#{connectionName}:undefine-attribute(name=#{name})"
+ bringDown "Resource adapter connection definition attribute #{name}", cmd
+ else
+ setattribute "/subsystem=resource-adapters/resource-adapter=#{@resource[:name]}/connection-definitions=#{connectionName}", name, value
+ end
+ $data['connection-definitions'][jndi][name] = value
+ end
+ end
+
+ def getconnectionattr name
+ prepareconfig()[:connections].each do |jndi, config|
+ if not connExists? jndi
+ return nil
+ end
+ if $data['connection-definitions'][jndi].nil?
+ return nil
+ end
+ return $data['connection-definitions'][jndi][name]
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/lib/puppet/provider/jboss_securitydomain/jbosscli.rb b/lib/puppet/provider/jboss_securitydomain/jbosscli.rb
new file mode 100644
index 0000000..25a1270
--- /dev/null
+++ b/lib/puppet/provider/jboss_securitydomain/jbosscli.rb
@@ -0,0 +1,67 @@
+require File.expand_path(File.join(File.dirname(File.dirname(__FILE__)), 'jbosscli.rb'))
+
+Puppet::Type.type(:jboss_securitydomain).provide(:jbosscli, :parent => Puppet::Provider::Jbosscli) do
+
+ def create
+ cmd = compilecmd "/subsystem=security/security-domain=#{@resource[:name]}/authentication=classic:add(login-modules=[{code=>\"#{@resource[:code]}\",flag=>\"#{@resource[:codeflag]}\",module-options=>["
+ @resource[:moduleoptions].each_with_index do |(key, value), index|
+ val = value.to_s.gsub(/\n/, ' ').strip
+ cmd += '%s => "%s"' % [key, val]
+ if index == @resource[:moduleoptions].length - 1
+ break
+ end
+ cmd += ","
+ end
+ cmd += "]}])"
+ cmd2 = compilecmd "/subsystem=security/security-domain=#{@resource[:name]}:add(cache-type=default)"
+ bringUp('Security Domain Cache Type', cmd2)[:result]
+ bringUp('Security Domain', cmd)[:result]
+ end
+
+ def destroy
+ cmd = compilecmd "/subsystem=security/security-domain=#{@resource[:name]}:remove()"
+ bringDown('Security Domain', cmd)[:result]
+ end
+
+ def preparelines lines
+ lines.gsub(/\((\"[^\"]+\") => (\"[^\"]+\")\)/, '\1 => \2').gsub(/\[((?:[\n\s]*\"[^\"]+\" => \"[^\"]+\",?[\n\s]*)+)\]/m, '{\1}')
+ end
+
+ #
+ def exists?
+ cmd = compilecmd "/subsystem=security/security-domain=#{@resource[:name]}/authentication=classic:read-resource()"
+ res = executeWithoutRetry cmd
+ if not res[:result]
+ Puppet.debug "Security Domain does NOT exist"
+ return false
+ end
+ undefined = nil
+ lines = preparelines res[:lines]
+ data = eval(lines)['result']
+ Puppet.debug "Security Domain exists: #{data.inspect}"
+
+ existinghash = Hash.new
+ givenhash = Hash.new
+
+ if !@resource[:moduleoptions].nil?
+ @resource[:moduleoptions].each do |key, value|
+ givenhash["#{key}"] = value.to_s.gsub(/\n/, ' ').strip
+ end
+ end
+
+ data['login-modules'][0]['module-options'].each do |key, value|
+ existinghash[key.to_s] = value.to_s.gsub(/\n/, ' ').strip
+ end
+
+ if !existinghash.nil? && !givenhash.nil? && existinghash != givenhash
+ diff = givenhash.to_a - existinghash.to_a
+ Puppet.notice "Security domain should be recreated. Diff: #{diff.inspect}"
+ Puppet.debug "Security domain moduleoptions existing hash => #{existinghash.inspect}"
+ Puppet.debug "Security domain moduleoptions given hash => #{givenhash.inspect}"
+ destroy
+ return false
+ end
+ return true
+ end
+
+end
diff --git a/lib/puppet/provider/jbosscli.rb b/lib/puppet/provider/jbosscli.rb
new file mode 100644
index 0000000..f32c2c0
--- /dev/null
+++ b/lib/puppet/provider/jbosscli.rb
@@ -0,0 +1,277 @@
+# -*- coding: utf-8 -*-
+require File.expand_path(File.join(File.dirname(__FILE__), '../../puppet_x/coi/jboss/configuration'))
+require 'tempfile'
+
+class Object
+ def blank?
+ return true if self.nil?
+ self.respond_to?(:empty?) ? self.empty? : !self
+ end
+
+ def to_bool
+ if self.respond_to?(:empty?)
+ str = self
+ else
+ str = self.to_s
+ end
+ if self.is_a? Numeric
+ return self != 0
+ end
+ return true if self == true || str =~ (/(true|t|yes|y)$/i)
+ return false if self == false || self.blank? || str =~ (/(false|f|no|n)$/i)
+ raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
+ end
+end
+class Hash
+ def hashbackmap
+ result = {}
+
+ self.each do |key, val|
+ result[key] = yield val
+ end
+
+ result
+ end
+end
+
+class Puppet::Provider::Jbosscli < Puppet::Provider
+
+ @@bin = "bin/jboss-cli.sh"
+ @@contents = nil
+
+ class << self
+ def jbossclibin
+ home = self.jbosshome
+ path = "#{home}/#{@@bin}"
+ return path
+ end
+
+ def jbosshome
+ Puppet_X::Coi::Jboss::Configuration::config_value :home
+ end
+
+ def jbosslog
+ Puppet_X::Coi::Jboss::Configuration::config_value :console_log
+ end
+
+ def config_runasdomain
+ Puppet_X::Coi::Jboss::Configuration::config_value :runasdomain
+ end
+
+ def config_controller
+ Puppet_X::Coi::Jboss::Configuration::config_value :controller
+ end
+
+ def config_profile
+ Puppet_X::Coi::Jboss::Configuration::config_value :profile
+ end
+
+ end
+
+ # TODO: Uncomment for defered provider confinment after droping support for Puppet < 3.0
+ # commands :jbosscli => Puppet::Provider::Jbosscli.jbossclibin
+
+ def runasdomain?
+ @resource[:runasdomain]
+ end
+
+ def getlog(lines)
+ last_lines = `tail -n #{lines} #{jbosslog}`
+ end
+
+ def printlog(lines)
+ return " ---\n JBoss AS log (last #{lines} lines): \n#{getlog lines}"
+ end
+
+ def execute jbosscmd
+ retry_count = @resource[:retry]
+ retry_timeout = @resource[:retry_timeout]
+ ctrlcfg = Puppet::Provider::Jbosscli.controllerConfig @resource
+ return Puppet::Provider::Jbosscli.execute jbosscmd, runasdomain?, ctrlcfg, retry_count, retry_timeout
+ end
+
+ def executeWithoutRetry jbosscmd
+ ctrlcfg = Puppet::Provider::Jbosscli.controllerConfig @resource
+ return Puppet::Provider::Jbosscli.execute jbosscmd, runasdomain?, ctrlcfg, 0, 0
+ end
+
+ def executeAndGet jbosscmd
+ ctrlcfg = Puppet::Provider::Jbosscli.controllerConfig @resource
+ return Puppet::Provider::Jbosscli.executeAndGet jbosscmd, runasdomain?, ctrlcfg, 0, 0
+ end
+
+ def self.controllerConfig resource
+ conf = {
+ :controller => resource[:controller],
+ :ctrluser => resource[:ctrluser],
+ :ctrlpasswd => resource[:ctrlpasswd],
+ }
+ return conf
+ end
+
+ def self.last_execute_status
+ $?
+ end
+
+ def self.execshell(cmd)
+ `#{cmd}`
+ end
+
+ def self.jbossas?
+ Facter.value(:jboss_product) == 'jboss-as'
+ end
+
+ def self.timeout_cli
+ '--timeout=50000' unless jbossas?
+ end
+
+ def self.execute jbosscmd, runasdomain, ctrlcfg, retry_count, retry_timeout
+ file = Tempfile.new 'jbosscli'
+ path = file.path
+ file.close
+ file.unlink
+
+ File.open(path, 'w') {|f| f.write(jbosscmd + "\n") }
+
+ ENV['JBOSS_HOME'] = self.jbosshome
+ cmd = "#{self.jbossclibin} #{timeout_cli} --connect --file=#{path} --controller=#{ctrlcfg[:controller]}"
+ unless ctrlcfg[:ctrluser].nil?
+ cmd += " --user=#{ctrlcfg[:ctrluser]}"
+ end
+ unless ctrlcfg[:ctrlpasswd].nil?
+ ENV['__PASSWD'] = ctrlcfg[:ctrlpasswd]
+ cmd += " --password=$__PASSWD"
+ end
+
+ retries = 0
+ result = ''
+ lines = ''
+ begin
+ if retries > 0
+ Puppet.warning "JBoss CLI command failed, try #{retries}/#{retry_count}, last status: #{result.exitstatus.to_s}, message: #{lines}"
+ sleep retry_timeout.to_i
+ end
+ Puppet.debug "Command send to JBoss CLI: " + jbosscmd
+ lines = self.execshell(cmd)
+ result = self.last_execute_status
+ retries += 1
+ end while (result.exitstatus != 0 && retries <= retry_count)
+ Puppet.debug "Output from JBoss CLI [%s]: %s" % [result.inspect, lines]
+ # deletes the temp file
+ File.unlink path
+ return {
+ :cmd => jbosscmd,
+ :result => result.exitstatus == 0,
+ :lines => lines
+ }
+ end
+
+ def setattribute(path, name, value)
+ setattribute_raw path, name, escape(value)
+ end
+
+ def setattribute_raw(path, name, value)
+ Puppet.debug "#{name.inspect} setting to #{value.inspect} for path: #{path}"
+ cmd = "#{path}:write-attribute(name=\"#{name.to_s}\", value=#{value})"
+ if runasdomain?
+ cmd = "/profile=#{@resource[:profile]}#{cmd}"
+ end
+ res = executeAndGet(cmd)
+ Puppet.debug(res.inspect)
+ if not res[:result]
+ raise "Cannot set #{name} for #{path}: #{res[:data]}"
+ end
+ @property_hash[name] = value
+ end
+
+ def bringUp(typename, args)
+ return executeWithFail(typename, args, 'to create')
+ end
+
+ def bringDown(typename, args)
+ return executeWithFail(typename, args, 'to remove')
+ end
+
+ $add_log = nil
+
+ def isprintinglog=(setting)
+ $add_log = setting
+ end
+
+ def trace method
+ Puppet.debug '%s[%s] > IN > %s' % [self.class, @resource[:name], method]
+ end
+
+ def traceout method, retval
+ Puppet.debug '%s[%s] > OUT > %s: %s' % [self.class, @resource[:name], method, retval.inspect]
+ end
+
+ def self.escape value
+ if value.respond_to? :to_str
+ str = value.gsub(/([^\\])\"/, '\1\\"')
+ else
+ str = value
+ end
+ return str.inspect
+ end
+
+ def escape value
+ Puppet::Provider::Jbosscli.escape value
+ end
+
+ def executeWithFail(typename, passed_args, way)
+ executed = execute(passed_args)
+ if not executed[:result]
+ ex = "\n#{typename} failed #{way}:\n[CLI command]: #{executed[:cmd]}\n[Error message]: #{executed[:lines]}"
+ if not $add_log.nil? and $add_log > 0
+ ex = "#{ex}\n#{printlog $add_log}"
+ end
+ raise ex
+ end
+ return executed
+ end
+
+ def compilecmd cmd
+ Puppet::Provider::Jbosscli.compilecmd @resource[:runasdomain], @resource[:profile], cmd
+ end
+
+ def self.compilecmd runasdomain, profile, cmd
+ out = cmd.to_s
+ asdomain = runasdomain.to_bool
+ if asdomain && out[0..9] == '/subsystem'
+ out = "/profile=#{profile}#{out}"
+ end
+ return out
+ end
+
+ def self.executeAndGet cmd, runasdomain, ctrlcfg, retry_count, retry_timeout
+ ret = self.execute cmd, runasdomain, ctrlcfg, retry_count, retry_timeout
+ if not ret[:result]
+ return {
+ :result => false,
+ :data => ret[:lines]
+ }
+ end
+ # Giving JBoss `undefine` value in Ruby
+ undefined = nil
+ # JBoss expression and Long value handling
+ ret[:lines].gsub!(/expression \"(.+)\",/, '\'\1\',')
+ ret[:lines].gsub!(/=> (\d+)L/, '=> \1')
+ begin
+ evalines = eval ret[:lines]
+ Puppet.debug evalines.inspect
+ return {
+ :result => evalines["outcome"] == "success",
+ :data => (evalines["outcome"] == "success" ? evalines["result"] : evalines["failure-description"])
+ }
+ rescue Exception => e
+ Puppet.err e
+ return {
+ :result => false,
+ :data => ret[:lines]
+ }
+ end
+ end
+
+
+end
diff --git a/lib/puppet/type/jboss_confignode.rb b/lib/puppet/type/jboss_confignode.rb
new file mode 100644
index 0000000..926704e
--- /dev/null
+++ b/lib/puppet/type/jboss_confignode.rb
@@ -0,0 +1,86 @@
+Puppet::Type.newtype(:jboss_confignode) do
+ @doc = "Generic configuration entry for JBoss Application Sever"
+
+ newproperty(:ensure) do
+ desc "Whether a configuration node should be in one of `present`, `absent`, `running`, `stopped`, `disabled` or `enabled` state."
+
+ newvalues :stopped, :running, :present, :absent, :enabled, :disabled
+
+ aliasvalue(:true, :present)
+ aliasvalue(:false, :absent)
+
+ end
+ newparam(:name) do
+ desc "The name of resource"
+ end
+
+ newparam(:path) do
+ desc "The JBoss configuration path to be ensured"
+ end
+
+ newproperty(:properties) do
+ desc "Additional properties for node"
+
+ munge do |value|
+ unless value.respond_to? :[]
+ {}
+ else
+ value
+ end
+ end
+
+ def change_to_s(current, desire)
+ changes = []
+ desire.each do |key, desired_value|
+ current_value = current[key]
+ message = "property '#{key}' has been changed from #{current_value.inspect} to #{desired_value.inspect}"
+ changes << message unless current_value == desired_value
+ end
+ changes.join ', '
+ end
+ end
+
+ newparam(:profile) do
+ desc "The JBoss profile name"
+ defaultto "full"
+ end
+
+ newparam(:runasdomain, :boolean => true) do
+ desc "Indicate that server is in domain mode"
+ newvalues :true, :false
+ defaultto :true
+
+ munge do |val|
+ val == :true or val == true
+ end
+ end
+
+ newparam(:controller) do
+ desc "Domain controller host:port address"
+ validate do |value|
+ if value == nil or value.to_s == 'undef'
+ raise ArgumentError, "Domain controller must be provided"
+ end
+ end
+ end
+
+ newparam :ctrluser do
+ desc 'A user name to connect to controller'
+ end
+
+ newparam :ctrlpasswd do
+ desc 'A password to be used to connect to controller'
+ end
+
+ newparam :retry do
+ desc "Number of retries."
+ defaultto 3
+ end
+
+ newparam :retry_timeout do
+ desc "Retry timeout in seconds"
+ defaultto 1
+ end
+
+
+end
\ No newline at end of file
diff --git a/lib/puppet/type/jboss_datasource.rb b/lib/puppet/type/jboss_datasource.rb
new file mode 100644
index 0000000..4d8d999
--- /dev/null
+++ b/lib/puppet/type/jboss_datasource.rb
@@ -0,0 +1,165 @@
+Puppet::Type.newtype(:jboss_datasource) do
+ @doc = "Data sources configuration for JBoss Application Sever"
+ ensurable
+
+ newparam(:name) do
+ desc "Name of type resource"
+ isnamevar
+ end
+
+ newproperty(:xa) do
+ desc "Is it XA Datasource?"
+ newvalues :true, :false
+ defaultto :false
+ munge do |value|
+ value == :true or value == true
+ end
+ end
+
+ newproperty(:dbname) do
+ desc "The database's name"
+ end
+
+ newproperty(:jndiname) do
+ desc "jndi-name"
+ end
+
+ newproperty(:jta) do
+ desc "jta"
+ newvalues :true, :false
+ defaultto :true
+ munge do |value|
+ value == :true or value == true
+ end
+ end
+
+ newproperty(:drivername) do
+ desc "driver-name"
+ isrequired
+ end
+
+ newproperty(:minpoolsize) do
+ desc "min-pool-size"
+ munge do |value|
+ value.to_i if Float value rescue 1
+ end
+ end
+
+ newproperty(:maxpoolsize) do
+ desc "max-pool-size"
+ munge do |value|
+ value.to_i if Float value rescue 50
+ end
+ end
+
+ newproperty(:username) do
+ desc "user-name"
+ isrequired
+ end
+
+ newproperty(:password) do
+ desc "The internal JBoss user asadmin uses. Default: admin"
+ isrequired
+ def change_to_s from, to
+ "password has been changed."
+ end
+ end
+
+ newproperty(:options) do
+ desc "Extra options for datasource or xa-datasource"
+
+ validate do |value|
+ unless value.respond_to? :[]
+ fail "You can pass only hash-like objects"
+ end
+ end
+
+ def change_to_s(current, desire)
+ changes = []
+ desire.each do |key, desired_value|
+ current_value = current[key]
+ message = "option '#{key}' has changed from #{current_value.inspect} to #{desired_value.inspect}"
+ changes << message unless current_value == desired_value
+ end
+ changes.join ', '
+ end
+ end
+
+ newproperty(:enabled) do
+ desc "Is datasource enabled?"
+ newvalues :true, :false
+ defaultto :true
+ munge do |value|
+ value == :true or value == true
+ end
+ end
+
+ newproperty(:host) do
+ desc "host to connect"
+ isrequired
+ validate do |value|
+ unless value =~ /\w/ or value == ''
+ raise ArgumentError, "Datasource host is invalid, given #{value.inspect}"
+ end
+ end
+ end
+
+ newproperty(:port) do
+ desc "port to connect"
+ isrequired
+ validate do |value|
+ unless value =~ /\d/ or value == ''
+ raise ArgumentError, "Datasource port is invalid, given #{value.inspect}"
+ end
+ end
+ munge do |value|
+ if value == '' then 0 else Integer(value) end
+ end
+ end
+
+ newproperty(:jdbcscheme) do
+ desc "jdbcscheme to be used"
+ isrequired
+ end
+
+ newparam(:profile) do
+ desc "The JBoss profile name"
+ defaultto "full"
+ end
+
+ newparam(:runasdomain, :boolean => true) do
+ desc "Indicate that server is in domain mode"
+ defaultto true
+ end
+
+ newparam(:controller) do
+ desc "Domain controller host:port address"
+ # Default is set to support listing of datasources without parameters (for easy use)
+ defaultto "127.0.0.1:9990"
+ validate do |value|
+ if value == nil or value.to_s == 'undef'
+ raise ArgumentError, "Domain controller must be provided"
+ end
+ end
+ end
+
+ newparam :ctrluser do
+ desc 'A user name to connect to controller'
+ end
+
+ newparam :ctrlpasswd do
+ desc 'A password to be used to connect to controller'
+ end
+
+ newparam :retry do
+ desc "Number of retries."
+ defaultto 3
+ end
+
+ newparam :retry_timeout do
+ desc "Retry timeout in seconds"
+ defaultto 1
+ end
+
+end
+
diff --git a/lib/puppet/type/jboss_deploy.rb b/lib/puppet/type/jboss_deploy.rb
new file mode 100644
index 0000000..91af0fb
--- /dev/null
+++ b/lib/puppet/type/jboss_deploy.rb
@@ -0,0 +1,56 @@
+Puppet::Type.newtype(:jboss_deploy) do
+ @doc = "Deploys and undeploys EAR/WAR artifacts on JBoss Application Server"
+ ensurable
+
+ newparam(:name) do
+ desc "The JNDI resource name."
+ isnamevar
+ isrequired
+ end
+
+ newparam(:source) do
+ desc "Path to the EAR/WAR file."
+ end
+
+ newparam(:redeploy, :boolean => true) do
+ desc "Force redeployment"
+ defaultto false
+ end
+
+ newproperty(:servergroups, :array_matching => :all) do
+ desc "Array of server groups on which deployment should be done"
+ end
+
+ newparam(:runasdomain, :boolean => true) do
+ desc "Indicate that server is in domain mode"
+ defaultto true
+ end
+
+ newparam(:controller) do
+ desc "Domain controller host:port address"
+ validate do |value|
+ if value == nil or value.to_s == 'undef'
+ raise ArgumentError, "Domain controller must be provided"
+ end
+ end
+ end
+
+ newparam :ctrluser do
+ desc 'A user name to connect to controller'
+ end
+
+ newparam :ctrlpasswd do
+ desc 'A password to be used to connect to controller'
+ end
+
+ newparam :retry do
+ desc "Number of retries."
+ defaultto 3
+ end
+
+ newparam :retry_timeout do
+ desc "Retry timeout in seconds"
+ defaultto 1
+ end
+
+end
diff --git a/lib/puppet/type/jboss_jdbcdriver.rb b/lib/puppet/type/jboss_jdbcdriver.rb
new file mode 100644
index 0000000..5022f3d
--- /dev/null
+++ b/lib/puppet/type/jboss_jdbcdriver.rb
@@ -0,0 +1,65 @@
+Puppet::Type.newtype(:jboss_jdbcdriver) do
+ @doc = "Manages JDBC driver on JBoss Application Server"
+ ensurable
+
+ newparam(:name) do
+ desc "The name of driver."
+ isnamevar
+ isrequired
+ end
+
+ newparam(:modulename) do
+ desc "Driver module name."
+ isrequired
+ end
+
+ newparam(:classname) do
+ desc "Driver Java class name."
+ end
+
+ newparam(:datasourceclassname) do
+ desc "Datasource Java class name."
+ end
+
+ newparam(:xadatasourceclassname) do
+ desc "XA Datasource Java class name."
+ end
+
+ newparam(:profile) do
+ desc "The JBoss profile name"
+ defaultto "full"
+ end
+
+ newparam(:runasdomain, :boolean => true) do
+ desc "Indicate that server is in domain mode"
+ defaultto true
+ end
+
+ newparam(:controller) do
+ desc "Domain controller host:port address"
+ validate do |value|
+ if value == nil or value.to_s == 'undef'
+ raise ArgumentError, "Domain controller must be provided"
+ end
+ end
+ end
+
+ newparam :ctrluser do
+ desc 'A user name to connect to controller'
+ end
+
+ newparam :ctrlpasswd do
+ desc 'A password to be used to connect to controller'
+ end
+
+ newparam :retry do
+ desc "Number of retries."
+ defaultto 3
+ end
+
+ newparam :retry_timeout do
+ desc "Retry timeout in seconds"
+ defaultto 1
+ end
+
+end
diff --git a/lib/puppet/type/jboss_jmsqueue.rb b/lib/puppet/type/jboss_jmsqueue.rb
new file mode 100644
index 0000000..030f9ed
--- /dev/null
+++ b/lib/puppet/type/jboss_jmsqueue.rb
@@ -0,0 +1,64 @@
+Puppet::Type.newtype(:jboss_jmsqueue) do
+ @doc = "JMS Queues configuration for JBoss Application Sever"
+ ensurable
+
+ newparam(:name) do
+ desc "name"
+ isnamevar
+ end
+
+ newproperty(:entries, :array_matching => :all) do
+ desc "entries passed as array"
+
+ def is_to_s is
+ return is.inspect
+ end
+ def should_to_s should
+ return should.inspect
+ end
+ end
+
+ newproperty(:durable, :boolean => true) do
+ newvalues :true, :false
+ defaultto false
+ desc "durable true/false"
+ end
+
+ newparam(:profile) do
+ desc "The JBoss profile name"
+ defaultto "full"
+ end
+
+ newparam(:runasdomain, :boolean => true) do
+ desc "Indicate that server is in domain mode"
+ defaultto true
+ end
+
+ newparam(:controller) do
+ desc "Domain controller host:port address"
+ validate do |value|
+ if value == nil or value.to_s == 'undef'
+ raise ArgumentError, "Domain controller must be provided"
+ end
+ end
+ end
+
+ newparam :ctrluser do
+ desc 'A user name to connect to controller'
+ end
+
+ newparam :ctrlpasswd do
+ desc 'A password to be used to connect to controller'
+ end
+
+ newparam :retry do
+ desc "Number of retries."
+ defaultto 3
+ end
+
+ newparam :retry_timeout do
+ desc "Retry timeout in seconds"
+ defaultto 1
+ end
+
+end
diff --git a/lib/puppet/type/jboss_resourceadapter.rb b/lib/puppet/type/jboss_resourceadapter.rb
new file mode 100644
index 0000000..ffce511
--- /dev/null
+++ b/lib/puppet/type/jboss_resourceadapter.rb
@@ -0,0 +1,80 @@
+Puppet::Type.newtype(:jboss_resourceadapter) do
+ @doc = "Manages resource adapters on JBoss Application Server"
+ ensurable
+
+ newparam(:name) do
+ desc "The name/ID of resource adapter."
+ isnamevar
+ isrequired
+ end
+
+ newproperty(:archive) do
+ desc "The resource adapter archive."
+ isrequired
+ end
+
+ newproperty(:transactionsupport) do
+ desc "The resource adapter transaction support type."
+ isrequired
+ end
+
+ newproperty(:jndiname, :array_matching => :all) do
+ desc "The resource adapter connection definition jndi name."
+ isrequired
+ end
+
+ newproperty(:classname) do
+ desc "The resource adapter connection definition class name."
+ isrequired
+ end
+
+ newproperty(:security) do
+ desc "The resource adapter connection definition security."
+ isrequired
+ defaultto 'application'
+ end
+
+ newproperty(:backgroundvalidation, :boolean => true) do
+ desc "The resource adapter connection definition class name."
+ isrequired
+ defaultto true
+ end
+
+ newparam(:profile) do
+ desc "The JBoss profile name"
+ defaultto "full"
+ end
+
+ newparam(:runasdomain, :boolean => true) do
+ desc "Indicate that server is in domain mode"
+ defaultto true
+ end
+
+ newparam(:controller) do
+ desc "Domain controller host:port address"
+ validate do |value|
+ if value == nil or value.to_s == 'undef'
+ raise ArgumentError, "Domain controller must be provided"
+ end
+ end
+ end
+
+ newparam :ctrluser do
+ desc 'A user name to connect to controller'
+ end
+
+ newparam :ctrlpasswd do
+ desc 'A password to be used to connect to controller'
+ end
+
+ newparam :retry do
+ desc "Number of retries."
+ defaultto 3
+ end
+
+ newparam :retry_timeout do
+ desc "Retry timeout in seconds"
+ defaultto 1
+ end
+
+end
diff --git a/lib/puppet/type/jboss_securitydomain.rb b/lib/puppet/type/jboss_securitydomain.rb
new file mode 100644
index 0000000..aee42ec
--- /dev/null
+++ b/lib/puppet/type/jboss_securitydomain.rb
@@ -0,0 +1,59 @@
+Puppet::Type.newtype(:jboss_securitydomain) do
+ @doc = "Security-domain configuration for JBoss Application Sever"
+ ensurable
+
+ newparam(:name) do
+ desc ""
+ isnamevar
+ end
+
+ newparam(:moduleoptions) do
+ desc "module-options given as a table"
+ end
+
+ newparam(:profile) do
+ desc "The JBoss profile name"
+ defaultto "full"
+ end
+
+ newparam(:runasdomain) do
+ desc "Run server in domain mode"
+ defaultto true
+ end
+
+ newparam(:controller) do
+ desc "Domain controller host:port address"
+ validate do |value|
+ if value == nil or value.to_s == 'undef'
+ raise ArgumentError, "Domain controller must be provided"
+ end
+ end
+ end
+
+ newparam :ctrluser do
+ desc 'A user name to connect to controller'
+ end
+
+ newparam :ctrlpasswd do
+ desc 'A password to be used to connect to controller'
+ end
+
+ newparam :retry do
+ desc "Number of retries."
+ defaultto 3
+ end
+
+ newparam :retry_timeout do
+ desc "Retry timeout in seconds"
+ defaultto 1
+ end
+
+ newparam(:code) do
+ desc "code for JBOSS security-domain"
+ end
+
+ newparam(:codeflag) do
+ desc "codeflag for JBOSS security-domain"
+ end
+
+end
diff --git a/lib/puppet_x/coi/jboss/configuration.rb b/lib/puppet_x/coi/jboss/configuration.rb
new file mode 100644
index 0000000..0f537af
--- /dev/null
+++ b/lib/puppet_x/coi/jboss/configuration.rb
@@ -0,0 +1,93 @@
+# A puppet x module
+module Puppet_X
+# A COI puppet_x module
+module Coi
+# JBoss module
+module Jboss
+# A class for JBoss configuration
+class Configuration
+ class << self
+
+ @config = nil
+
+ # Gets the main config file
+ def configfile
+ content = self.read_raw_profile_d.chomp
+ re = /export JBOSS_CONF=\'([^\']+)\'/
+ m = re.match(content)
+ m[1]
+ rescue
+ ENV['JBOSS_CONF']
+ end
+
+ # Read the configuration with augeas
+ #
+ # @return [Hash] configuration in a hash object or nil if not avialable
+ def read
+ require 'augeas'
+
+ map = nil
+ cfgfile = self.configfile
+ unless cfgfile.nil?
+ aug = Augeas::open('/', nil, Augeas::NO_MODL_AUTOLOAD)
+ aug.transform(:lens => 'Shellvars.lns', :incl => cfgfile, :name => 'jboss-as.conf')
+ aug.load
+ is_bool = lambda { |value| !/^(true|false)$/.match(value).nil? }
+ to_bool = lambda { |value| if !/^true$/.match(value).nil? then true else false end }
+ map = {}
+ aug.match("/files#{cfgfile}/*").each do |key|
+ m = key[/(JBOSS_.+)$/]
+ if m
+ v = aug.get(key)
+ v = to_bool.call(v) if is_bool.call(v)
+ map[m.downcase.sub('jboss_', '')] = v
+ end
+ end
+ aug.close
+ end
+ map
+ end
+
+ # Checks is this execution is taking place on pre wildfly server
+ #
+ # @return [Boolean] true if execution is taking place on pre wildfly server
+ def is_pre_wildfly?
+ product = self.config_value(:product)
+ version = self.config_value(:version)
+ product == 'jboss-as' or ( product == 'jboss-eap' and version < '6.3.0.GA' )
+ end
+
+ # Resets configuration
+ #
+ # @param value [Hash] optional value to reset to
+ # @return nil
+ def reset_config(value = nil)
+ @config = value
+ nil
+ end
+
+ # Gets configuration value by its symbol
+ #
+ # @param key [Symbol] a key in hash
+ # @return [Object] configuration value
+ def config_value(key)
+ @config = self.read if @config.nil?
+ ret = nil
+ unless @config.nil?
+ arr = @config.map { |k,v| [k.to_s.to_sym, v] }
+ h = Hash[arr]
+ ret = h[key]
+ end
+ ret
+ end
+
+ def read_raw_profile_d
+ File.read('/etc/profile.d/jboss.sh')
+ end
+
+ end
+end
+
+end
+end
+end
\ No newline at end of file
diff --git a/lib/puppet_x/coi/jboss/functions/jboss_to_bool.rb b/lib/puppet_x/coi/jboss/functions/jboss_to_bool.rb
new file mode 100644
index 0000000..7611d76
--- /dev/null
+++ b/lib/puppet_x/coi/jboss/functions/jboss_to_bool.rb
@@ -0,0 +1,47 @@
+# A puppet x module
+module Puppet_X
+# A COI puppet_x module
+module Coi
+# JBoss module
+module Jboss
+# A custom class that holds custom functions
+class Functions
+
+ class << self
+ # PRIVATE INTERNAL FUNCTION. Casts any value to boolean
+ #
+ # @param args [Array] should be only one argument in array
+ # @return [string] casted value to boolean
+ def jboss_to_bool args
+ if args.size != 1
+ raise(Puppet::ParseError, "jboss_to_bool(): Wrong number of arguments given (#{args.size} for 1)")
+ end
+ string = args[0]
+ # If string is already Boolean, return it
+ if !!string == string
+ return string
+ end
+ string = string.to_s if string.is_a?(Symbol)
+ string = string.inspect unless string.is_a?(String)
+
+ # We consider all the yes, no, y, n and so on too ...
+ result = case string
+ #
+ # This is how undef looks like in Puppet ...
+ # We yield false in this case.
+ #
+ when /^$/, '' then false # Empty string will be false ...
+ when /^(1|t|y|true|yes)$/ then true
+ when /^(0|f|n|false|no)$/ then false
+ when /^(undef|undefined)$/ then false # This is not likely to happen ...
+ else
+ false
+ end
+
+ return result
+ end
+ end
+end
+end
+end
+end
\ No newline at end of file
diff --git a/lib/puppet_x/coi/jboss/functions/jboss_to_i.rb b/lib/puppet_x/coi/jboss/functions/jboss_to_i.rb
new file mode 100644
index 0000000..f2f168a
--- /dev/null
+++ b/lib/puppet_x/coi/jboss/functions/jboss_to_i.rb
@@ -0,0 +1,25 @@
+# A puppet x module
+module Puppet_X
+# A COI puppet_x module
+module Coi
+# JBoss module
+module Jboss
+# A custom class that holds custom functions
+class Functions
+
+ class << self
+ # PRIVATE INTERNAL FUNCTION. Casts any value to integer
+ #
+ # @param args [Array] should be only one argument in array
+ # @return [int] casted value to integer of input value
+ def jboss_to_i args
+ if args.size != 1
+ raise(Puppet::ParseError, "jboss_to_i(): Wrong number of arguments given (#{args.size} for 1)")
+ end
+ args[0].to_s.to_i
+ end
+ end
+end
+end
+end
+end
\ No newline at end of file
diff --git a/lib/puppet_x/coi/jboss/functions/jboss_to_s.rb b/lib/puppet_x/coi/jboss/functions/jboss_to_s.rb
new file mode 100644
index 0000000..d627eb8
--- /dev/null
+++ b/lib/puppet_x/coi/jboss/functions/jboss_to_s.rb
@@ -0,0 +1,25 @@
+# A puppet x module
+module Puppet_X
+# A COI puppet_x module
+module Coi
+# JBoss module
+module Jboss
+# A custom class that holds custom functions
+class Functions
+
+ class << self
+ # PRIVATE INTERNAL FUNCTION. Casts any value to string
+ #
+ # @param args [Array] should be only one argument in array
+ # @return [string] casted value to string
+ def jboss_to_s args
+ if args.size != 1
+ raise(Puppet::ParseError, "jboss_to_s(): Wrong number of arguments given (#{args.size} for 1)")
+ end
+ args[0].to_s
+ end
+ end
+end
+end
+end
+end
\ No newline at end of file
diff --git a/lib/puppet_x/coi/jboss/provider/datasource/post_wildfly_provider.rb b/lib/puppet_x/coi/jboss/provider/datasource/post_wildfly_provider.rb
new file mode 100644
index 0000000..59b10f5
--- /dev/null
+++ b/lib/puppet_x/coi/jboss/provider/datasource/post_wildfly_provider.rb
@@ -0,0 +1,43 @@
+# A puppet x module
+module Puppet_X
+# A COI puppet_x module
+module Coi
+# JBoss module
+module Jboss
+# JBoss provider module
+module Provider
+# JBoss datasource provider module
+module Datasource
+
+# A class for JBoss post WildFly datasource provider
+class PostWildFlyProvider
+ def initialize(provider)
+ @provider = provider
+ end
+ def xa_datasource_properties_wrapper(parameters)
+ "{#{parameters}}"
+ end
+
+ def jta
+ if @provider.xa?
+ true.to_s
+ else
+ @provider.getattrib('jta').to_s
+ end
+ end
+
+ def jta= value
+ Puppet.warning 'JTA does not make sense in XA Datasource as distributed transaction is being used' if @provider.xa?
+ @provider.setattrib('jta', value.to_s) unless @provider.xa?
+ end
+
+ def jta_opt(cmd)
+ cmd.push "--jta=#{@provider.resource[:jta].inspect}" unless @provider.xa?
+ end
+end
+
+end
+end
+end
+end
+end
\ No newline at end of file
diff --git a/lib/puppet_x/coi/jboss/provider/datasource/pre_wildfly_provider.rb b/lib/puppet_x/coi/jboss/provider/datasource/pre_wildfly_provider.rb
new file mode 100644
index 0000000..421288c
--- /dev/null
+++ b/lib/puppet_x/coi/jboss/provider/datasource/pre_wildfly_provider.rb
@@ -0,0 +1,39 @@
+# A puppet x module
+module Puppet_X
+# A COI puppet_x module
+module Coi
+# JBoss module
+module Jboss
+# JBoss provider module
+module Provider
+# JBoss datasource provider module
+module Datasource
+
+# A class for JBoss pre WildFly datasource provider
+class PreWildFlyProvider
+ def initialize(provider)
+ @provider = provider
+ end
+
+ def xa_datasource_properties_wrapper(parameters)
+ "[#{parameters}]"
+ end
+
+ def jta
+ @provider.getattrib('jta').to_s
+ end
+
+ def jta=(value)
+ @provider.setattrib('jta', value.to_s)
+ end
+
+ def jta_opt(cmd)
+ cmd.push "--jta=#{@provider.resource[:jta].inspect}"
+ end
+end
+
+end
+end
+end
+end
+end
\ No newline at end of file
diff --git a/manifests/clientry.pp b/manifests/clientry.pp
new file mode 100644
index 0000000..66a4789
--- /dev/null
+++ b/manifests/clientry.pp
@@ -0,0 +1,70 @@
+# == Define: jboss::clientry
+#
+# This define is very versitale. It can be used to add or remove any JBoss CLI entry. You can pass any number of properties for
+# given CLI path and each one will be manage, other parameters will not be changed.
+#
+# === Parameters:
+#
+# This type uses *JBoss module standard metaparameters*
+#
+# [*ensure*]
+# Standard ensure parameter. Can be either `present` or `absent`.
+# [*path*]
+# This is the namevar. Path of the CLI entry. This is path accepted by JBoss CLI. The path must be passed without
+# `/profile=` in domain mode as well (for that `profile` parameter must be used).
+# [*properties*]
+# This is optional properties hash. You can pass any valid JBoss properties for given `path`. For valid ones head to the JBoss
+# Application Server documentation. Must be hash object or `undef` value.
+# [*dorestart*]
+# This parameter forces to execute command `:restart()` on this CLI entry.
+#
+define jboss::clientry (
+ $ensure = 'present',
+ $path = $name,
+ $properties = undef,
+ $profile = $::jboss::profile,
+ $controller = $::jboss::controller,
+ $runasdomain = $::jboss::runasdomain,
+ $dorestart = true,
+) {
+ include jboss
+ include jboss::internal::service
+ include jboss::internal::runtime::node
+
+ case $ensure {
+ 'running': {}
+ 'stopped': {}
+ 'absent': {}
+ 'present': {}
+ 'enabled': {}
+ 'disabled': {}
+ default: {
+ fail("Invalid value for ensure: `${ensure}`. Supported values are: `present`, `absent`, `running`, `stopped`, `enabled`, `disabled`")
+ }
+ }
+
+ jboss_confignode { $name:
+ ensure => $ensure,
+ path => $path,
+ properties => $properties,
+ controller => $controller,
+ ctrluser => $jboss::internal::runtime::node::username,
+ ctrlpasswd => $jboss::internal::runtime::node::password,
+ profile => $profile,
+ runasdomain => $runasdomain,
+ require => Anchor['jboss::package::end'],
+ }
+
+ if str2bool($::jboss_running) {
+ Jboss_confignode[$name] ~> Service[$jboss::internal::service::servicename]
+ } else {
+ Anchor['jboss::service::end'] -> Jboss_confignode[$name]
+ }
+
+ if $dorestart {
+ if !$::jboss::runasdomain {
+ Jboss_confignode[$name] ~> Exec['jboss::service::restart']
+ }
+ }
+
+}
diff --git a/manifests/datasource.pp b/manifests/datasource.pp
new file mode 100644
index 0000000..66c3526
--- /dev/null
+++ b/manifests/datasource.pp
@@ -0,0 +1,162 @@
+# == Define: jboss::datasource
+#
+# This defined type can be used to add and remove JBoss data sources. It support both XA and Non-XA data sources. It can setup data
+# sources and manage required drivers.
+#
+# === Parameters
+#
+# This type uses *JBoss module standard metaparameters*
+#
+# [*jdbcscheme*]
+# **Required parameter.** This is the JDBC scheme for ex.: `postgresql`, `oracle`, `mysql`, `mssql` or `h2:mem`. All accepted
+# by JBoss JDBC shemes are valid.
+# [*host*]
+# **Required parameter.** This is the name of the database host or it's IP address. Pass empty string `''` if host isn't needed.
+# [*port*]
+# **Required parameter.** This is the port of the database. Pass empty string `''` if port isn't needed.
+# [*username*]
+# **Required parameter.** This is the user name that will be used to connect to database.
+# [*password*]
+# **Required parameter.** This is the password that will be used to connect to database.
+# [*dbname*]
+# **This is the namevar**. Name of the database to be used.
+# [*ensure*]
+# Standard ensure parameter. Can be either `present` or `absent`.
+# [*jndiname*]
+# Java JNDI name of the datasource. Be default it is equals to `java:jboss/datasources/`
+# [*xa*]
+# This parameters indicate that given data source should XA or Non-XA type. Be default this is equal to `false`
+# [*jta*]
+# This parameters indicate that given data source should support Java JTA transactions. Be default this is equal to `true`
+# [*minpoolsize*]
+# Minimum connections in connection pool. By default it is equal to `1`.
+# [*maxpoolsize*]
+# Maximum connections in connection pool. By default it is equal to `50`.
+# [*enabled*]
+# This parameter control whether given data source should be enabled or not. By default it is equal to `true`.
+# [*options*]
+# This is an extra options hash. You can give any additional options that will be passed directly to JBoss data source. Any
+# supported by JBoss values will be accepted and enforced. Values that are not mentioned are not processed.
+#
+# Default options added to every data source (they can be overwritten):
+#
+# - `validate-on-match` => `false`
+# - `background-validation` => `false`
+# - `share-prepared-statements` => `false`
+# - `prepared-statements-cache-size` => `0`
+#
+# Default options added to every XA data source (they can be overwritten):
+#
+# - `same-rm-override` => `true`
+# - `wrap-xa-resource` => `true`
+#
+define jboss::datasource (
+ $jdbcscheme,
+ $host,
+ $port,
+ $username,
+ $password,
+ $driver,
+ $dbname = $name,
+ $ensure = 'present',
+ $jndiname = "java:jboss/datasources/${name}",
+ $xa = jboss_to_bool(hiera('jboss::datasource::xa', false)),
+ $jta = jboss_to_bool(hiera('jboss::datasource::jta', true)),
+ $profile = $::jboss::profile,
+ $controller = $::jboss::controller,
+ $minpoolsize = jboss_to_i(hiera('jboss::datasource::minpoolsize', 1)),
+ $maxpoolsize = jboss_to_i(hiera('jboss::datasource::maxpoolsize', 50)),
+ $enabled = jboss_to_bool(hiera('jboss::datasource::enabled', true)),
+ $options = {},
+ $runasdomain = $::jboss::runasdomain,
+) {
+ include jboss
+ include jboss::internal::service
+ include jboss::internal::runtime::node
+
+ $drivername = $driver['name']
+
+ $default_hash = {
+ 'validate-on-match' => jboss_to_bool(hiera('jboss::datasource::validateonmatch', false)),
+ 'background-validation' => jboss_to_bool(hiera('jboss::datasource::backgroundvalidation', false)),
+ 'share-prepared-statements' => jboss_to_bool(hiera('jboss::datasource::sharepreparedstatements', false)),
+ 'prepared-statements-cache-size' => jboss_to_i(hiera('jboss::datasource::preparedstatementscachesize', 0))
+ }
+
+ if $xa {
+ $default_xa_hash = {
+ 'same-rm-override' => jboss_to_bool(hiera('jboss::datasource::samermoverride', true)),
+ 'wrap-xa-resource' => jboss_to_bool(hiera('jboss::datasource::wrapxaresource', true))
+ }
+ $default_options = merge($default_hash, $default_xa_hash)
+ } else {
+ $default_options = $default_hash
+ }
+
+ $actual_options = merge($default_options, $options)
+
+ if ! defined(Jboss_jdbcdriver[$drivername]) and $ensure == 'present' {
+
+ $datasourceclassname = has_key($driver, 'datasourceclassname') ? {
+ true => $driver['datasourceclassname'],
+ default => undef,
+ }
+
+ $xadatasourceclassname = has_key($driver, 'xadatasourceclassname') ? {
+ true => $driver['xadatasourceclassname'],
+ default => undef,
+ }
+
+ jboss_jdbcdriver { $drivername:
+ ensure => 'present',
+ classname => $driver['classname'],
+ modulename => $driver['modulename'],
+ datasourceclassname => $datasourceclassname,
+ xadatasourceclassname => $xadatasourceclassname,
+ runasdomain => $runasdomain,
+ profile => $profile,
+ controller => $controller,
+ ctrluser => $jboss::internal::runtime::node::username,
+ ctrlpasswd => $jboss::internal::runtime::node::password,
+ require => Anchor['jboss::package::end'],
+ before => Jboss_Datasource[$name],
+ }
+ if jboss_to_bool($::jboss_running) {
+ Jboss_jdbcdriver[$drivername] ~> Service[$jboss::internal::service::servicename]
+ } else {
+ Anchor['jboss::service::end'] -> Jboss_jdbcdriver[$drivername] ~> Exec['jboss::service::restart']
+ }
+ }
+
+ jboss_datasource { $name:
+ ensure => $ensure,
+ dbname => $dbname,
+ enabled => $enabled,
+ runasdomain => $runasdomain,
+ profile => $profile,
+ controller => $controller,
+ ctrluser => $jboss::internal::runtime::node::username,
+ ctrlpasswd => $jboss::internal::runtime::node::password,
+ jndiname => $jndiname,
+ jta => $jta,
+ xa => $xa,
+ drivername => $drivername,
+ minpoolsize => $minpoolsize,
+ maxpoolsize => $maxpoolsize,
+ username => $username,
+ password => $password,
+ host => $host,
+ port => $port,
+ jdbcscheme => $jdbcscheme,
+ options => $actual_options,
+ require => [
+ Anchor['jboss::package::end'],
+ ],
+ }
+
+ if jboss_to_bool($::jboss_running) {
+ Jboss_datasource[$name] ~> Service[$jboss::internal::service::servicename]
+ } else {
+ Anchor['jboss::service::end'] -> Jboss_datasource[$name] ~> Exec['jboss::service::restart']
+ }
+}
diff --git a/manifests/deploy.pp b/manifests/deploy.pp
new file mode 100644
index 0000000..f001fc6
--- /dev/null
+++ b/manifests/deploy.pp
@@ -0,0 +1,29 @@
+# Deploys artifact to JBoss server
+define jboss::deploy (
+ $path,
+ $ensure = 'present',
+ $jndi = $name,
+ $redeploy = false,
+ $servergroups = hiera('jboss::deploy::servergroups', undef),
+ $controller = $::jboss::controller,
+ $runasdomain = $::jboss::runasdomain,
+) {
+ include jboss
+ include jboss::internal::runtime::node
+
+ jboss_deploy { $jndi:
+ ensure => $ensure,
+ source => $path,
+ runasdomain => $runasdomain,
+ redeploy => $redeploy,
+ servergroups => $servergroups,
+ controller => $controller,
+ ctrluser => $jboss::internal::runtime::node::username,
+ ctrlpasswd => $jboss::internal::runtime::node::password,
+ require => [
+ Anchor['jboss::service::end'],
+ Exec['jboss::service::restart'],
+ ],
+ }
+
+}
diff --git a/manifests/domain/controller.pp b/manifests/domain/controller.pp
new file mode 100644
index 0000000..2b4184d
--- /dev/null
+++ b/manifests/domain/controller.pp
@@ -0,0 +1,9 @@
+# == Class: jboss::domain::controller
+#
+# This class will setup JBoss server to run as controller of the domain. It has no parameters.
+#
+class jboss::domain::controller {
+ class { 'jboss::internal::runtime::dc':
+ runs_as_controller => true,
+ }
+}
diff --git a/manifests/domain/node.pp b/manifests/domain/node.pp
new file mode 100644
index 0000000..0c03c29
--- /dev/null
+++ b/manifests/domain/node.pp
@@ -0,0 +1,14 @@
+# == Class: jboss::domain::node
+#
+# This class will setup JBoss server to run as node of the domain. It takes two parameters: `ctrluser` and `ctrlpassword`. User name
+# and password must be setup to JBoss controller. Easiest way to add jboss management user with `jboss::user` type.
+#
+class jboss::domain::node (
+ $ctrluser,
+ $ctrlpassword,
+) {
+ class { 'jboss::internal::runtime::node':
+ username => $ctrluser,
+ password => $ctrlpassword,
+ }
+}
diff --git a/manifests/domain/server.pp b/manifests/domain/server.pp
new file mode 100644
index 0000000..7cf4d3e
--- /dev/null
+++ b/manifests/domain/server.pp
@@ -0,0 +1,81 @@
+# Creates JBoss domain server
+define jboss::domain::server (
+ $group = false,
+ $ensure = 'running',
+ $host = undef,
+ $autostart = true,
+ $socket_binding_group = undef,
+ $socket_binding_port_offset = $::jboss::internal::params::socketbinding::port_offset,
+ $controller = $::jboss::controller,
+) {
+ include jboss
+
+ $host_is_null = $host == undef
+ $hostname = $host_is_null ? {
+ true => $jboss::hostname,
+ default => $host,
+ }
+
+ if ! $group and $ensure == 'running' {
+ fail("Must pass group to Jboss::Domain::Server[${name}] while ensuring to be `${ensure}`")
+ }
+
+ $props = {
+ 'group' => $group,
+ 'auto-start' => $autostart,
+ 'socket-binding-port-offset' => $socket_binding_port_offset,
+ }
+ if $socket_binding_group {
+ jboss_hash_setvalue($props, 'socket-binding-group', $socket_binding_group)
+ }
+ case $ensure {
+ 'running': {}
+ 'stopped': {}
+ 'absent': {}
+ 'present': {}
+ default: {
+ fail("Invalid value for ensure: `${ensure}`. Supported values are: `present`, `absent`, `running`, `stopped`")
+ }
+ }
+ $ensurex = $ensure ? {
+ 'absent' => 'absent',
+ default => 'present',
+ }
+
+ if ! jboss_to_bool($::jboss_running) and $ensurex == 'absent' {
+ include jboss::internal::augeas
+ $cfg_file = $jboss::internal::runtime::hostconfigpath
+ $path = 'host/servers'
+ $augeas_defaults = merge($jboss::internal::augeas::defaults, {
+ context => "/files${cfg_file}/",
+ incl => $cfg_file,
+ })
+ $augeas = {
+ "ensure absent server ${name}" => merge($augeas_defaults, {
+ changes => "rm ${path}/server[#attribute/name='${name}']",
+ onlyif => "match ${path}/server[#attribute/name='${name}'] size != 0",
+ })
+ }
+ create_resources('augeas', $augeas)
+ } else {
+ jboss::clientry { "jboss::domain::server(${name})":
+ ensure => $ensure,
+ path => "/host=${hostname}/server-config=${name}",
+ controller => $controller,
+ runasdomain => true,
+ properties => $props,
+ }
+
+ if $ensurex == 'present' {
+ if ! defined(Jboss::Domain::Servergroup[$group]) {
+ jboss::domain::servergroup { $group:
+ ensure => $ensurex,
+ controller => $controller,
+ }
+ }
+ Jboss::Domain::Servergroup[$group] ->
+ Jboss::Clientry["jboss::domain::server(${name})"]
+ }
+ }
+
+}
diff --git a/manifests/domain/servergroup.pp b/manifests/domain/servergroup.pp
new file mode 100644
index 0000000..a893fa2
--- /dev/null
+++ b/manifests/domain/servergroup.pp
@@ -0,0 +1,77 @@
+# Creates JBoss domain server group
+define jboss::domain::servergroup (
+ $ensure = 'present',
+ $permgensize = $::jboss::internal::params::memorydefaults::permgensize,
+ $maxpermgensize = $::jboss::internal::params::memorydefaults::maxpermgensize,
+ $heapsize = $::jboss::internal::params::memorydefaults::heapsize,
+ $maxheapsize = $::jboss::internal::params::memorydefaults::maxheapsize,
+ $profile = $::jboss::profile,
+ $socket_binding_group = $::jboss::internal::params::socketbinding::group,
+ $socket_binding_port_offset = $::jboss::internal::params::socketbinding::port_offset,
+ $controller = $::jboss::controller,
+ $system_properties = {},
+ $jvmopts = undef,
+) {
+ include jboss
+
+ case $ensure {
+ 'absent': {}
+ 'present': {}
+ default: {
+ fail("Invalid value for ensure: `${ensure}`. Supported values are: `present`, `absent`")
+ }
+ }
+
+ jboss::clientry { "jboss::domain::servergroup(${name})":
+ ensure => $ensure,
+ path => "/server-group=${name}",
+ controller => $controller,
+ runasdomain => true,
+ properties => {
+ 'profile' => $profile,
+ 'socket-binding-group' => $socket_binding_group,
+ 'socket-binding-port-offset' => $socket_binding_port_offset,
+ }
+ }
+
+ $jvmopts_set = $jvmopts != undef
+ $jvmopts_str = $jvmopts_set ? {
+ true => $jvmopts,
+ default => undef,
+ }
+
+ $jvmproperties = {
+ 'heap-size' => $heapsize,
+ 'max-heap-size' => $maxheapsize,
+ 'max-permgen-size' => $maxpermgensize,
+ 'jvm-options' => $jvmopts_str,
+ }
+
+ jboss::clientry { "jboss::domain::servergroup::jvm(${name})":
+ ensure => $ensure,
+ path => "/server-group=${name}/jvm=default",
+ controller => $controller,
+ runasdomain => true,
+ properties => $jvmproperties
+ }
+
+ #Prepend server group name to each system property. Result is 'group:property'
+ $system_properties_keys = regsubst(keys($system_properties), '^(.*)$', "${name}~~~\\1")
+ jboss::internal::domain::servergroup::foreach { $system_properties_keys:
+ ensure => $ensure,
+ map => $system_properties,
+ group => $name,
+ profile => $profile,
+ controller => $controller,
+ }
+
+ if $ensure == 'present' {
+ JBoss::Clientry["jboss::domain::servergroup(${name})"] ->
+ JBoss::Clientry["jboss::domain::servergroup::jvm(${name})"]
+ } else {
+ JBoss::Clientry["jboss::domain::servergroup::jvm(${name})"] ->
+ JBoss::Clientry["jboss::domain::servergroup(${name})"]
+ }
+}
+
+
diff --git a/manifests/download.pp b/manifests/download.pp
deleted file mode 100644
index 458e8e3..0000000
--- a/manifests/download.pp
+++ /dev/null
@@ -1,17 +0,0 @@
-class jboss::download {
-
- package { "wget":
- ensure => "installed"
- }
-
-notify {"DOWNLOAD:WGET":}
- define download ($uri, $timeout = 300) {
- exec { "download $name":
- command => "wget -q '$uri' -O $name",
- path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
- creates => $name,
- timeout => $timeout,
- require => Package[ "wget" ],
- }
- }
-}
diff --git a/manifests/init.pp b/manifests/init.pp
index 98d9a56..25e79d5 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,149 +1,124 @@
-class jboss inherits jboss::params {
- include jboss::download
- $download_dir = '/opt/download'
- $download_file = "jboss-$version.zip"
- $jboss_parent_dir = '/usr/local/lib'
- $jboss_dir = "jboss-$version"
- $jboss_download_site = "http://public.prs.jakby.co/Virtualki"
- $jboss_path = "$jboss_parent_dir/$jboss_dir"
-
- user { $jboss::params::jboss_user:
- ensure => "present",
- managehome => true
- }
-
- group { $jboss::params::jboss_group:
- ensure => "present",
- require => User[$jboss::params::jboss_user],
- members => User[$jboss::params::jboss_user],
- }
-
- file { $jboss_path:
- group => $jboss::params::jboss_group,
- owner => $jboss::params::jboss_user,
- mode => 2775
- }
-
- file { jboss-as:
- path => "/etc/jboss-as",
- ensure => directory,
- group => $jboss::params::jboss_group,
- owner => $jboss::params::jboss_user,
- mode => 2775
- }
-
-
-
- file { $jboss_parent_dir:
- ensure => 'directory',
- }
-
- Exec {
- path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
- }
-
- file { $download_dir:
- ensure => 'directory',
- }
-
- jboss::download::download { "$download_dir/$zip_name":
- uri => "$jboss_download_site/$zip_name",
- require => [File[$jboss_path], File[$jboss_parent_dir], File[$download_dir],]
- }
-
- package { unzip:
- ensure => "installed"
- }
-
- package { "java-1.6.0-openjdk-devel.x86_64":
- ensure => "installed"
+# == Class: jboss
+#
+# The `jboss` main class is used to install the application server itself. It can install it on default parameters but you can use
+# then to customize installation procedure.
+#
+# === Standard metaparameters
+#
+# [*runasdomain*]
+# This parameter is used to configure JBoss server to run in domain or standalone mode. By default is equal to `false`, so
+# JBoss runs in standalone mode. Set it to `true` to setup domain mode.
+# [*profile*]
+# JBoss profile to use. By default it is equal to `full`, which is the default profile in JBoss server. You can use any other
+# default profile to start with: `full`, `ha`, `full-ha`.
+# [*controller*]
+# To with controller connect to. By default it is equals to `127.0.0.1:9999` on jboss servers and `127.0.0.1:9990` on wildfly
+# server.
+#
+# === Parameters
+#
+# [*hostname*]
+# It is used to name jboss main `host.xml` key to distinguish from other hosts in distributed environment. By default is
+# equals to `$::hostname` fact. Applicable Hiera key: `jboss::params::hostname`
+# [*product*]
+# Name of the JBoss product. Can be one of: `jboss-eap`, `jboss-as` or `wildfly`. By default this is equals to `wildfly`.
+# Applicable Hiera key: `jboss::params::product`
+# [*jboss_user*]
+# The name of the user to be used as owner of JBoss files in filesystem. It will be also used to run JBoss processes. Be default
+# it is equal to `jboss` for `jboss-eap` and `jboss-as` server and `wildfly` for `wildfly` server. Applicable Hiera key:
+# `jboss::params::jboss_user`
+# [*jboss_group*]
+# The filesystem group to be used as a owner of JBoss files. By default it is equal to the same value as `$jboss::jboss_user`.
+# [*download_url*]
+# The download URL from which JBoss zip file will be downloaded. Be default it is equal to
+# `http://download.jboss.org///-.zip`
+# [*java_autoinstall*]
+# This parameter is by default equal to `true` and if so it will install default Java JDK using `puppetlabs/java`. Applicable
+# Hiera key: `jboss::params::java_autoinstall`
+# [*java_version*]
+# This parameter is by default equals to `latest` and it is passed to `puppetlabs/java` module. You can give other values. For
+# details look in Puppetlabs/Java module dodumentation. Applicable Hiera key: `jboss::params::java_version`
+# [*java_package*]
+# The name of Java JDK package to use. Be default it is used to `undef` and it is passed to `puppetlabs/java`. Possible values
+# are: `jdk`, `jre`. For details look in Puppetlabs/Java module dodumentation. Applicable Hiera key:
+# `jboss::params::java_package`
+# [*install_dir*]
+# The directory to use as installation home for JBoss Application Server. By default it is equal to
+# `/usr/lib/-`. Applicable Hiera key: `jboss::params::install_dir`
+# [*controller_host*]
+# To with controller connect to. By default it is equals to `127.0.0.1`.
+# [*enableconsole*]
+# This parameter is used to enable or disable access to JBoss management web console. It is equal to `false` by default, so the
+# console is turned off. Applicable Hiera key: `jboss::params::enableconsole`
+# [*prerequisites*]
+# The class to use as a JBoss prerequisites which will be processed before installation. By default is equal to
+# `Class['jboss::internal::prerequisites']`. The default class is used to install `wget` package. If you would like to install
+# `wget` in diffrent way, please write your class that does that and pass reference to it as this parameter
+# [*fetch_tool*]
+# This parameter is by default equal to `jboss::internal::util::download`. This is a default implementation for fetching files
+# (mostly JBoss zip files) with `wget`. If you would like to use your own implementation, please write your custom define with
+# the same interface as `jboss::internal::util::download` and pass it's name to this parameter. Applicable Hiera key:
+# `jboss::params::fetch_tool`
+#
+# === Copyright
+#
+# Copyright (R) 2015 COI
+#
+class jboss (
+ $hostname = $jboss::params::hostname,
+ $product = $jboss::params::product,
+ $jboss_user = $jboss::params::jboss_user,
+ $jboss_group = $jboss::params::jboss_group,
+ $version = $jboss::params::version,
+ $download_url = "${jboss::params::download_urlbase}/${product}/${version}/${product}-${version}.zip",
+ $java_autoinstall = $jboss::params::java_autoinstall,
+ $java_version = $jboss::params::java_version,
+ $java_package = $jboss::params::java_package,
+ $install_dir = $jboss::params::install_dir,
+ $runasdomain = $jboss::params::runasdomain,
+ $controller_host = $jboss::params::controller_host,
+ $enableconsole = $jboss::params::enableconsole,
+ $profile = $jboss::params::profile,
+ $prerequisites = Class['jboss::internal::prerequisites'],
+ $fetch_tool = $jboss::params::fetch_tool,
+) inherits jboss::params {
+
+ $home = "${install_dir}/${product}-${version}"
+
+ include jboss::internal::compatibility
+
+ $controller = "${controller_host}:${jboss::internal::compatibility::controller_port}"
+
+ include jboss::internal::configuration
+ include jboss::internal::service
+
+ $servicename = $jboss::internal::service::servicename
+
+ class { 'jboss::internal::package':
+ version => $version,
+ product => $product,
+ jboss_user => $jboss_user,
+ jboss_group => $jboss_group,
+ download_url => $download_url,
+ java_autoinstall => $java_autoinstall,
+ java_version => $java_version,
+ java_package => $java_package,
+ install_dir => $install_dir,
+ prerequisites => $prerequisites,
+ require => Anchor['jboss::begin'],
+ }
+ include jboss::internal::package
+
+ anchor { 'jboss::begin': }
+
+ anchor { 'jboss::end':
+ require => [
+ Class['jboss::internal::package'],
+ Class['jboss::internal::configuration'],
+ Class['jboss::internal::service'],
+ Anchor['jboss::begin'],
+ Anchor['jboss::package::end'],
+ Anchor['jboss::service::end'],
+ ],
}
-
- file { "$download_dir/$jboss_dir":
- }
-
- file { "$download_dir/$download_file":
- }
-
- exec { 'unzip-downloaded':
- command => "unzip $zip_name",
- cwd => $download_dir,
- creates => $jboss_path,
- require => [File["$download_dir/$download_file"], Package[unzip]]
- }
-
- define setgroupaccess ($user, $group, $dir, $glpath) {
- exec { "rwX $name":
- command => "chmod -R g+rwX $dir",
- creates => $glpath,
- }
-
- exec { "find $name":
- command => "find $dir -type d -exec chmod g+s {} +",
- creates => $glpath,
- }
-
- exec { "group $name":
- command => "chown -R $user:$group $dir",
- creates => $glpath,
- }
- }
-
- setgroupaccess { 'set-perm':
- user => $jboss::params::jboss_user,
- group => $jboss::params::jboss_group,
- require => Group[$jboss::params::jboss_group],
- dir => "$download_dir/$jboss_dir",
- glpath => $jboss_path,
- }
-
- exec { 'move-downloaded':
- command => "mv $download_dir/$jboss_dir $jboss_path",
- cwd => $download_dir,
- creates => $jboss_path,
- }
-
- exec { 'jboss-service-link':
- command => "ln -s $jboss_path/bin/init.d/jboss-as-domain.sh /etc/init.d/jboss",
- unless => "test -f /etc/init.d/jboss",
- }
-
- # file { servicefile:
- # path => "/etc/init.d/jboss",
- # mode => 755,
- # #content => template('jboss/jboss2.erb'),
- # content => template('jboss/jboss-init.erb'),
- # notify => Service["jboss"]
- # }
-
- file { jboss-as-conf:
- path => "/etc/jboss-as/jboss-as.conf",
- mode => 755,
- content => template('jboss/jboss-as.conf.erb'),
- notify => Service["jboss"]
- }
-
- file { jbosscli:
- content => template('jboss/jboss-cli.erb'),
- mode => 755,
- path => '/usr/bin/jboss-cli',
- notify => Service["jboss"]
- }
-
- service { "jboss":
- ensure => running,
- enable => true,
- hasstatus => true,
- hasrestart => true,
- # require => [File[$jboss_path], File[servicefile],
- # #Class[java7],
- # ]
- }
-
- Jboss::Download::Download["$download_dir/$zip_name"] -> Exec['unzip-downloaded'] -> Setgroupaccess['set-perm'] -> Exec[
- 'move-downloaded'] -> Exec['jboss-service-link'] -> File[jboss-as] -> File[jboss-as-conf] -> File[jbosscli]
-
- # File[servicefile] -> Service['jboss']
- File[jboss-as-conf] -> Service['jboss']
}
-
diff --git a/manifests/interface.pp b/manifests/interface.pp
new file mode 100644
index 0000000..8d2bf6d
--- /dev/null
+++ b/manifests/interface.pp
@@ -0,0 +1,102 @@
+define jboss::interface (
+ $interface_name = $name,
+ $controller = $::jboss::controller,
+ $runasdomain = $::jboss::runasdomain,
+ $profile = $::jboss::profile,
+ $ensure = 'present',
+ $any_address = undef, # bool
+ $any_ipv4_address = undef, # bool
+ $any_ipv6_address = undef, # bool
+ $inet_address = undef, # string
+ $link_local_address = undef, # bool
+ $loopback = undef, # string
+ $loopback_address = undef, # bool
+ $multicast = undef, # bool
+ $nic = undef, # string
+ $nic_match = undef, # string
+ $point_to_point = undef, # bool
+ $public_address = undef, # bool
+ $site_local_address = undef, # bool
+ $subnet_match = undef, # string
+ $up = undef, # bool
+ $virtual = undef, # bool
+ ) {
+ include jboss
+ include jboss::internal::augeas
+ include jboss::internal::runtime
+
+ $bind_variables = {
+ 'any-address' => $any_address, # undef, bool
+ 'any-ipv4-address' => $any_ipv4_address, # undef, bool
+ 'any-ipv6-address' => $any_ipv6_address, # undef, bool
+ 'inet-address' => $inet_address, # '${jboss.bind.address:127.0.0.1}', string
+ 'link-local-address' => $link_local_address,# undef, bool
+ 'loopback' => $loopback, # undef, string
+ 'loopback-address' => $loopback_address, # undef, bool
+ 'multicast' => $multicast, # undef, bool
+ 'nic' => $nic, # undef, string
+ 'nic-match' => $nic_match, # undef, string
+ 'point-to-point' => $point_to_point, # undef, bool
+ 'public-address' => $public_address, # undef, bool
+ 'site-local-address' => $site_local_address,# undef, bool
+ 'subnet-match' => $subnet_match, # undef, string
+ 'up' => $up, # undef, bool
+ 'virtual' => $virtual, # undef, bool
+ }
+
+ if jboss_to_bool($::jboss_running) {
+ Jboss::Clientry {
+ ensure => $ensure,
+ controller => $controller,
+ runasdomain => $runasdomain,
+ profile => $profile,
+ }
+ $entrypath = $runasdomain ? {
+ true => "/host=${jboss::hostname}/interface=${interface_name}",
+ default => "/interface=${interface_name}",
+ }
+ jboss::clientry { $entrypath:
+ properties => $bind_variables,
+ }
+ } else {
+ $supported_bind_types = keys($bind_variables)
+ $prefixed_bind_types = prefix($supported_bind_types, "${interface_name}:")
+
+ if $runasdomain {
+ $cfg_file = $jboss::internal::runtime::hostconfigpath
+ $path = 'host/interfaces'
+ } else {
+ $cfg_file = $jboss::internal::runtime::standaloneconfigpath
+ $path = 'server/interfaces'
+ }
+
+ validate_absolute_path($cfg_file)
+
+ $augeas_defaults = merge($jboss::internal::augeas::defaults, {
+ context => "/files${cfg_file}/",
+ incl => $cfg_file,
+ })
+
+ if ($ensure == 'present') {
+ $augeas_params = merge($augeas_defaults, {
+ changes => "set ${path}/interface[last()+1]/#attribute/name ${interface_name}",
+ onlyif => "match ${path}/interface[#attribute/name='${interface_name}'] size == 0",
+ })
+ create_resources('augeas', { "ensure present interface ${interface_name}" => $augeas_params })
+ # For compatibility with puppet 2.x - foreach
+ jboss::internal::interface::foreach { $prefixed_bind_types:
+ cfg_file => $cfg_file,
+ path => $path,
+ interface_name => $interface_name,
+ bind_variables => $bind_variables,
+ augeas_defaults => $augeas_defaults,
+ }
+ } else {
+ $augeas_params = merge($augeas_defaults, {
+ changes => "rm ${path}/interface[#attribute/name='${interface_name}']",
+ onlyif => "match ${path}/interface[#attribute/name='${interface_name}'] size != 0",
+ })
+ ensure_resource('augeas', "ensure absent interface ${interface_name}", $augeas_params)
+ }
+ }
+}
diff --git a/manifests/internal/augeas.pp b/manifests/internal/augeas.pp
new file mode 100644
index 0000000..91e9f36
--- /dev/null
+++ b/manifests/internal/augeas.pp
@@ -0,0 +1,31 @@
+# Internal class - defaults for augeas provider
+class jboss::internal::augeas {
+ include jboss
+ if versioncmp($::augeasversion, '1.0.0') < 0 {
+ # Include additional only for old augeas version
+ include jboss::internal::lenses
+ $defaults = {
+ require => [
+ Anchor['jboss::configuration::begin'],
+ File["${jboss::internal::lenses::lenses_path}/jbxml.aug"],
+ ],
+ notify => [
+ Anchor['jboss::configuration::end'],
+ Service[$jboss::product],
+ ],
+ load_path => $jboss::internal::lenses::lenses_path,
+ lens => 'jbxml.lns',
+ }
+ } else {
+ $defaults = {
+ lens => 'xml.lns',
+ require => [
+ Anchor['jboss::configuration::begin'],
+ ],
+ notify => [
+ Anchor['jboss::configuration::end'],
+ Service[$jboss::product],
+ ],
+ }
+ }
+}
\ No newline at end of file
diff --git a/manifests/internal/compatibility.pp b/manifests/internal/compatibility.pp
new file mode 100644
index 0000000..586174f
--- /dev/null
+++ b/manifests/internal/compatibility.pp
@@ -0,0 +1,44 @@
+# Internal class - handles compatibility between
+class jboss::internal::compatibility {
+ include jboss
+
+ case $jboss::product {
+ 'wildfly': {
+ if versioncmp($jboss::version, '8.0.0') < 0 or versioncmp($jboss::version, '9.0.0') >= 0 {
+ fail("Unsupported version ${jboss::product} ${jboss::version}. Supporting only: Wildfly 8.x series")
+ }
+ }
+ 'jboss-eap': {
+ if versioncmp($jboss::version, '6.0.0') < 0 or versioncmp($jboss::version, '7.0.0') >= 0 {
+ fail("Unsupported version ${jboss::product} ${jboss::version}. Supporting only: JBoss EAP 6.x series")
+ }
+ }
+ 'jboss-as': {
+ if versioncmp($jboss::version, '7.0.0') < 0 or versioncmp($jboss::version, '8.0.0') >= 0 {
+ fail("Unsupported version ${jboss::product} ${jboss::version}. Supporting only: JBoss AS 7.x series")
+ }
+ }
+ default: {
+ fail("Unsupported product ${jboss::product}. Supporting only: 'jboss-eap', 'jboss-as' and 'wildfly'")
+ }
+ }
+
+ case $jboss::product {
+ 'wildfly': {
+ $controller_port = '9990'
+ $__osfamily_down = downcase($::osfamily)
+ $initd_file = "${jboss::home}/bin/init.d/wildfly-init-${__osfamily_down}.sh"
+ $product_short = 'wildfly'
+ }
+ 'jboss-eap', 'jboss-as': {
+ $controller_port = '9999'
+ $product_short = 'jboss'
+ $initd_file = $jboss::runasdomain ? {
+ true => "${jboss::home}/bin/init.d/jboss-as-domain.sh",
+ default => "${jboss::home}/bin/init.d/jboss-as-standalone.sh",
+ }
+ }
+ default: {}
+ }
+
+}
diff --git a/manifests/internal/configuration.pp b/manifests/internal/configuration.pp
new file mode 100644
index 0000000..dbf2599
--- /dev/null
+++ b/manifests/internal/configuration.pp
@@ -0,0 +1,118 @@
+class jboss::internal::configuration {
+ include jboss
+ include jboss::params
+ include jboss::internal::params
+ include jboss::internal::runtime
+ include jboss::internal::augeas
+ include jboss::internal::configure::interfaces
+
+ include jboss::internal::quirks::etc_initd_functions
+
+ $home = $jboss::home
+ $user = $jboss::jboss_user
+ $enableconsole = $jboss::enableconsole
+ $runasdomain = $jboss::runasdomain
+ $controller = $jboss::controller
+ $profile = $jboss::profile
+ $configfile = $jboss::internal::runtime::configfile
+ $product = $jboss::product
+ $version = $jboss::version
+ $etcconfdir = "/etc/${jboss::product}"
+ $conffile = "${etcconfdir}/${jboss::product}.conf"
+ $logdir = "${jboss::internal::params::logbasedir}/${jboss::product}"
+ $logfile = "${logdir}/console.log"
+
+ anchor { 'jboss::configuration::begin':
+ require => Anchor['jboss::package::end'],
+ }
+
+ if $runasdomain {
+ include jboss::internal::service
+ $hostfile = "${jboss::home}/domain/configuration/host.xml"
+ $augeas = merge($jboss::internal::augeas::defaults, {
+ changes => "set host/#attribute/name ${jboss::hostname}",
+ context => "/files${hostfile}/",
+ incl => $hostfile,
+ })
+ create_resources('augeas', { "jboss::configure::set_hostname(${jboss::hostname})" => $augeas })
+ }
+
+ file { '/etc/profile.d/jboss.sh':
+ ensure => 'file',
+ mode => '0644',
+ content => "export JBOSS_CONF='${conffile}'",
+ before => Concat[$conffile],
+ }
+
+ file { $logdir:
+ ensure => 'directory',
+ alias => 'jboss::logdir',
+ mode => '2770',
+ owner => $user,
+ group => $jboss::jboss_group,
+ }
+
+ file { $logfile:
+ ensure => 'file',
+ alias => 'jboss::logfile',
+ owner => 'root',
+ group => $jboss::jboss_group,
+ mode => '0660',
+ }
+
+ if $jboss::product != 'jboss-as' {
+ file { '/etc/jboss-as':
+ ensure => 'directory',
+ owner => $user,
+ group => $jboss::jboss_group,
+ mode => '2770',
+ }
+ file { '/etc/jboss-as/jboss-as.conf':
+ ensure => 'link',
+ target => $conffile,
+ before => Anchor['jboss::configuration::end'],
+ }
+ }
+
+ $defaults_file = $::osfamily ? {
+ 'Debian' => "/etc/default/${jboss::product}",
+ 'RedHat' => "/etc/sysconfig/${jboss::product}.conf",
+ default => undef
+ }
+ if $defaults_file == undef {
+ fail("Unsupported OS Family: ${::osfamily}")
+ }
+
+ file { '/etc/default':
+ ensure => 'directory',
+ }
+
+ file { [$defaults_file, "/etc/default/${jboss::product}.conf"]:
+ ensure => 'link',
+ target => $conffile,
+ before => Anchor['jboss::configuration::end'],
+ }
+
+ concat { $conffile:
+ alias => 'jboss::jboss-as.conf',
+ mode => '0644',
+ notify => Service[$jboss::product],
+ require => [
+ Anchor['jboss::configuration::begin'],
+ File[$logdir],
+ ],
+ }
+
+ concat::fragment { 'jboss::jboss-as.conf::defaults':
+ target => $conffile,
+ order => '000',
+ content => template('jboss/jboss-as.conf.erb'),
+ }
+
+ anchor { 'jboss::configuration::end':
+ require => [
+ Anchor['jboss::configuration::begin'],
+ Concat['jboss::jboss-as.conf'],
+ ],
+ }
+}
diff --git a/manifests/internal/configure/interfaces.pp b/manifests/internal/configure/interfaces.pp
new file mode 100644
index 0000000..1f484b9
--- /dev/null
+++ b/manifests/internal/configure/interfaces.pp
@@ -0,0 +1,44 @@
+# Internal class - configure network interfaces
+class jboss::internal::configure::interfaces {
+ include jboss::params
+ include jboss
+ include jboss::internal::runtime::dc
+
+ $enableconsole = $jboss::enableconsole
+ $runasdomain = $jboss::runasdomain
+ $controller = $jboss::controller
+
+ $bind_public = $jboss::params::bind_public
+ $bind_mgmt = $jboss::params::bind_mgmt
+
+ Jboss::Interface {
+ ensure => 'present',
+ }
+
+ $__console_is_sensible = $jboss::internal::runtime::dc::runs_as_controller or $jboss::runasdomain == false
+ if $__console_is_sensible and ($enableconsole or $bind_mgmt != undef){
+ if $bind_mgmt != undef {
+ jboss::interface { 'management':
+ inet_address => $bind_mgmt,
+ any_address => undef,
+ }
+ } else {
+ jboss::interface { 'management':
+ any_address => true,
+ inet_address => undef,
+ }
+ }
+ }
+
+ if $bind_public != undef {
+ jboss::interface { 'public':
+ any_address => undef,
+ inet_address => $bind_public,
+ }
+ } else {
+ jboss::interface { 'public':
+ any_address => true,
+ inet_address => undef,
+ }
+ }
+}
diff --git a/manifests/internal/domain/servergroup/foreach.pp b/manifests/internal/domain/servergroup/foreach.pp
new file mode 100644
index 0000000..73e3669
--- /dev/null
+++ b/manifests/internal/domain/servergroup/foreach.pp
@@ -0,0 +1,35 @@
+# Internal define - foreach for servergroup
+define jboss::internal::domain::servergroup::foreach (
+ $group,
+ $profile,
+ $controller,
+ $ensure = 'present',
+ $key = $name,
+ $map = {},
+) {
+
+ #Remove group prefix from system property name
+ $split = split($key, '~~~')
+ $property = $split[1]
+
+ $value = $map[$property]
+
+ jboss::clientry { "jboss::domain::servergroup::sysproperty(${key} => ${value})":
+ ensure => $ensure,
+ path => "/server-group=${group}/system-property=${property}",
+ profile => $profile,
+ controller => $controller,
+ runasdomain => true,
+ properties => {
+ value => $value,
+ }
+ }
+
+ if $ensure == 'present' {
+ JBoss::Clientry["jboss::domain::servergroup(${group})"] ->
+ JBoss::Clientry["jboss::domain::servergroup::sysproperty(${key} => ${value})"]
+ } else {
+ JBoss::Clientry["jboss::domain::servergroup::sysproperty(${key} => ${value})"] ->
+ JBoss::Clientry["jboss::domain::servergroup(${group})"]
+ }
+}
diff --git a/manifests/internal/interface/foreach.pp b/manifests/internal/interface/foreach.pp
new file mode 100644
index 0000000..25b46fb
--- /dev/null
+++ b/manifests/internal/interface/foreach.pp
@@ -0,0 +1,35 @@
+# Helper for creating interface children
+define jboss::internal::interface::foreach (
+ $cfg_file,
+ $path,
+ $interface_name,
+ $bind_variables,
+ $augeas_defaults,
+ $ensure = 'present',
+) {
+ require jboss::internal::lenses
+
+ validate_hash($augeas_defaults)
+
+ Augeas {
+ require => Augeas["ensure present interface ${interface_name}"],
+ }
+
+ $interface_bind_pair = split($name, ':')
+ $bind_type = $interface_bind_pair[1]
+ $bind_value = $bind_variables[$bind_type]
+
+ if ($bind_value == undef or $ensure != 'present') {
+ $augeas_params = merge($augeas_defaults, {
+ changes => "rm ${path}/interface[#attribute/name='${interface_name}']/${bind_type}",
+ onlyif => "match ${path}/interface[#attribute/name='${interface_name}']/${bind_type} size != 0",
+ })
+ ensure_resource('augeas', "interface ${interface_name} rm ${bind_type}", $augeas_params)
+ } else {
+ $augeas_params = merge($augeas_defaults, {
+ changes => "set ${path}/interface[#attribute/name='${interface_name}']/${bind_type}/#attribute/value '${bind_value}'",
+ onlyif => "get ${path}/interface[#attribute/name='${interface_name}']/${bind_type}/#attribute/value != '${bind_value}'",
+ })
+ ensure_resource('augeas', "interface ${interface_name} set ${bind_type}", $augeas_params)
+ }
+}
diff --git a/manifests/internal/lenses.pp b/manifests/internal/lenses.pp
new file mode 100644
index 0000000..6c596a9
--- /dev/null
+++ b/manifests/internal/lenses.pp
@@ -0,0 +1,20 @@
+# Installs lenses file for JBoss .xml files
+class jboss::internal::lenses {
+ include jboss
+
+ $lenses_path = "${::jboss::home}/lenses"
+
+ file { $lenses_path:
+ ensure => 'directory',
+ owner => $::jboss::jboss_user,
+ require => Anchor['jboss::configuration::begin'],
+ }
+
+ file { "${lenses_path}/jbxml.aug":
+ ensure => 'file',
+ source => 'puppet:///modules/jboss/jbxml.aug',
+ owner => $::jboss::jboss_user,
+ require => File[$lenses_path],
+ before => Anchor['jboss::configuration::end'],
+ }
+}
diff --git a/manifests/internal/module/assemble.pp b/manifests/internal/module/assemble.pp
new file mode 100644
index 0000000..6334676
--- /dev/null
+++ b/manifests/internal/module/assemble.pp
@@ -0,0 +1,56 @@
+# Internal define - Assemble JBoss module from files
+define jboss::internal::module::assemble (
+ $layer,
+ $modulename = $name,
+ $artifacts = [],
+ $dependencies = [],
+) {
+ include jboss
+
+ $replaced = regsubst($modulename, '\.', '/', 'G')
+ $dir = "modules/system/layers/${layer}/${replaced}/main"
+
+ File {
+ mode => '0640',
+ owner => $jboss::jboss_user,
+ group => $jboss::jboss_group,
+ }
+
+ exec { "jboss::module::assemble::${name}(dir=${dir})":
+ command => "/bin/mkdir -p ${jboss::home}/${dir}",
+ unless => "test -d ${jboss::home}/${dir}",
+ path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+ notify => Service[$jboss::product],
+ require => Anchor['jboss::package::end'],
+ }
+
+ file { "jboss::module::assemble::${name}(dir=${dir})":
+ ensure => 'directory',
+ mode => '2750',
+ path => "${jboss::home}/${dir}",
+ notify => Service[$jboss::product],
+ require => [
+ Anchor['jboss::package::end'],
+ Exec["jboss::module::assemble::${name}(dir=${dir})"]
+ ],
+ }
+
+ file { "jboss::module::assemble::${name}(module.xml)":
+ ensure => 'file',
+ path => "${jboss::home}/${dir}/module.xml",
+ content => template('jboss/module/module.xml.erb'),
+ notify => Service[$jboss::product],
+ require => Anchor['jboss::package::end'],
+ }
+
+ jboss::internal::module::assemble::process_artifacts { $artifacts:
+ dir => $dir,
+ notify => Service[$jboss::product],
+ require => Anchor['jboss::package::end'],
+ }
+
+ jboss::internal::module::registerlayer { "jboss::module::assemble::${name}(${layer})":
+ layer => $layer,
+ }
+
+}
diff --git a/manifests/internal/module/assemble/process_artifacts.pp b/manifests/internal/module/assemble/process_artifacts.pp
new file mode 100644
index 0000000..4289856
--- /dev/null
+++ b/manifests/internal/module/assemble/process_artifacts.pp
@@ -0,0 +1,25 @@
+# Internal define - processing artifacts
+define jboss::internal::module::assemble::process_artifacts (
+ $dir,
+ $uri = $name,
+) {
+ include jboss
+ $base = jboss_basename($uri)
+ $target_dir = "${jboss::home}/${dir}"
+ if $uri =~ /^(?:http|https|ftp|sftp|ftps):/ {
+ jboss::internal::util::fetch::file { $base:
+ address => $uri,
+ fetch_dir => $target_dir,
+ notify => Service[$jboss::product],
+ require => Anchor['jboss::package::end'],
+ }
+ } else {
+ file { "${target_dir}/${base}":
+ source => $uri,
+ mode => '0640',
+ owner => $jboss::jboss_user,
+ group => $jboss::jboss_group,
+ notify => Service[$jboss::product],
+ }
+ }
+}
diff --git a/manifests/internal/module/registerlayer.pp b/manifests/internal/module/registerlayer.pp
new file mode 100644
index 0000000..5c4ef45
--- /dev/null
+++ b/manifests/internal/module/registerlayer.pp
@@ -0,0 +1,27 @@
+# Internal define - register module layer
+define jboss::internal::module::registerlayer (
+ $layer = name,
+) {
+ include jboss
+
+ File {
+ mode => '0640',
+ owner => $jboss::jboss_user,
+ group => $jboss::jboss_group,
+ }
+
+ if (!defined(Exec["jboss::module::layer::${layer}"])) {
+ exec { "jboss::module::layer::${layer}":
+ command => "/bin/awk -F'=' 'BEGIN {ins = 0} /^layers=/ { ins = ins + 1; print \$1=${layer},\$2 } END {if(ins == 0) print \"layers=${layer},base\"}' > ${jboss::home}/modules/layers.conf",
+ unless => "/bin/egrep -e '^layers=.*${layer}.*' ${jboss::home}/modules/layers.conf",
+ require => Anchor['jboss::installed'],
+ notify => Service[$jboss::product],
+ }
+ file { "${jboss::home}/modules/system/layers/${layer}":
+ ensure => 'directory',
+ alias => "jboss::module::layer::${layer}",
+ require => Anchor['jboss::installed'],
+ notify => Service[$jboss::product],
+ }
+ }
+}
diff --git a/manifests/internal/package.pp b/manifests/internal/package.pp
new file mode 100644
index 0000000..fb624d4
--- /dev/null
+++ b/manifests/internal/package.pp
@@ -0,0 +1,186 @@
+# Internal class that installs JBoss
+class jboss::internal::package (
+ $download_url,
+ $prerequisites,
+ $jboss_user,
+ $jboss_group,
+ $product = $jboss::params::product,
+ $version = $jboss::params::version,
+ $java_autoinstall = $jboss::params::java_autoinstall,
+ $java_version = $jboss::params::java_version,
+ $java_package = $jboss::params::java_package,
+ $install_dir = $jboss::params::install_dir,
+ # Prerequisites class, that can be overwritten
+) inherits jboss::params {
+ include jboss
+ include jboss::internal::runtime
+ include jboss::internal::compatibility
+
+ $download_rootdir = $jboss::internal::params::download_rootdir
+ $download_file = jboss_basename($download_url)
+ $download_dir = "${download_rootdir}/download-${product}-${version}"
+ $home = $jboss::home
+ $configfile = $jboss::internal::runtime::configfile
+ $standaloneconfigfile = $jboss::internal::runtime::standaloneconfigfile
+
+ case $version {
+ /^[0-9]+\.[0-9]+\.[0-9]+[\._-][0-9a-zA-Z_-]+$/: {
+ debug("Running in version: ${1} -> ${version}")
+ }
+ default: {
+ fail("Invalid Jboss version passed: `${version}`! Pass valid version for ex.: `6.2.0.GA`")
+ }
+ }
+
+ anchor { 'jboss::package::begin':
+ require => Anchor['jboss::begin'],
+ }
+
+ File {
+ owner => $jboss_user,
+ group => $jboss_group,
+ mode => '2750',
+ }
+
+ Exec {
+ path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+ logoutput => 'on_failure',
+ }
+
+ if (!defined(Group[$jboss_group])) {
+ group { $jboss_group: ensure => 'present', }
+ }
+
+ if (!defined(User[$jboss_user])) {
+ $empty = ''
+ create_resources('user', {
+ "${jboss_user}${empty}" => {
+ ensure => 'present',
+ managehome => true,
+ gid => $jboss_group,
+ }
+ })
+ }
+
+ $confdir = "/etc/${product}"
+
+ file { $confdir:
+ ensure => 'directory',
+ alias => 'jboss::confdir',
+ owner => 'root',
+ group => 'root',
+ mode => '0755',
+ }
+
+ if $java_autoinstall {
+ class { 'java':
+ distribution => 'jdk',
+ version => $java_version,
+ package => $java_package,
+ notify => Service[$jboss::product],
+ }
+ Class['java'] -> Exec['jboss::package::check-for-java']
+ }
+
+ file { $download_dir:
+ ensure => 'directory',
+ }
+
+ jboss::internal::util::fetch::file { $download_file:
+ address => $download_url,
+ fetch_dir => $download_dir,
+ require => File[$download_dir],
+ }
+
+ if $prerequisites == Class['jboss::internal::prerequisites'] {
+ include jboss::internal::prerequisites
+ }
+
+ exec { 'jboss::unzip-downloaded':
+ command => "unzip -o -q ${download_dir}/${download_file} -d ${jboss::home}",
+ cwd => $download_dir,
+ creates => $jboss::home,
+ require => [
+ $prerequisites, # Prerequisites class, that can be overwritten
+ Jboss::Internal::Util::Fetch::File[$download_file],
+ Package['unzip'],
+ ],
+ }
+
+ exec { 'jboss::move-unzipped':
+ command => "mv ${jboss::home}/*/* ${jboss::home}/",
+ creates => "${jboss::home}/bin",
+ require => Exec['jboss::unzip-downloaded'],
+ }
+
+ exec { 'jboss::test-extraction':
+ command => "echo '${jboss::home}/bin/init.d not found!' 1>&2 && exit 1",
+ unless => "test -d ${jboss::home}/bin/init.d",
+ require => Exec['jboss::move-unzipped'],
+ }
+
+ jboss::internal::util::groupaccess { $jboss::home:
+ user => $jboss_user,
+ group => $jboss_group,
+ require => [
+ User[$jboss_user],
+ Exec['jboss::test-extraction'],
+ ],
+ }
+
+ file { "${confdir}/domain.xml":
+ ensure => 'link',
+ alias => 'jboss::configuration-link::domain',
+ target => "${jboss::home}/domain/configuration/domain.xml",
+ require => Jboss::Internal::Util::Groupaccess[$jboss::home],
+ }
+ $hostfile = 'host.xml'
+ file { "${confdir}/${hostfile}":
+ ensure => 'link',
+ alias => 'jboss::configuration-link::host',
+ target => "${jboss::home}/domain/configuration/${hostfile}",
+ require => Jboss::Internal::Util::Groupaccess[$jboss::home],
+ }
+
+ file { "${confdir}/standalone.xml":
+ ensure => 'link',
+ alias => 'jboss::configuration-link::standalone',
+ target => "${jboss::home}/standalone/configuration/${standaloneconfigfile}",
+ require => Jboss::Internal::Util::Groupaccess[$jboss::home],
+ }
+
+ file { "/etc/init.d/${product}":
+ ensure => 'link',
+ alias => 'jboss::service-link',
+ target => $jboss::internal::compatibility::initd_file,
+ require => Jboss::Internal::Util::Groupaccess[$jboss::home],
+ }
+
+ file { "/usr/bin/${jboss::internal::compatibility::product_short}-cli":
+ ensure => 'file',
+ alias => 'jboss::jbosscli',
+ content => template('jboss/jboss-cli.erb'),
+ mode => '0755',
+ require => Jboss::Internal::Util::Groupaccess[$jboss::home],
+ }
+
+ exec { 'jboss::package::check-for-java':
+ command => 'echo "Please provide Java executable to system!" 1>&2 && exit 1',
+ unless => '[ `which java` ] && java -version 2>&1 | grep -q \'java version\'',
+ require => Anchor['jboss::installed'],
+ before => Anchor['jboss::package::end'],
+ }
+
+ anchor { 'jboss::installed':
+ require => [
+ Jboss::Internal::Util::Groupaccess[$jboss::home],
+ Exec['jboss::test-extraction'],
+ File['jboss::confdir'],
+ File['jboss::logfile'],
+ File['jboss::jbosscli'],
+ File['jboss::service-link'],
+ ],
+ before => Anchor['jboss::package::end'],
+ }
+ anchor { 'jboss::package::end': }
+}
diff --git a/manifests/internal/params.pp b/manifests/internal/params.pp
new file mode 100644
index 0000000..b28610c
--- /dev/null
+++ b/manifests/internal/params.pp
@@ -0,0 +1,11 @@
+class jboss::internal::params {
+
+ # Directory to download installation temporary files
+ $download_rootdir = hiera('jboss::internal::params::download_rootdir', '/usr/src')
+
+ # Directory for logging
+ $logbasedir = hiera('jboss::internal::params::logbasedir', '/var/log')
+
+ include jboss::internal::params::socketbinding
+ include jboss::internal::params::memorydefaults
+}
diff --git a/manifests/internal/params/memorydefaults.pp b/manifests/internal/params/memorydefaults.pp
new file mode 100644
index 0000000..851ef49
--- /dev/null
+++ b/manifests/internal/params/memorydefaults.pp
@@ -0,0 +1,11 @@
+# Internal class - JBoss memory defaults
+class jboss::internal::params::memorydefaults {
+ # Perm Gen memory initial
+ $permgensize = hiera('jboss::internal::params::memorydefaults::permgensize', '32m')
+ # Perm Gen memory maximum
+ $maxpermgensize = hiera('jboss::internal::params::memorydefaults::maxpermgensize', '256m')
+ # Heap memory initial
+ $heapsize = hiera('jboss::internal::params::memorydefaults::heapsize', '256m')
+ # Heap memory maximum
+ $maxheapsize = hiera('jboss::internal::params::memorydefaults::maxheapsize', '1303m')
+}
diff --git a/manifests/internal/params/socketbinding.pp b/manifests/internal/params/socketbinding.pp
new file mode 100644
index 0000000..1c47d0c
--- /dev/null
+++ b/manifests/internal/params/socketbinding.pp
@@ -0,0 +1,8 @@
+# Internal class - socketbinging params
+class jboss::internal::params::socketbinding {
+ # Default sockets to be used, if not passed to `jboss::domain::server` or `jboss::domain::servergroup`
+ $group = hiera('jboss::internal::params::socketbinding::group', 'full-sockets')
+
+ # Default offset for server ports to be used, if not passed to `jboss::domain::server` or `jboss::domain::servergroup`
+ $port_offset = jboss_to_i(hiera('jboss::internal::params::socketbinding::port_offset', 0))
+}
diff --git a/manifests/internal/prerequisites.pp b/manifests/internal/prerequisites.pp
new file mode 100644
index 0000000..af36e82
--- /dev/null
+++ b/manifests/internal/prerequisites.pp
@@ -0,0 +1,13 @@
+# == Class: prerequisites
+#
+# Ensure any required dependencies for jboss installaction are present.
+#
+# Parameters:
+#
+# None
+#
+class jboss::internal::prerequisites {
+ if ! defined(Package['unzip']) {
+ ensure_packages(['unzip'])
+ }
+}
diff --git a/manifests/internal/quirks/etc_initd_functions.pp b/manifests/internal/quirks/etc_initd_functions.pp
new file mode 100644
index 0000000..2c1c551
--- /dev/null
+++ b/manifests/internal/quirks/etc_initd_functions.pp
@@ -0,0 +1,25 @@
+# Internal class - Quircks for /etc/init.d/functions loading from RHEL even on Debian like systems
+class jboss::internal::quirks::etc_initd_functions {
+ include jboss
+ include jboss::internal::service
+ include jboss::internal::compatibility
+
+ if $jboss::product != 'wildfly' and $::osfamily == 'Debian' {
+ file { '/sbin/consoletype':
+ content => join(['#!/bin/sh', 'echo pty'], "\n"),
+ mode => '0755',
+ }
+ file { '/etc/init.d/functions':
+ ensure => 'file',
+ source => 'puppet:///modules/jboss/rhel-initd-functions.sh',
+ require => File['/sbin/consoletype'],
+ notify => Service[$jboss::internal::service::servicename],
+ }
+ exec { "sed -i '1s/.*/#!\\/bin\\/bash/' ${jboss::internal::compatibility::initd_file}":
+ onlyif => "test \"$(head -n 1 ${jboss::internal::compatibility::initd_file})\" = '#!/bin/sh'",
+ require => Anchor['jboss::package::end'],
+ notify => Service[$jboss::internal::service::servicename],
+ path => $::path,
+ }
+ }
+}
diff --git a/manifests/internal/runtime.pp b/manifests/internal/runtime.pp
new file mode 100644
index 0000000..bdfa433
--- /dev/null
+++ b/manifests/internal/runtime.pp
@@ -0,0 +1,32 @@
+# JBoss internals - class that calculates and hold variables calculated at runtime
+class jboss::internal::runtime {
+ include jboss
+
+ $runasdomain = $jboss::runasdomain
+ $profile = $jboss::profile
+
+ $domainconfigfile = 'domain.xml'
+ $hostconfigfile = 'host.xml'
+
+ $standaloneconfigfile = $profile ? {
+ '' => 'standalone.xml',
+ 'ha' => 'standalone-ha.xml',
+ 'osgi' => 'standalone-osgi.xml',
+ 'full' => 'standalone-full.xml',
+ 'full-ha' => 'standalone-full-ha.xml',
+ default => 'standalone-full.xml'
+ }
+
+ $configfile = $runasdomain ? {
+ true => $domainconfigfile,
+ default => $standaloneconfigfile,
+ }
+
+ validate_absolute_path($jboss::home)
+
+ $standaloneconfigpath = "${jboss::home}/standalone/configuration/${standaloneconfigfile}"
+ $hostconfigpath = "${jboss::home}/domain/configuration/${hostconfigfile}"
+ $domainconfigpath = "${jboss::home}/domain/configuration/${domainconfigfile}"
+
+ include jboss::internal::runtime::dc
+}
diff --git a/manifests/internal/runtime/dc.pp b/manifests/internal/runtime/dc.pp
new file mode 100644
index 0000000..d645dfd
--- /dev/null
+++ b/manifests/internal/runtime/dc.pp
@@ -0,0 +1,4 @@
+class jboss::internal::runtime::dc (
+ $runs_as_controller = false,
+) {
+}
\ No newline at end of file
diff --git a/manifests/internal/runtime/node.pp b/manifests/internal/runtime/node.pp
new file mode 100644
index 0000000..48f490d
--- /dev/null
+++ b/manifests/internal/runtime/node.pp
@@ -0,0 +1,6 @@
+class jboss::internal::runtime::node (
+ $username = undef,
+ $password = undef,
+) {
+
+}
\ No newline at end of file
diff --git a/manifests/internal/service.pp b/manifests/internal/service.pp
new file mode 100644
index 0000000..98dc938
--- /dev/null
+++ b/manifests/internal/service.pp
@@ -0,0 +1,56 @@
+# Internal class - manage JBoss service
+class jboss::internal::service {
+
+ include jboss
+ include jboss::params
+ include jboss::internal::configuration
+
+ Exec {
+ path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+ logoutput => 'on_failure',
+ }
+
+ anchor { 'jboss::service::begin': }
+
+ $servicename = $jboss::product
+
+ service { $servicename:
+ ensure => running,
+ enable => true,
+ hasstatus => true,
+ hasrestart => true,
+ subscribe => [
+ Anchor['jboss::package::end'],
+ Anchor['jboss::service::begin'],
+ ],
+ }
+
+ exec { 'jboss::service::test-running':
+ loglevel => 'emerg',
+ command => "tail -n 50 ${jboss::internal::configuration::logfile} && exit 1",
+ unless => "ps aux | grep ${servicename} | grep -vq grep",
+ logoutput => true,
+ subscribe => Service[$servicename],
+ }
+
+ exec { 'jboss::service::restart':
+ command => "service ${servicename} stop ; pkill -9 -f \"^java.*jboss\" ; service ${servicename} start",
+ refreshonly => true,
+ require => Exec['jboss::service::test-running'],
+ }
+
+ anchor { 'jboss::service::end':
+ require => [
+ Service[$servicename],
+ Exec['jboss::service::test-running'],
+ ],
+ }
+
+ anchor { 'jboss::service::started':
+ require => [
+ Service[$servicename],
+ Anchor['jboss::service::end'],
+ Exec['jboss::service::restart'],
+ ],
+ }
+}
diff --git a/manifests/internal/util/download.pp b/manifests/internal/util/download.pp
new file mode 100644
index 0000000..d579255
--- /dev/null
+++ b/manifests/internal/util/download.pp
@@ -0,0 +1,66 @@
+# Internal define. Default download method.
+define jboss::internal::util::download (
+ $fetch_dir,
+ $mode,
+ $owner,
+ $group,
+ $uri = $name,
+ $timeout = 900,
+ $filename = undef,
+ $install_wget = true,
+) {
+
+ if $filename == undef {
+ $base = jboss_basename($uri)
+ $dest = "${fetch_dir}/${base}"
+ } else {
+ $dest = "${fetch_dir}/${filename}"
+ }
+
+ validate_string($dest)
+ validate_re($dest, '^.+$')
+
+ case $uri {
+ /^(?:http|https|ftp|sftp|ftps):/ : {
+ if ! defined(Package['wget']) and $install_wget {
+ ensure_packages(['wget'])
+ }
+
+ if ! defined(Group[$group]) {
+ ensure_resource('group', $group, {
+ ensure => 'present',
+ })
+ }
+
+ if ! defined(User[$owner]) {
+ ensure_resource('user', $owner, {
+ ensure => 'present',
+ gid => $group,
+ })
+ }
+
+ exec { "wget -q '${uri}' -O '${dest}' && chmod ${mode} '${dest}' && chown ${owner}:${group} '${dest}'":
+ alias => "download ${name}",
+ logoutput => 'on_failure',
+ path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+ creates => $dest,
+ timeout => $timeout,
+ require => [
+ Package['wget'],
+ Group[$group],
+ User[$owner],
+ ],
+ }
+ }
+ default : {
+ file { $dest:
+ alias => "download ${name}",
+ mode => $mode,
+ owner => $owner,
+ group => $group,
+ source => $uri,
+ }
+ }
+ }
+
+}
diff --git a/manifests/internal/util/fetch/file.pp b/manifests/internal/util/fetch/file.pp
new file mode 100644
index 0000000..09112e3
--- /dev/null
+++ b/manifests/internal/util/fetch/file.pp
@@ -0,0 +1,58 @@
+# Fetches a file from external resource
+define jboss::internal::util::fetch::file (
+ $address,
+ $fetch_dir,
+ $mode = '0640',
+ $owner = undef,
+ $group = undef,
+ $fetch_tool = undef,
+ $filename = $name,
+ $attributes = {},
+) {
+
+ if defined(Class['jboss']) {
+ include jboss
+ $actualOwner = $owner ? {
+ undef => $jboss::jboss_user,
+ default => $owner
+ }
+ $actualGroup = $group ? {
+ undef => $jboss::jboss_group,
+ default => $group
+ }
+ $actual_fetch_tool = $fetch_tool ? {
+ undef => $jboss::fetch_tool,
+ default => $fetch_tool,
+ }
+ } else {
+ include jboss::params
+ $actualOwner = $owner ? {
+ undef => $jboss::params::jboss_user,
+ default => $owner
+ }
+ $actualGroup = $group ? {
+ undef => $jboss::params::jboss_group,
+ default => $group
+ }
+ $actual_fetch_tool = $fetch_tool ? {
+ undef => $jboss::params::fetch_tool,
+ default => $fetch_tool,
+ }
+ }
+
+ validate_string($address)
+
+ $all_attrs = merge($attributes, {
+ 'filename' => $filename,
+ 'fetch_dir' => $fetch_dir,
+ 'mode' => $mode,
+ 'owner' => $actualOwner,
+ 'group' => $actualGroup,
+ })
+
+ $emptyhack = ''
+
+ create_resources($actual_fetch_tool, {
+ "${address}${emptyhack}" => $all_attrs
+ })
+}
diff --git a/manifests/internal/util/groupaccess.pp b/manifests/internal/util/groupaccess.pp
new file mode 100644
index 0000000..c309a4c
--- /dev/null
+++ b/manifests/internal/util/groupaccess.pp
@@ -0,0 +1,22 @@
+# Internal define - Sets group access recursively
+define jboss::internal::util::groupaccess (
+ $group,
+ $user,
+ $target = $name,
+) {
+
+ exec { "g+s ${name}":
+ command => "find ${target} -type d -exec chmod g+s,a+x {} +",
+ unless => "/usr/bin/test -g ${target} -a -x ${target}",
+ }
+
+ exec { "rw ${name}":
+ command => "chmod -R g+rw ${target}",
+ unless => "/usr/bin/test $(stat -c %A ${target} | cut -c 5-6) = rw",
+ }
+
+ exec { "group ${name}":
+ command => "chown -R ${user}:${group} ${target}",
+ unless => "/usr/bin/test $(stat -c '%U:%G' ${target}) = '${user}:${group}'",
+ }
+}
diff --git a/manifests/jmsqueue.pp b/manifests/jmsqueue.pp
new file mode 100644
index 0000000..7419600
--- /dev/null
+++ b/manifests/jmsqueue.pp
@@ -0,0 +1,46 @@
+# == Define: jboss::jmsqueue
+#
+# Use this defined type to add and remove JBoss JMS Queues.
+#
+# === Parameters
+#
+# This type uses *JBoss module standard metaparameters*
+#
+# [*entries*]
+# A list of JNDI entries for JBoss JMS Queue. You can specify any number of entries from which your queue will be visible
+# inside your application.
+# [*ensure*]
+# Standard ensure parameter. Can be either `present` or `absent`.
+# [*durable*]
+# This parameter indicate that given JMS queue should be durable or not. By default this is equal to `false`.
+#
+define jboss::jmsqueue (
+ $entries,
+ $ensure = 'present',
+ $durable = jboss_to_bool(hiera('jboss::jmsqueue::durable', false)),
+ $profile = $::jboss::profile,
+ $controller = $::jboss::controller,
+ $runasdomain = $::jboss::runasdomain,
+) {
+ include jboss
+ include jboss::internal::service
+ include jboss::internal::runtime::node
+
+ jboss_jmsqueue { $name:
+ ensure => $ensure,
+ durable => $durable,
+ entries => $entries,
+ runasdomain => $runasdomain,
+ profile => $profile,
+ controller => $controller,
+ ctrluser => $jboss::internal::runtime::node::username,
+ ctrlpasswd => $jboss::internal::runtime::node::password,
+ require => Anchor['jboss::package::end'],
+ }
+
+ if jboss_to_bool($::jboss_running) {
+ Jboss_jmsqueue[$name] ~> Service[$jboss::internal::service::servicename]
+ } else {
+ Anchor['jboss::service::end'] -> Jboss_jmsqueue[$name] ~> Exec['jboss::service::restart']
+ }
+}
diff --git a/manifests/logging/async.pp b/manifests/logging/async.pp
new file mode 100644
index 0000000..f8f9a3a
--- /dev/null
+++ b/manifests/logging/async.pp
@@ -0,0 +1,22 @@
+define jboss::logging::async (
+ $logger_name = $name,
+ $ensure = 'present',
+ $level = 'INFO',
+ $formatter = '%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n',
+ $handlers = [ 'CONSOLE', 'FILE' ],
+ $overflow_action = 'BLOCK',
+ $queue_length = 1024,
+) {
+
+ jboss::clientry { "/subsystem=logging/async-handler=${logger_name}":
+ ensure => $ensure,
+ dorestart => false,
+ properties => {
+ 'level' => $level,
+ 'formatter' => $formatter,
+ 'subhandlers' => $handlers,
+ 'overflow-action' => $overflow_action,
+ 'queue-length' => $queue_length,
+ },
+ }
+}
diff --git a/manifests/logging/console.pp b/manifests/logging/console.pp
new file mode 100644
index 0000000..acc58a9
--- /dev/null
+++ b/manifests/logging/console.pp
@@ -0,0 +1,19 @@
+# Console logging for JBoss
+define jboss::logging::console (
+ $logger_name = $name,
+ $ensure = 'present',
+ $level = 'INFO',
+ $formatter = '%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n',
+ $target = 'System.out',
+) {
+
+ jboss::clientry { "/subsystem=logging/console-handler=${logger_name}":
+ ensure => $ensure,
+ dorestart => false,
+ properties => {
+ 'level' => $level,
+ 'target' => $target,
+ 'formatter' => $formatter,
+ },
+ }
+}
diff --git a/manifests/logging/file.pp b/manifests/logging/file.pp
new file mode 100644
index 0000000..7ba75d1
--- /dev/null
+++ b/manifests/logging/file.pp
@@ -0,0 +1,27 @@
+# Logging to file for JBoss
+define jboss::logging::file (
+ $logger_name = $name,
+ $ensure = 'present',
+ $level = 'INFO',
+ $formatter = '%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n',
+ $suffix = '.yyyy-MM-dd',
+ $relative_to = 'jboss.server.log.dir',
+ $file_path = 'server.log',
+) {
+
+ $file = {
+ 'relative-to' => $relative_to,
+ 'path' => $file_path,
+ }
+
+ jboss::clientry { "/subsystem=logging/periodic-rotating-file-handler=${logger_name}":
+ ensure => $ensure,
+ dorestart => false,
+ properties => {
+ 'level' => $level,
+ 'formatter' => $formatter,
+ 'suffix' => $suffix,
+ 'file' => $file,
+ },
+ }
+}
diff --git a/manifests/logging/logger.pp b/manifests/logging/logger.pp
new file mode 100644
index 0000000..d0945d5
--- /dev/null
+++ b/manifests/logging/logger.pp
@@ -0,0 +1,17 @@
+# Default logger configuration for JBoss
+define jboss::logging::logger (
+ $logger_name = $name,
+ $ensure = 'present',
+ $level = 'INFO',
+ $use_parent_handlers = true,
+) {
+
+ jboss::clientry { "/subsystem=logging/logger=${logger_name}":
+ ensure => $ensure,
+ dorestart => false,
+ properties => {
+ 'level' => $level,
+ 'use-parent-handlers' => $use_parent_handlers,
+ },
+ }
+}
diff --git a/manifests/logging/root.pp b/manifests/logging/root.pp
new file mode 100644
index 0000000..9fd4fef
--- /dev/null
+++ b/manifests/logging/root.pp
@@ -0,0 +1,17 @@
+# Root logger for JBoss
+define jboss::logging::root (
+ $logger_name = $name,
+ $ensure = 'present',
+ $level = 'INFO',
+ $handlers = [ 'CONSOLE', 'FILE' ],
+) {
+
+ jboss::clientry { "/subsystem=logging/root-logger=${logger_name}":
+ ensure => $ensure,
+ dorestart => false,
+ properties => {
+ 'level' => $level,
+ 'handlers' => $handlers,
+ },
+ }
+}
diff --git a/manifests/logging/syslog.pp b/manifests/logging/syslog.pp
new file mode 100644
index 0000000..592c01e
--- /dev/null
+++ b/manifests/logging/syslog.pp
@@ -0,0 +1,24 @@
+# A JBoss syslog definition
+define jboss::logging::syslog (
+ $logger_name = $name,
+ $ensure = 'present',
+ $level = 'INFO',
+ $app_name = 'java-app',
+ $port = 514,
+ $serverhost = '127.0.0.1',
+ $clienthostname = undef,
+ $format = 'RFC5424',
+) {
+
+ jboss::clientry { "/subsystem=logging/syslog-handler=${logger_name}":
+ ensure => $ensure,
+ dorestart => false,
+ properties => {
+ 'level' => $level,
+ 'app-name' => $app_name,
+ 'port' => $port,
+ 'server-address' => $serverhost,
+ 'syslog-format' => $format,
+ },
+ }
+}
diff --git a/manifests/module.pp b/manifests/module.pp
new file mode 100644
index 0000000..065554e
--- /dev/null
+++ b/manifests/module.pp
@@ -0,0 +1,16 @@
+# Creates JBoss module
+define jboss::module (
+ $layer,
+ $modulename = $name,
+ $artifacts = [],
+ $dependencies = [],
+) {
+ include jboss
+
+ jboss::internal::module::assemble { $name:
+ layer => $layer,
+ modulename => $modulename,
+ artifacts => $artifacts,
+ dependencies => $dependencies,
+ }
+}
diff --git a/manifests/params.pp b/manifests/params.pp
index 2c87dfe..7dabb73 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -1,9 +1,55 @@
+# JBoss parameters
+class jboss::params inherits jboss::internal::params {
+ # JBoss product name
+ $product = hiera('jboss::params::product', 'wildfly')
+
+ # Version of JBoss Application Server
+ $version = hiera('jboss::params::version', '8.2.0.Final')
+
+ # Should java be installed by this module automatically?
+ $java_autoinstall = jboss_to_bool(hiera('jboss::params::java_install', true))
+
+ # The version of Java to be installed, default: latest
+ $java_version = hiera('jboss::params::java_version', 'latest')
+
+ # Java package version, undef, jdk, jre
+ $java_package = hiera('jboss::params::java_package', undef)
+
+ # User for Jboss Application Server
+ $jboss_user = hiera('jboss::params::jboss_user', 'jboss')
+
+ # Group for Jboss Application Server
+ $jboss_group = hiera('jboss::params::jboss_group', 'jboss')
+
+ # Download URL for Jboss Application Server installation package
+ $download_urlbase = hiera('jboss::params::download_urlbase', 'http://download.jboss.org')
+
+ # Target installation directory root
+ $install_dir = hiera('jboss::params::install_dir', '/usr/lib')
+
+ # Runs JBoss Application Server in domain mode
+ $runasdomain = jboss_to_bool(hiera('jboss::params::runasdomain', false))
+
+ # Enable JBoss Application Server management console
+ $enableconsole = jboss_to_bool(hiera('jboss::params::enableconsole', false))
+
+ # JBoss default domain profile
+ $profile = hiera('jboss::settings::profile', 'full')
+
+ # JBoss default domain controller's hostname
+ $controller_host = hiera('jboss::settings::controller', '127.0.0.1')
+
+ # JBoss bind public interface to:
+ $bind_public = hiera('jboss::params::bind_public', undef)
+
+ # JBoss bind management interface to:
+ $bind_mgmt = hiera('jboss::params::bind_mgmt', undef)
+
+ # JBoss default host name
+ $hostname = hiera('jboss::params::hostname', $::hostname)
+
+ # Tool used by this module to fetch JBoss installation files from network
+ $fetch_tool = hiera('jboss::params::fetch_tool', 'jboss::internal::util::download')
-class jboss::params {
- $jboss_user = "jboss"
- $jboss_group = "jboss"
- $zip_name = "jboss-eap-6.1.0.zip"
- $version = "eap-6.1"
- $java_home = "/etc/alternatives/java_sdk"
}
diff --git a/manifests/resourceadapter.pp b/manifests/resourceadapter.pp
new file mode 100644
index 0000000..89e6370
--- /dev/null
+++ b/manifests/resourceadapter.pp
@@ -0,0 +1,39 @@
+# Creates JBoss resource adapter
+define jboss::resourceadapter (
+ $jndiname,
+ $archive,
+ $transactionsupport,
+ $classname,
+ $ensure = 'present',
+ $security = hiera('jboss::resourceadapter::security', 'application'),
+ $backgroundvalidation = jboss_to_bool(hiera('jboss::resourceadapter::backgroundvalidation', false)),
+ $profile = $::jboss::profile,
+ $controller = $::jboss::controller,
+ $runasdomain = $::jboss::runasdomain,
+) {
+ include jboss
+ include jboss::internal::service
+ include jboss::internal::runtime::node
+
+ jboss_resourceadapter { $name:
+ ensure => $ensure,
+ archive => $archive,
+ transactionsupport => $transactionsupport,
+ backgroundvalidation => $backgroundvalidation,
+ security => $security,
+ classname => $classname,
+ jndiname => $jndiname,
+ controller => $controller,
+ ctrluser => $jboss::internal::runtime::node::username,
+ ctrlpasswd => $jboss::internal::runtime::node::password,
+ profile => $profile,
+ runasdomain => $runasdomain,
+ require => Anchor['jboss::package::end'],
+ }
+
+ if jboss_to_bool($::jboss_running) {
+ Jboss_resourceadapter[$name] ~> Service[$jboss::internal::service::servicename]
+ } else {
+ Anchor['jboss::service::end'] -> Jboss_resourceadapter[$name] ~> Exec['jboss::service::restart']
+ }
+}
diff --git a/manifests/securitydomain.pp b/manifests/securitydomain.pp
new file mode 100644
index 0000000..9fc11a5
--- /dev/null
+++ b/manifests/securitydomain.pp
@@ -0,0 +1,33 @@
+# Creates JBoss security domain
+define jboss::securitydomain (
+ $code = undef,
+ $codeflag = undef,
+ $moduleoptions = undef,
+ $ensure = 'present',
+ $profile = $::jboss::profile,
+ $controller = $::jboss::controller,
+ $runasdomain = $::jboss::runasdomain,
+) {
+ include jboss
+ include jboss::internal::service
+ include jboss::internal::runtime::node
+
+ jboss_securitydomain { $name:
+ ensure => $ensure,
+ code => $code,
+ codeflag => $codeflag,
+ moduleoptions => $moduleoptions,
+ runasdomain => $runasdomain,
+ profile => $profile,
+ controller => $controller,
+ ctrluser => $jboss::internal::runtime::node::username,
+ ctrlpasswd => $jboss::internal::runtime::node::password,
+ require => Anchor['jboss::package::end'],
+ }
+
+ if jboss_to_bool($::jboss_running) {
+ Jboss_securitydomain[$name] ~> Service[$jboss::internal::service::servicename]
+ } else {
+ Anchor['jboss::service::end'] -> Jboss_securitydomain[$name] ~> Exec['jboss::service::restart']
+ }
+}
diff --git a/manifests/user.pp b/manifests/user.pp
new file mode 100644
index 0000000..9fbeae8
--- /dev/null
+++ b/manifests/user.pp
@@ -0,0 +1,111 @@
+# == Define: jboss::user
+#
+# This define to add and remove JBoss management and application users, manage their passwords and roles.
+#
+# === Parameters:
+#
+# [*password*]
+# **Required parameter.** This is password that will be used for user.
+# [*ensure*]
+# Standard ensure parameter. Can be either `present` or `absent`.
+# [*user*]
+# (namevar) Name of user to manage.
+# [*realm*]
+# This is by default equal to `ManagementRealm`. It can be equal also to `ApplicationRealm`.
+# [*roles*]
+# This is by default equal to `undef`. You can pass a list of roles in form of string delimited by `,` sign.
+#
+define jboss::user (
+ $password,
+ $ensure = 'present',
+ $user = $name,
+ $realm = 'ManagementRealm',
+ $roles = undef,
+) {
+
+ include jboss
+ require jboss::internal::package
+ include jboss::internal::service
+
+ $home = $jboss::home
+
+ $dir = $jboss::runasdomain ? {
+ true => 'domain',
+ default => 'standalone',
+ }
+
+ # application realm or normal
+ $application_realm = $realm ? {
+ 'ApplicationRealm' => true,
+ default => false,
+ }
+
+ # -a is needed to set in application-users.properties file
+ if ($application_realm) {
+ $extraarg = '-a'
+ }
+
+ $file = $application_realm ? {
+ true => 'application-users.properties',
+ default => 'mgmt-users.properties',
+ }
+
+ $filepath = "${home}/${dir}/configuration/${file}"
+ $filepath_roles = "${home}/${dir}/configuration/application-roles.properties"
+ $jbossuserfix = '2>&1 | awk \'BEGIN{a=0}{if (/Error/){a=1};print}END{if (a==1) exit 1}\''
+
+ case $ensure {
+ 'present': {
+ $rolesstr = $roles ? {
+ undef => '',
+ default => "--roles '${roles}'"
+ }
+ # By default the properties realm expects the entries to be in the format: -
+ # username=HEX( MD5( username ':' realm ':' password))
+ $mangledpasswd = md5("${name}:${realm}:${password}")
+ exec { "jboss::user::add(${realm}/${name})":
+ environment => [
+ "JBOSS_HOME=${home}",
+ "__PASSWD=${password}"
+ ],
+ command => "${home}/bin/add-user.sh --silent --user '${name}' --password \"\$__PASSWD\" --realm '${realm}' ${rolesstr} ${extraarg} ${jbossuserfix}",
+ unless => "/bin/egrep -e '^${name}=${mangledpasswd}' ${filepath}",
+ require => Anchor['jboss::package::end'],
+ notify => Service[$jboss::internal::service::servicename],
+ logoutput => true,
+ }
+ if $application_realm {
+ file_line { "jboss::user::roles::add(${realm}/${name})":
+ ensure => present,
+ path => $filepath_roles,
+ line => "${name}=${roles}",
+ match => "${name}=.*",
+ require => Exec["jboss::user::add(${realm}/${name})"],
+ notify => Service[$jboss::internal::service::servicename],
+ }
+ }
+ }
+ 'absent':{
+ exec { "jboss::user::remove(${realm}/${name})":
+ command => "/bin/sed -iE 's/^${name}=.*$//g' ${filepath}",
+ onlyif => "/bin/egrep -e '^${name}=' ${filepath}",
+ require => Anchor['jboss::package::end'],
+ logoutput => 'on_failure',
+ notify => Service[$jboss::internal::service::servicename],
+ }
+ if $application_realm {
+ exec { "jboss::user::roles::remove(${realm}/${name})":
+ command => "/bin/sed -iE 's/^${name}=.*$//g' ${filepath_roles}",
+ onlyif => "/bin/egrep -e '^${name}=' ${filepath_roles}",
+ require => Anchor['jboss::package::end'],
+ logoutput => 'on_failure',
+ notify => Service[$jboss::internal::service::servicename],
+ }
+ }
+ }
+ default: {
+ fail("Ensure must be eiter present or absent, provided: `${ensure}`!")
+ }
+ }
+
+}
diff --git a/metadata.json b/metadata.json
index 026d9d2..74b8309 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,27 +1,28 @@
{
- "name": "coi-jboss",
- "author": "pawel",
- "description": "",
- "license": "",
- "project_page": "",
- "source": "",
- "summary": "",
- "version": "0.0.1",
- "checksums": {
- ".project": "1975a07954009f86e8638d7284d84d45",
- "Modulefile": "9d01941af48e5b38981dbac05d9188ca",
- "README.markdown": "626dde043a850bfbf376a7c748ae01ae",
- "Rakefile": "f37e6131fe7de9a49b09d31596f5fbf1",
- "manifests/download.pp": "31b858c66f6045d26c614ec1ff71acd2",
- "manifests/init.pp": "d7911f8c9f97c460b99c4a70b7e7492d",
- "manifests/params.pp": "24a8ac5fdb42328cee665ce93ec09072",
- "spec/spec.opts": "a600ded995d948e393fbe2320ba8e51c",
- "spec/spec_helper.rb": "3ea886dd135e120afa31e0aab12e85b0",
- "templates/jboss-as.conf.erb": "97b8f0c607eab29de0c0b93e40b64ff8",
- "templates/jboss-cli.erb": "0848e84d8d2283de6d5011ca96fa673f",
- "templates/jboss-init.erb": "7d7ed0a2f4e77c130cf9feda1b868184",
- "templates/jboss2.erb": "642dfdcb8d7b9dfd30d618d7c13a6400",
- "tests/init.pp": "c2e8f20b178d74245743774a82012fd8"
- },
- "dependencies": []
-}
\ No newline at end of file
+ "name": "coi/jboss",
+ "version": "1.0.0",
+ "author": "Center of Information Technology COI.gov.pl",
+ "summary": "Installs and manages resources of JBoss EAP and Wildfly application servers",
+ "license": "Apache-2.0",
+ "source": "git://github.com/coi-gov-pl/puppet-jboss.git",
+ "project_page": "https://github.com/coi-gov-pl/puppet-jboss",
+ "issues_url": "https://github.com/coi-gov-pl/puppet-jboss/issues",
+ "dependencies": [
+ { "name": "puppetlabs/java", "version_requirement": ">= 1.0.1" },
+ { "name": "puppetlabs/stdlib", "version_requirement": ">= 3.2.0" },
+ { "name": "puppetlabs/concat", "version_requirement": ">= 1.0.0" }
+ ],
+ "operatingsystem_support": [
+ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6" ] },
+ { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6" ] },
+ { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6" ] },
+ { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6" ] },
+ { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] },
+ { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] }
+ ],
+ "requirements": [
+ { "name": "pe", "version_requirement": ">=2.8.0 <4.0.0" },
+ { "name": "puppet", "version_requirement": ">=2.7.0 <4.0.0" }
+ ]
+}
+
diff --git a/spec/acceptance/001_init_spec.rb b/spec/acceptance/001_init_spec.rb
new file mode 100644
index 0000000..cd606e9
--- /dev/null
+++ b/spec/acceptance/001_init_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper_acceptance'
+
+describe 'jboss class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
+ describe 'executing with defaults' do
+
+ pp = <<-eos
+ class { 'jboss': }
+ eos
+
+ it 'should work without errors' do
+ apply_manifest(pp, :catch_failures => true)
+ end
+ it 'should not make any changes when executed twice' do
+ apply_manifest(pp, :expect_changes => false)
+ end
+ describe service('wildfly') do
+ it { should be_running }
+ end
+
+ end
+end
\ No newline at end of file
diff --git a/spec/acceptance/nodesets/centos-5-x86_64-docker.yml b/spec/acceptance/nodesets/centos-5-x86_64-docker.yml
new file mode 100644
index 0000000..f31fc23
--- /dev/null
+++ b/spec/acceptance/nodesets/centos-5-x86_64-docker.yml
@@ -0,0 +1,12 @@
+HOSTS:
+ centos-5-x64:
+ platform: el-5-x86_64
+ hypervisor : docker
+ image: centos:5
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'yum install -y crontabs tar wget'
+CONFIG:
+ type: foss
+ log_level: debug
diff --git a/spec/acceptance/nodesets/centos-6-x86_64-docker.yml b/spec/acceptance/nodesets/centos-6-x86_64-docker.yml
new file mode 100644
index 0000000..6fbea74
--- /dev/null
+++ b/spec/acceptance/nodesets/centos-6-x86_64-docker.yml
@@ -0,0 +1,12 @@
+HOSTS:
+ centos-6-x64:
+ platform: el-6-x86_64
+ hypervisor : docker
+ image: centos:6
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'yum install -y crontabs tar wget'
+CONFIG:
+ type: foss
+ log_level: debug
diff --git a/spec/acceptance/nodesets/centos-6-x86_64-openstack.yml b/spec/acceptance/nodesets/centos-6-x86_64-openstack.yml
new file mode 100644
index 0000000..2ce40e2
--- /dev/null
+++ b/spec/acceptance/nodesets/centos-6-x86_64-openstack.yml
@@ -0,0 +1,11 @@
+HOSTS:
+ centos-6-x64:
+ platform: el-6-x86_64
+ hypervisor : openstack
+ flavor: m1.small
+ image: centos-6-latest
+ user: root
+CONFIG:
+ type: foss
+ log_level: debug
+ openstack_network: default
diff --git a/spec/acceptance/nodesets/centos-6-x86_64-pe288-docker.yml b/spec/acceptance/nodesets/centos-6-x86_64-pe288-docker.yml
new file mode 100644
index 0000000..36d256d
--- /dev/null
+++ b/spec/acceptance/nodesets/centos-6-x86_64-pe288-docker.yml
@@ -0,0 +1,21 @@
+HOSTS:
+ centos-6-x64-pe288:
+ roles:
+ - master
+ - agent
+ - database
+ - dashboard
+ platform: el-6-x86_64
+ image: centos:centos6
+ hypervisor: docker
+ docker_preserve_image: true
+ docker_image_commands:
+ - 'yum install -y tar vim'
+CONFIG:
+ type: pe
+ pe_ver: 2.8.8
+ pe_dir: https://s3.amazonaws.com/pe-builds/released/2.8.8
+ log_level: verbose
+ssh:
+ password: root
+ auth_methods: ["password"]
\ No newline at end of file
diff --git a/spec/acceptance/nodesets/centos-6-x86_64-pe382-docker.yml b/spec/acceptance/nodesets/centos-6-x86_64-pe382-docker.yml
new file mode 100644
index 0000000..2866714
--- /dev/null
+++ b/spec/acceptance/nodesets/centos-6-x86_64-pe382-docker.yml
@@ -0,0 +1,21 @@
+HOSTS:
+ centos-6-x64-pe382:
+ roles:
+ - master
+ - agent
+ - database
+ - dashboard
+ platform: el-6-x86_64
+ image: centos:centos6
+ hypervisor: docker
+ docker_preserve_image: true
+ docker_image_commands:
+ - 'yum install -y tar vim'
+CONFIG:
+ type: pe
+ pe_ver: 3.8.2
+ pe_dir: https://s3.amazonaws.com/pe-builds/released/3.8.2
+ log_level: verbose
+ssh:
+ password: root
+ auth_methods: ["password"]
\ No newline at end of file
diff --git a/spec/acceptance/nodesets/centos-6-x86_64-vagrant.yml b/spec/acceptance/nodesets/centos-6-x86_64-vagrant.yml
new file mode 100644
index 0000000..0574815
--- /dev/null
+++ b/spec/acceptance/nodesets/centos-6-x86_64-vagrant.yml
@@ -0,0 +1,8 @@
+HOSTS:
+ centos-6-x64:
+ platform: el-6-x86_64
+ hypervisor : vagrant
+ box : camptocamp/centos-6-x86_64
+CONFIG:
+ type: foss
+ log_level: debug
diff --git a/spec/acceptance/nodesets/centos-7-x86_64-docker.yml b/spec/acceptance/nodesets/centos-7-x86_64-docker.yml
new file mode 100644
index 0000000..5d5150b
--- /dev/null
+++ b/spec/acceptance/nodesets/centos-7-x86_64-docker.yml
@@ -0,0 +1,12 @@
+HOSTS:
+ centos-7-x64:
+ platform: el-7-x86_64
+ hypervisor : docker
+ image: centos:7
+ docker_preserve_image: true
+ docker_cmd: '["/usr/sbin/init"]'
+ docker_image_commands:
+ - 'yum install -y crontabs tar wget'
+CONFIG:
+ type: foss
+ log_level: debug
diff --git a/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml b/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml
new file mode 100644
index 0000000..b9bb99c
--- /dev/null
+++ b/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml
@@ -0,0 +1,11 @@
+HOSTS:
+ centos-7-x64:
+ platform: el-7-x86_64
+ hypervisor : openstack
+ flavor: m1.small
+ image: centos-7-latest
+ user: centos
+CONFIG:
+ type: foss
+ log_level: debug
+ openstack_network: default
diff --git a/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml b/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml
new file mode 100644
index 0000000..b7e6a04
--- /dev/null
+++ b/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml
@@ -0,0 +1,8 @@
+HOSTS:
+ centos-7-x64:
+ platform: el-7-x86_64
+ hypervisor : vagrant
+ box : camptocamp/centos-7-x86_64
+CONFIG:
+ type: foss
+ log_level: debug
diff --git a/spec/acceptance/nodesets/debian-6-x86_64-docker.yml b/spec/acceptance/nodesets/debian-6-x86_64-docker.yml
new file mode 100644
index 0000000..ac13e21
--- /dev/null
+++ b/spec/acceptance/nodesets/debian-6-x86_64-docker.yml
@@ -0,0 +1,12 @@
+HOSTS:
+ debian-6-x64:
+ platform: debian-6-amd64
+ hypervisor : docker
+ image: debian:6
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'apt-get install -y wget'
+CONFIG:
+ type: foss
+ log_level: debug
diff --git a/spec/acceptance/nodesets/debian-6-x86_64-openstack.yml b/spec/acceptance/nodesets/debian-6-x86_64-openstack.yml
new file mode 100644
index 0000000..423f4e7
--- /dev/null
+++ b/spec/acceptance/nodesets/debian-6-x86_64-openstack.yml
@@ -0,0 +1,11 @@
+HOSTS:
+ debian-6-x64:
+ platform: debian-6-amd64
+ hypervisor : openstack
+ flavor: m1.small
+ image: debian-6-latest
+ user: debian
+CONFIG:
+ type: foss
+ log_level: debug
+ openstack_network: default
diff --git a/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml
new file mode 100644
index 0000000..38a196b
--- /dev/null
+++ b/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml
@@ -0,0 +1,8 @@
+HOSTS:
+ debian-6-x64:
+ platform: debian-6-amd64
+ hypervisor : vagrant
+ box : puppetlabs/debian-6.0.10-64-nocm
+CONFIG:
+ type: foss
+ log_level: debug
diff --git a/spec/acceptance/nodesets/debian-7-x86_64-docker.yml b/spec/acceptance/nodesets/debian-7-x86_64-docker.yml
new file mode 100644
index 0000000..17fb3b3
--- /dev/null
+++ b/spec/acceptance/nodesets/debian-7-x86_64-docker.yml
@@ -0,0 +1,12 @@
+HOSTS:
+ debian-7-x64:
+ platform: debian-7-amd64
+ hypervisor : docker
+ image: debian:7
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'apt-get install -y cron wget'
+CONFIG:
+ type: foss
+ log_level: debug
diff --git a/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml b/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml
new file mode 100644
index 0000000..c16afa4
--- /dev/null
+++ b/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml
@@ -0,0 +1,11 @@
+HOSTS:
+ debian-7-x64:
+ platform: debian-7-amd64
+ hypervisor : openstack
+ flavor: m1.small
+ image: debian-7-latest
+ user: debian
+CONFIG:
+ type: foss
+ log_level: debug
+ openstack_network: default
diff --git a/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml
new file mode 100644
index 0000000..572c137
--- /dev/null
+++ b/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml
@@ -0,0 +1,8 @@
+HOSTS:
+ debian-7-x64:
+ platform: debian-7-amd64
+ hypervisor : vagrant
+ box : camptocamp/debian-7-amd64
+CONFIG:
+ type: foss
+ log_level: debug
diff --git a/spec/acceptance/nodesets/debian-8-x86_64-docker.yml b/spec/acceptance/nodesets/debian-8-x86_64-docker.yml
new file mode 100644
index 0000000..09ac1c2
--- /dev/null
+++ b/spec/acceptance/nodesets/debian-8-x86_64-docker.yml
@@ -0,0 +1,12 @@
+HOSTS:
+ debian-8-x64:
+ platform: debian-8-amd64
+ hypervisor : docker
+ image: debian:8
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'apt-get install -y cron wget'
+CONFIG:
+ type: foss
+ log_level: debug
diff --git a/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml b/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml
new file mode 100644
index 0000000..39c20a5
--- /dev/null
+++ b/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml
@@ -0,0 +1,11 @@
+HOSTS:
+ debian-8-x64:
+ platform: debian-8-amd64
+ hypervisor : openstack
+ flavor: m1.small
+ image: debian-8-latest
+ user: debian
+CONFIG:
+ type: foss
+ log_level: debug
+ openstack_network: default
diff --git a/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml
new file mode 100644
index 0000000..055150a
--- /dev/null
+++ b/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml
@@ -0,0 +1,8 @@
+HOSTS:
+ debian-8-x64:
+ platform: debian-8-amd64
+ hypervisor : vagrant
+ box : camptocamp/debian-8-amd64
+CONFIG:
+ type: foss
+ log_level: debug
diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml
new file mode 100644
index 0000000..6fbea74
--- /dev/null
+++ b/spec/acceptance/nodesets/default.yml
@@ -0,0 +1,12 @@
+HOSTS:
+ centos-6-x64:
+ platform: el-6-x86_64
+ hypervisor : docker
+ image: centos:6
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'yum install -y crontabs tar wget'
+CONFIG:
+ type: foss
+ log_level: debug
diff --git a/spec/acceptance/nodesets/ubuntu-10.04-x86_64-docker.yml b/spec/acceptance/nodesets/ubuntu-10.04-x86_64-docker.yml
new file mode 100644
index 0000000..94a51b1
--- /dev/null
+++ b/spec/acceptance/nodesets/ubuntu-10.04-x86_64-docker.yml
@@ -0,0 +1,10 @@
+HOSTS:
+ ubuntu-1004-x64:
+ platform: ubuntu-10.04-amd64
+ hypervisor : docker
+ image: ubuntu:10.04
+ # This stops the image from being deleted on completion, speeding up the process.
+ docker_preserve_image: true
+CONFIG:
+ type: foss
+ log_level: debug
diff --git a/spec/acceptance/nodesets/ubuntu-12.04-x86_64-docker.yml b/spec/acceptance/nodesets/ubuntu-12.04-x86_64-docker.yml
new file mode 100644
index 0000000..833106b
--- /dev/null
+++ b/spec/acceptance/nodesets/ubuntu-12.04-x86_64-docker.yml
@@ -0,0 +1,12 @@
+HOSTS:
+ ubuntu-1204-x64:
+ platform: ubuntu-12.04-amd64
+ hypervisor : docker
+ image: ubuntu:12.04
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'apt-get install -y wget'
+CONFIG:
+ type: foss
+ log_level: debug
diff --git a/spec/acceptance/nodesets/ubuntu-12.04-x86_64-openstack.yml b/spec/acceptance/nodesets/ubuntu-12.04-x86_64-openstack.yml
new file mode 100644
index 0000000..9db344e
--- /dev/null
+++ b/spec/acceptance/nodesets/ubuntu-12.04-x86_64-openstack.yml
@@ -0,0 +1,11 @@
+HOSTS:
+ ubuntu-1204-x64:
+ platform: ubuntu-12.04-amd64
+ hypervisor : openstack
+ flavor: m1.small
+ image: ubuntu-1204-latest
+ user: ubuntu
+CONFIG:
+ type: foss
+ log_level: debug
+ openstack_network: default
diff --git a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-docker.yml b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-docker.yml
new file mode 100644
index 0000000..7d7c04e
--- /dev/null
+++ b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-docker.yml
@@ -0,0 +1,12 @@
+HOSTS:
+ ubuntu-1404-x64:
+ platform: ubuntu-14.04-amd64
+ hypervisor : docker
+ image: ubuntu:14.04
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'apt-get install -y wget'
+CONFIG:
+ type: foss
+ log_level: debug
diff --git a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-openstack.yml b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-openstack.yml
new file mode 100644
index 0000000..28f8401
--- /dev/null
+++ b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-openstack.yml
@@ -0,0 +1,11 @@
+HOSTS:
+ ubuntu-1404-x64:
+ platform: ubuntu-14.04-amd64
+ hypervisor : openstack
+ flavor: m1.small
+ image: ubuntu-1404-latest
+ user: ubuntu
+CONFIG:
+ type: foss
+ log_level: debug
+ openstack_network: default
diff --git a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml
new file mode 100644
index 0000000..8584692
--- /dev/null
+++ b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml
@@ -0,0 +1,8 @@
+HOSTS:
+ ubuntu-1404-x64:
+ platform: ubuntu-14.04-amd64
+ hypervisor : vagrant
+ box : puppetlabs/ubuntu-14.04-64-nocm
+CONFIG:
+ type: foss
+ log_level: debug
diff --git a/spec/acceptance/nodesets/ubuntu-14.10-x86_64-docker.yml b/spec/acceptance/nodesets/ubuntu-14.10-x86_64-docker.yml
new file mode 100644
index 0000000..f3bbad1
--- /dev/null
+++ b/spec/acceptance/nodesets/ubuntu-14.10-x86_64-docker.yml
@@ -0,0 +1,12 @@
+HOSTS:
+ ubuntu-1410-x64:
+ platform: ubuntu-14.10-amd64
+ hypervisor : docker
+ image: ubuntu:14.10
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'apt-get install -y wget'
+CONFIG:
+ type: foss
+ log_level: debug
diff --git a/spec/acceptance/nodesets/ubuntu-14.10-x86_64-openstack.yml b/spec/acceptance/nodesets/ubuntu-14.10-x86_64-openstack.yml
new file mode 100644
index 0000000..6ae4e05
--- /dev/null
+++ b/spec/acceptance/nodesets/ubuntu-14.10-x86_64-openstack.yml
@@ -0,0 +1,11 @@
+HOSTS:
+ ubuntu-1410-x64:
+ platform: ubuntu-14.10-amd64
+ hypervisor : openstack
+ flavor: m1.small
+ image: ubuntu-1410-latest
+ user: ubuntu
+CONFIG:
+ type: foss
+ log_level: debug
+ openstack_network: default
diff --git a/spec/acceptance/nodesets/ubuntu-15.04-x86_64-docker.yml b/spec/acceptance/nodesets/ubuntu-15.04-x86_64-docker.yml
new file mode 100644
index 0000000..45f912a
--- /dev/null
+++ b/spec/acceptance/nodesets/ubuntu-15.04-x86_64-docker.yml
@@ -0,0 +1,12 @@
+HOSTS:
+ ubuntu-1504-x64:
+ platform: ubuntu-15.04-amd64
+ hypervisor : docker
+ image: ubuntu:15.04
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'apt-get install -y wget'
+CONFIG:
+ type: foss
+ log_level: debug
diff --git a/spec/acceptance/nodesets/ubuntu-15.04-x86_64-openstack.yml b/spec/acceptance/nodesets/ubuntu-15.04-x86_64-openstack.yml
new file mode 100644
index 0000000..894fedd
--- /dev/null
+++ b/spec/acceptance/nodesets/ubuntu-15.04-x86_64-openstack.yml
@@ -0,0 +1,11 @@
+HOSTS:
+ ubuntu-1504-x64:
+ platform: ubuntu-15.04-amd64
+ hypervisor : openstack
+ flavor: m1.small
+ image: ubuntu-1504-latest
+ user: ubuntu
+CONFIG:
+ type: foss
+ log_level: debug
+ openstack_network: default
diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb
new file mode 100644
index 0000000..36fc3db
--- /dev/null
+++ b/spec/classes/init_spec.rb
@@ -0,0 +1,49 @@
+require 'spec_helper_puppet'
+
+describe 'jboss', :type => :class do
+ let(:facts) do
+ {
+ :operatingsystem => 'OracleLinux',
+ :osfamily => 'RedHat',
+ :ipaddress => '192.168.0.1',
+ :concat_basedir => '/root/concat',
+ :puppetversion => Puppet.version
+ }
+ end
+ context 'with defaults for all parameters' do
+ it { is_expected.to compile }
+ it { is_expected.to contain_class 'jboss' }
+ it { is_expected.to contain_anchor 'jboss::begin' }
+ it { is_expected.to contain_anchor 'jboss::end' }
+ it { is_expected.to contain_anchor 'jboss::configuration::begin' }
+ it { is_expected.to contain_anchor 'jboss::configuration::end' }
+ it { is_expected.to contain_anchor 'jboss::installed' }
+ it { is_expected.to contain_anchor 'jboss::package::begin' }
+ it { is_expected.to contain_anchor 'jboss::package::end' }
+ it { is_expected.to contain_anchor 'jboss::service::begin' }
+ it { is_expected.to contain_anchor 'jboss::service::end' }
+ it { is_expected.to contain_anchor 'jboss::service::started' }
+ it { is_expected.to contain_user 'jboss' }
+ it { is_expected.to contain_group 'jboss' }
+ end
+ context 'with product => jboss-eap and version => 6.4.0.GA parameters set' do
+ let(:params) do
+ { :product => 'jboss-eap', :version => '6.4.0.GA' }
+ end
+
+ it { is_expected.to compile }
+ it { is_expected.to contain_class 'jboss' }
+ it { is_expected.to contain_user 'jboss' }
+ it { is_expected.to contain_group 'jboss' }
+ end
+ context 'with jboss_user => appserver parameter set' do
+ let(:params) do
+ { :jboss_user => 'appserver' }
+ end
+
+ it { is_expected.to compile }
+ it { is_expected.to contain_class 'jboss' }
+ it { is_expected.to contain_user 'appserver' }
+ it { is_expected.to contain_group 'jboss' }
+ end
+end
diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb
new file mode 100644
index 0000000..e17ec64
--- /dev/null
+++ b/spec/classes/params_spec.rb
@@ -0,0 +1,7 @@
+require 'spec_helper_puppet'
+
+describe 'jboss::params', :type => :class do
+
+ it { is_expected.to compile }
+
+end
\ No newline at end of file
diff --git a/spec/defines/datasource_spec.rb b/spec/defines/datasource_spec.rb
new file mode 100644
index 0000000..a0a8be5
--- /dev/null
+++ b/spec/defines/datasource_spec.rb
@@ -0,0 +1,88 @@
+require 'spec_helper_puppet'
+
+describe 'jboss::datasource', :type => :define do
+ def merge_params(hash = {})
+ hash.merge({
+ :username => 'test-username',
+ :password => 'test-password',
+ :jdbcscheme => 'test-scheme',
+ :host => 'example.com',
+ :port => '1234',
+ :driver => {
+ 'name' => 'test-driver',
+ 'classname' => 'com.example.TestDriver',
+ 'modulename' => 'test-driver',
+ },
+ })
+ end
+
+ let(:title) { 'test-datasource' }
+ let(:params) { merge_params }
+ let(:facts) do
+ {
+ :osfamily => "RedHat",
+ :operatingsystem => "OracleLinux",
+ :'jboss::profile' => "domain",
+ :'jboss::controller' => "controller.example.com",
+ :concat_basedir => "/tmp/",
+ :jboss_product => 'wildfly',
+ :jboss_version => '8.2.0.Final',
+ }
+ end
+
+ it { is_expected.to compile.with_all_deps }
+ it do
+ is_expected.to contain_jboss_jdbcdriver('test-driver').
+ with_classname('com.example.TestDriver').with_modulename('test-driver')
+ end
+ it { is_expected.to contain_jboss_datasource('test-datasource') }
+ it { is_expected.to contain_jboss__datasource('test-datasource') }
+
+ it do
+ is_expected.to contain_jboss_datasource('test-datasource').
+ with_port(1234)
+ end
+
+ it do
+ is_expected.to contain_jboss_datasource('test-datasource').
+ with_xa(false)
+ end
+
+ context 'with option prepared-statements-cache-size set to 46' do
+ let(:options) do {
+ 'prepared-statements-cache-size' => 46
+ }
+ end
+ context 'in XA mode' do
+ let(:params) do
+ merge_params({ :options => options, :xa => true })
+ end
+
+ it { is_expected.to contain_jboss_datasource('test-datasource').with_xa(true) }
+ it do is_expected.to contain_jboss_datasource('test-datasource').with_options({
+ "validate-on-match"=>false,
+ "background-validation"=>false,
+ "share-prepared-statements"=>false,
+ "prepared-statements-cache-size"=>46,
+ "same-rm-override"=>true,
+ "wrap-xa-resource"=>true
+ })
+ end
+ end
+ context 'in non-XA mode' do
+ let(:params) do
+ merge_params({ :options => options, :xa => false })
+ end
+
+ it { is_expected.to contain_jboss_datasource('test-datasource').with_xa(false) }
+ it do is_expected.to contain_jboss_datasource('test-datasource').with_options({
+ "validate-on-match"=>false,
+ "background-validation"=>false,
+ "share-prepared-statements"=>false,
+ "prepared-statements-cache-size"=>46
+ })
+ end
+ end
+ end
+end
+
diff --git a/spec/defines/logging/syslog_spec.rb b/spec/defines/logging/syslog_spec.rb
new file mode 100644
index 0000000..6d64421
--- /dev/null
+++ b/spec/defines/logging/syslog_spec.rb
@@ -0,0 +1,27 @@
+require 'spec_helper_puppet'
+
+describe 'jboss::logging::syslog', :type => :define do
+ let(:title) { 'test-handler' }
+ let(:params) { { :app_name => 'test-app', } }
+ let(:facts) { {
+ :osfamily => "RedHat",
+ :operatingsystem => "RedHat",
+ 'jboss::profile' => "domain",
+ 'jboss::controller' => "controller.example.com",
+ :concat_basedir => "/tmp/"
+ } }
+
+ it { is_expected.to compile }
+ it do
+ is_expected.to contain_jboss__clientry("/subsystem=logging/syslog-handler=#{title}").
+ with_ensure('present').
+ with_properties({
+ 'port' => 514,
+ 'app-name' => 'test-app',
+ 'level' => 'INFO',
+ 'server-address' => '127.0.0.1',
+ 'syslog-format' => 'RFC5424',
+ })
+ end
+end
+
diff --git a/spec/functions/jboss_to_bool_spec.rb b/spec/functions/jboss_to_bool_spec.rb
new file mode 100644
index 0000000..61311b5
--- /dev/null
+++ b/spec/functions/jboss_to_bool_spec.rb
@@ -0,0 +1,50 @@
+require 'spec_helper'
+
+describe 'jboss_to_bool', :type => :puppet_function do
+ it do
+ should run.
+ with_params().and_raise_error(
+ Puppet::ParseError,
+ 'jboss_to_bool(): Wrong number of arguments given (0 for 1)'
+ )
+ end
+
+ it do
+ should run.
+ with_params(1, true).and_raise_error(
+ Puppet::ParseError,
+ 'jboss_to_bool(): Wrong number of arguments given (2 for 1)'
+ )
+ end
+
+ it { should run.with_params(true).and_return true }
+ it { should run.with_params(1).and_return true }
+ it { should run.with_params(:true).and_return true }
+ it { should run.with_params(:t).and_return true }
+ it { should run.with_params(:yes).and_return true }
+ it { should run.with_params(:y).and_return true }
+ it { should run.with_params('true').and_return true }
+ it { should run.with_params('t').and_return true }
+ it { should run.with_params('yes').and_return true }
+ it { should run.with_params('y').and_return true }
+
+ it { should run.with_params(nil).and_return false }
+ it { should run.with_params(false).and_return false }
+ it { should run.with_params(:undef).and_return false }
+ it { should run.with_params(:undefined).and_return false }
+ it { should run.with_params('undef').and_return false }
+ it { should run.with_params('undefined').and_return false }
+ it { should run.with_params('').and_return false }
+ it { should run.with_params('It\'s tick tac toe!').and_return false }
+ it { should run.with_params(0).and_return false }
+ it { should run.with_params(1340).and_return false }
+ it { should run.with_params(:f).and_return false }
+ it { should run.with_params(:false).and_return false }
+ it { should run.with_params('false').and_return false }
+ it { should run.with_params('f').and_return false }
+ it { should run.with_params(:no).and_return false }
+ it { should run.with_params(:n).and_return false }
+ it { should run.with_params('no').and_return false }
+ it { should run.with_params('n').and_return false }
+
+end
\ No newline at end of file
diff --git a/spec/functions/jboss_to_i_spec.rb b/spec/functions/jboss_to_i_spec.rb
new file mode 100644
index 0000000..a921010
--- /dev/null
+++ b/spec/functions/jboss_to_i_spec.rb
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe 'jboss_to_i', :type => :puppet_function do
+ it do
+ should run.
+ with_params().and_raise_error(
+ Puppet::ParseError,
+ 'jboss_to_i(): Wrong number of arguments given (0 for 1)'
+ )
+ end
+
+ it { should run.with_params(nil).and_return(0) }
+ it { should run.with_params('').and_return(0) }
+ it { should run.with_params(123).and_return(123) }
+ it { should run.with_params('67').and_return(67) }
+
+ it do
+ v = :azx
+ should run.with_params(v).and_return(0)
+ end
+
+end
\ No newline at end of file
diff --git a/spec/functions/jboss_to_s_spec.rb b/spec/functions/jboss_to_s_spec.rb
new file mode 100644
index 0000000..a169ecf
--- /dev/null
+++ b/spec/functions/jboss_to_s_spec.rb
@@ -0,0 +1,27 @@
+require 'spec_helper'
+
+describe 'jboss_to_s', :type => :puppet_function do
+ it 'should throw Puppet::ParseError if passing 0 args' do
+ should run.
+ with_params().and_raise_error(
+ Puppet::ParseError,
+ 'jboss_to_s(): Wrong number of arguments given (0 for 1)'
+ )
+ end
+
+ it 'should throw Puppet::ParseError if passing 2 args' do
+ should run.
+ with_params(1, true).and_raise_error(
+ Puppet::ParseError,
+ 'jboss_to_s(): Wrong number of arguments given (2 for 1)'
+ )
+ end
+
+ it 'should return "true" if passing true' do
+ should run.with_params(true).and_return 'true'
+ end
+
+ it 'should return "undef" if passing :undef' do
+ should run.with_params(:undef).and_return 'undef'
+ end
+end
\ No newline at end of file
diff --git a/spec/spec.opts b/spec/spec.opts
index 91cd642..e6ad807 100644
--- a/spec/spec.opts
+++ b/spec/spec.opts
@@ -1,5 +1,5 @@
--format
-s
+d
--colour
--loadby
mtime
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index dc7e9f4..86d6702 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,2 +1,69 @@
-require 'rubygems'
require 'puppetlabs_spec_helper/module_spec_helper'
+require 'rspec/its'
+
+unless $executing_puppet
+ begin
+ gem 'simplecov'
+ require 'simplecov'
+ formatters = []
+ formatters << SimpleCov::Formatter::HTMLFormatter
+
+ begin
+ gem 'coveralls'
+ require 'coveralls'
+ formatters << Coveralls::SimpleCov::Formatter if ENV['TRAVIS']
+ rescue Gem::LoadError
+ # do nothing
+ end
+
+ begin
+ gem 'codeclimate-test-reporter'
+ require 'codeclimate-test-reporter'
+ formatters << CodeClimate::TestReporter::Formatter if (ENV['TRAVIS'] and ENV['CODECLIMATE_REPO_TOKEN'])
+ rescue Gem::LoadError
+ # do nothing
+ end
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[*formatters]
+ SimpleCov.start do
+ add_filter "/spec/"
+ add_filter "/.vendor/"
+ add_filter "/vendor/"
+ add_filter "/gems/"
+ minimum_coverage 76
+ refuse_coverage_drop
+ end
+ rescue Gem::LoadError
+ # do nothing
+ end
+end
+
+begin
+ gem 'pry'
+ require 'pry'
+rescue Gem::LoadError
+ # do nothing
+end
+
+require 'rspec-puppet'
+
+RSpec.configure do |c|
+ c.tty = true unless ENV['JENKINS_URL'].nil?
+ c.mock_with :rspec do |mock|
+ mock.syntax = [:expect, :should]
+ end
+ c.include PuppetlabsSpec::Files
+
+ c.before :each do
+ # Store any environment variables away to be restored later
+ @old_env = {}
+ ENV.each_key {|k| @old_env[k] = ENV[k]}
+
+ if ENV['STRICT_VARIABLES'] == 'yes'
+ Puppet.settings[:strict_variables]=true
+ end
+ end
+
+ c.after :each do
+ PuppetlabsSpec::Files.cleanup
+ end
+end
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
new file mode 100644
index 0000000..e3cf2cd
--- /dev/null
+++ b/spec/spec_helper_acceptance.rb
@@ -0,0 +1,58 @@
+require 'beaker-rspec/spec_helper'
+require 'beaker-rspec/helpers/serverspec'
+
+unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no'
+
+ puppetver = if RUBY_VERSION < '1.9.0' then '2.7.26' else ENV['PUPPET_VERSION'] end
+ facterver = ENV['FACTER_VERSION']
+ # This will install the latest available package on el and deb based
+ # systems fail on windows and osx, and install via gem on other *nixes
+ foss_opts = { :default_action => 'gem_install' }
+ foss_opts[:version] = puppetver unless puppetver.nil?
+ foss_opts[:facter_version] = facterver unless facterver.nil?
+
+ if default.is_pe?
+ install_pe
+ else
+ install_puppet foss_opts
+ end
+
+ hosts.each do |host|
+ shell("mkdir -p #{host['distmoduledir']}")
+ if ! host.is_pe?
+ # Augeas is only used in one place, for Redhat.
+ if fact('osfamily') == 'RedHat'
+ install_package host, 'ruby-devel'
+ install_package host, 'tar'
+ end
+ end
+ end
+end
+
+UNSUPPORTED_PLATFORMS = ['AIX','windows','Solaris', 'Suse']
+
+RSpec.configure do |c|
+ # Project root
+ proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+
+ # Configure all nodes in nodeset
+ c.before :suite do
+ # Install module and dependencies
+ install_dev_puppet_module(:source => proj_root, :module_name => 'jboss')
+
+ hosts.each do |host|
+ on host, "/bin/touch #{default['puppetpath']}/hiera.yaml"
+ on host, 'chmod 755 /root'
+ if fact('osfamily') == 'Debian'
+ on host, "echo \"en_US ISO-8859-1\nen_US.UTF-8 UTF-8\n\" > /etc/locale.gen"
+ on host, '/usr/sbin/locale-gen'
+ on host, '/usr/sbin/update-locale'
+ end
+
+ on host, puppet('module','install','puppetlabs-stdlib', '--version', '3.2.0'), { :acceptable_exit_codes => [0,1] }
+ on host, puppet('module','install','puppetlabs-java', '--version', '1.3.0'), { :acceptable_exit_codes => [0,1] }
+ on host, puppet('module','install','puppetlabs-concat', '--version', '1.0.0'), { :acceptable_exit_codes => [0,1] }
+ end
+
+ end
+end
\ No newline at end of file
diff --git a/spec/spec_helper_puppet.rb b/spec/spec_helper_puppet.rb
new file mode 100644
index 0000000..8d74cb0
--- /dev/null
+++ b/spec/spec_helper_puppet.rb
@@ -0,0 +1,5 @@
+$executing_puppet = true
+
+require 'spec_helper'
+
+at_exit { RSpec::Puppet::Coverage.report! }
diff --git a/spec/unit/facter/jboss_configfile_spec.rb b/spec/unit/facter/jboss_configfile_spec.rb
new file mode 100644
index 0000000..f70ebcb
--- /dev/null
+++ b/spec/unit/facter/jboss_configfile_spec.rb
@@ -0,0 +1,18 @@
+require 'spec_helper'
+
+describe 'Fact jboss_configfile', :type => :fact do
+ subject { Facter.value(:jboss_configfile) }
+ let(:sample_config) { '/etc/jboss-eap/jboss-eap.conf' }
+ let(:sample_content) { "export JBOSS_CONF='#{sample_config}'" }
+ let(:path) { '/etc/profile.d/jboss.sh' }
+ before :each do
+ expect(File).to receive(:read).with(path).and_return(sample_content)
+ end
+ after :each do
+ fct = Facter.fact :jboss_configfile
+ fct.instance_variable_set(:@value, nil)
+ end
+ context "with sample file \"export JBOSS_CONF='/etc/jboss-eap/jboss-eap.conf'\"" do
+ it { expect(subject).to eq(sample_config) }
+ end
+end
\ No newline at end of file
diff --git a/spec/unit/facter/jboss_fullconfig_spec.rb b/spec/unit/facter/jboss_fullconfig_spec.rb
new file mode 100644
index 0000000..c89389b
--- /dev/null
+++ b/spec/unit/facter/jboss_fullconfig_spec.rb
@@ -0,0 +1,101 @@
+require 'spec_helper'
+require 'puppet_x/coi/jboss/configuration'
+
+describe 'Fact jboss_fullconfig', :type => :fact do
+ let(:sample_config) do
+ t = Tempfile.new('rspec-jboss-fullconfig')
+ path = t.path
+ t.unlink
+ path
+ end
+ let(:sample_content) do
+ <<-eos
+ # The Jboss home directory.
+ #
+ JBOSS_HOME=/usr/lib/wildfly-12.2.0.Final
+
+ # The JBoss product name.
+ #
+ JBOSS_PRODUCT=wildfly
+
+ # The JBoss version.
+ #
+ JBOSS_VERSION=12.2.0.Final
+
+ # The JBoss configuration file
+ #
+ JBOSS_CONFIG=standalone-full.xml
+
+ # The username who should own the process.
+ #
+ JBOSS_USER=wildfly
+
+ # The amount of time to wait for startup
+ #
+ # STARTUP_WAIT=30
+
+ # The amount of time to wait for shutdown
+ #
+ # SHUTDOWN_WAIT=30
+
+ # Location to keep the console log
+ #
+ JBOSS_CONSOLE_LOG=/var/log/wildfly/console.log
+
+ # Runs JBoss in domain mode?
+ JBOSS_RUNASDOMAIN=false
+
+ # JBoss running mode: domain or standalone
+ JBOSS_MODE=standalone
+
+ # Default JBoss domain controller
+ JBOSS_CONTROLLER=127.0.0.1:9990
+
+ # Default JBoss domain profile
+ JBOSS_PROFILE=full
+ eos
+ end
+ let(:profile_d_content) { "export JBOSS_CONF=\'#{sample_config}\'" }
+ let(:expected_hash) do
+ {
+ 'home' => '/usr/lib/wildfly-12.2.0.Final',
+ 'product' => 'wildfly',
+ 'version' => '12.2.0.Final',
+ 'config' => 'standalone-full.xml',
+ 'user' => 'wildfly',
+ 'console_log' => '/var/log/wildfly/console.log',
+ 'runasdomain' => false,
+ 'mode' => 'standalone',
+ 'controller' => '127.0.0.1:9990',
+ 'profile' => 'full',
+ }
+ end
+ before :all do
+ Facter.clear
+ configfile_fct = Facter.fact :jboss_configfile
+ configfile_fct.instance_variable_set(:@value, nil)
+ end
+ before :each do
+ Facter.clear
+ expect(Puppet_X::Coi::Jboss::Configuration).to receive(:read_raw_profile_d).
+ at_least(:once).and_return(profile_d_content)
+ File.open(sample_config, 'w') {|f| f.write(sample_content) }
+ end
+ after :each do
+ fct = Facter.fact :jboss_fullconfig
+ fct.instance_variable_set(:@value, nil)
+ configfile_fct = Facter.fact :jboss_configfile
+ configfile_fct.instance_variable_set(:@value, nil)
+ File.unlink(sample_config)
+ end
+ subject { Facter.value(:jboss_fullconfig) }
+ context 'with sample config file for WildFly 8.2' do
+ context 'return value' do
+ it { expect(subject).not_to be_nil }
+ it { expect(subject).not_to be_empty }
+ it { expect(subject).to respond_to(:[]) }
+ its(:size) { should eq(10) }
+ it { expect(subject).to eq(expected_hash) }
+ end
+ end
+end
\ No newline at end of file
diff --git a/spec/unit/facter/jboss_running_spec.rb b/spec/unit/facter/jboss_running_spec.rb
new file mode 100644
index 0000000..8365948
--- /dev/null
+++ b/spec/unit/facter/jboss_running_spec.rb
@@ -0,0 +1,7 @@
+require 'spec_helper'
+
+describe 'jboss_running', :type => :fact do
+ subject { Facter.value(:jboss_running) }
+ it { expect { subject }.not_to raise_error }
+ it { expect(subject).to match('^(?:true|false)$') }
+end
\ No newline at end of file
diff --git a/spec/unit/lib/provider/datasource/post_wildfly_provider_spec.rb b/spec/unit/lib/provider/datasource/post_wildfly_provider_spec.rb
new file mode 100644
index 0000000..10007d7
--- /dev/null
+++ b/spec/unit/lib/provider/datasource/post_wildfly_provider_spec.rb
@@ -0,0 +1,25 @@
+require 'spec_helper'
+require 'puppet_x/coi/jboss/provider/datasource/post_wildfly_provider'
+
+describe Puppet_X::Coi::Jboss::Provider::Datasource::PostWildFlyProvider do
+
+ let(:xa) { false }
+ let(:jta) { true }
+ let(:provider) { double("Provider") }
+ before do
+ allow(provider).to receive(:xa?).and_return(xa)
+ allow(provider).to receive(:getattrib).and_return(jta)
+ end
+ let(:target) { described_class.new(provider) }
+
+ describe 'xa_datasource_properties_wrapper' do
+ let(:parameters) { 'david=one,martha=tree' }
+ subject { target.xa_datasource_properties_wrapper(parameters) }
+ it { expect(subject).to eq('{david=one,martha=tree}') }
+ end
+
+ describe 'jta' do
+ subject { target.jta }
+ it { expect(subject).to eq('true') }
+ end
+end
\ No newline at end of file
diff --git a/spec/unit/lib/provider/datasource/pre_wildfly_provider_spec.rb b/spec/unit/lib/provider/datasource/pre_wildfly_provider_spec.rb
new file mode 100644
index 0000000..f640c81
--- /dev/null
+++ b/spec/unit/lib/provider/datasource/pre_wildfly_provider_spec.rb
@@ -0,0 +1,13 @@
+require 'spec_helper'
+require 'puppet_x/coi/jboss/provider/datasource/pre_wildfly_provider'
+
+describe Puppet_X::Coi::Jboss::Provider::Datasource::PreWildFlyProvider do
+
+ let(:target) { described_class.new(nil) }
+
+ describe 'xa_datasource_properties_wrapper' do
+ let(:parameters) { 'david=one,martha=tree' }
+ subject { target.xa_datasource_properties_wrapper(parameters) }
+ it { expect(subject).to eq('[david=one,martha=tree]') }
+ end
+end
\ No newline at end of file
diff --git a/spec/unit/provider/jboss_datasource/jbosscli_spec.rb b/spec/unit/provider/jboss_datasource/jbosscli_spec.rb
new file mode 100644
index 0000000..53a7bd3
--- /dev/null
+++ b/spec/unit/provider/jboss_datasource/jbosscli_spec.rb
@@ -0,0 +1,305 @@
+require 'spec_helper'
+require 'puppet_x/coi/jboss/configuration'
+
+context "While mocking facts :jboss_product => 'jboss-eap' and :jboss_version => '6.4.0.GA'" do
+
+ let(:mock_values) do
+ {
+ :product => 'jboss-eap',
+ :version => '6.4.0.GA',
+ :controller => '127.0.0.1:9999',
+ }
+ end
+
+ before :each do
+ Puppet_X::Coi::Jboss::Configuration.reset_config(mock_values)
+ end
+
+ after :each do
+ Puppet_X::Coi::Jboss::Configuration.reset_config
+ end
+
+ describe 'Puppet::Type::Jboss_datasource::ProviderJbosscli' do
+
+ let(:described_class) do
+ Puppet::Type.type(:jboss_datasource).provider(:jbosscli)
+ end
+ let(:sample_repl) do
+ {
+ :name => 'testing',
+ :xa => false,
+ :runasdomain => false,
+ :jdbcscheme => 'h2:mem',
+ }
+ end
+
+ let(:resource) do
+ raw = sample_repl.dup
+ raw[:provider] = described_class.name
+ Puppet::Type.type(:jboss_datasource).new(raw)
+ end
+
+ let(:provider) do
+ resource.provider
+ end
+
+ before :each do
+ allow(provider.class).to receive(:suitable?).and_return(true)
+ end
+
+ describe 'Result of self.instances()' do
+ let(:xa_result) do
+ <<-eos
+ {
+ "outcome" => "success",
+ "result" => []
+ }
+ eos
+ end
+ let(:nonxa_result) do
+ <<-eos
+ {
+ "outcome" => "success",
+ "result" => [
+ "ExampleDS",
+ "test-datasource"
+ ]
+ }
+ eos
+ end
+ let(:status) { double(:exitstatus => 0) }
+ before :each do
+ re = /.*bin\/jboss-cli.sh --timeout=50000 --connect --file=\/tmp\/jbosscli.* --controller=127.0.0.1:9999/
+ expect(Puppet::Provider::Jbosscli).to receive(:last_execute_status).
+ at_least(:once).and_return(status)
+ expect(Puppet::Provider::Jbosscli).to receive(:execshell).
+ at_least(:once).with(re).and_return(xa_result, nonxa_result)
+ end
+ it { expect(provider.class.instances).not_to be_empty }
+ context 'its size' do
+ subject { provider.class.instances.size }
+ it { expect(subject).to eq(2) }
+ end
+ context 'for second result, parameter' do
+ subject { provider.class.instances[1] }
+ its(:class) { should eq(Puppet::Type::Jboss_datasource::ProviderJbosscli) }
+ its(:name) { should eq('test-datasource') }
+ its(:xa) { should eq(false) }
+ end
+ end
+
+ context 'Given `testing` Non-XA datasource using h2:mem' do
+ let(:command) do
+ '/subsystem=datasources/data-source=testing:read-resource(recursive=true)'
+ end
+ let(:runasdomain) { false }
+ let(:timeout) { 0 }
+ let(:retry_count) { 0 }
+ let(:ctrlcfg) do
+ {
+ :controller => "127.0.0.1:9990",
+ :ctrluser => nil,
+ :ctrlpasswd => nil
+ }
+ end
+ let(:result) do
+ {
+ :result => true,
+ :data => {
+ "allocation-retry" => nil,
+ "allocation-retry-wait-millis" => nil,
+ "allow-multiple-users" => false,
+ "background-validation" => false,
+ "background-validation-millis" => nil,
+ "blocking-timeout-wait-millis" => nil,
+ "capacity-decrementer-class" => nil,
+ "capacity-decrementer-properties" => nil,
+ "capacity-incrementer-class" => nil,
+ "capacity-incrementer-properties" => nil,
+ "check-valid-connection-sql" => nil,
+ "connection-listener-class" => nil,
+ "connection-listener-property" => nil,
+ "connection-properties" => nil,
+ "connection-url" => "jdbc:h2:mem:///testing;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE",
+ "datasource-class" => nil,
+ "driver-class" => nil,
+ "driver-name" => "h2",
+ "enabled" => true,
+ "exception-sorter-class-name" => nil,
+ "exception-sorter-properties" => nil,
+ "flush-strategy" => nil,
+ "idle-timeout-minutes" => nil,
+ "initial-pool-size" => nil,
+ "jndi-name" => "java:jboss/datasources/testing",
+ "jta" => true,
+ "max-pool-size" => 50,
+ "min-pool-size" => 1,
+ "new-connection-sql" => nil,
+ "password" => "test-password",
+ "pool-prefill" => nil,
+ "pool-use-strict-min" => nil,
+ "prepared-statements-cache-size" => 0,
+ "query-timeout" => nil,
+ "reauth-plugin-class-name" => nil,
+ "reauth-plugin-properties" => nil,
+ "security-domain" => nil,
+ "set-tx-query-timeout" => false,
+ "share-prepared-statements" => false,
+ "spy" => false,
+ "stale-connection-checker-class-name" => nil,
+ "stale-connection-checker-properties" => nil,
+ "track-statements" => "NOWARN",
+ "transaction-isolation" => nil,
+ "url-delimiter" => nil,
+ "url-selector-strategy-class-name" => nil,
+ "use-ccm" => true,
+ "use-fast-fail" => false,
+ "use-java-context" => true,
+ "use-try-lock" => nil,
+ "user-name" => "test-username",
+ "valid-connection-checker-class-name" => nil,
+ "valid-connection-checker-properties" => nil,
+ "validate-on-match" => false,
+ "statistics" => nil
+ }
+ }
+ end
+ let(:expected_connection) do
+ "testing;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE"
+ end
+ before :each do
+ expect(Puppet::Provider::Jbosscli).to receive(:executeAndGet).
+ with(command, runasdomain, ctrlcfg, retry_count, timeout).and_return(result)
+ end
+
+ describe 'result of dbname()' do
+ subject { provider.dbname }
+ it { expect(subject).not_to be_nil }
+ it { expect(subject).not_to be_empty }
+ it { expect(subject).to eq(expected_connection) }
+ end
+
+ describe 'result of host()' do
+ subject { provider.host }
+ it { expect(subject).not_to be_nil }
+ it { expect(subject).to be_empty }
+ it { expect(subject).to eq('') }
+ end
+
+ describe 'result of port()' do
+ subject { provider.port }
+ it { expect(subject).not_to be_nil }
+ it { expect(subject).to eq(0) }
+ end
+
+ describe 'result of jdbcscheme()' do
+ subject { provider.jdbcscheme }
+ it { expect(subject).not_to be_nil }
+ it { expect(subject).not_to be_empty }
+ it { expect(subject).to eq('h2:mem') }
+ end
+ end
+
+ describe 'For XA Datasource' do
+ let(:sample_repl) do
+ {
+ :name => 'testing',
+ :xa => true,
+ :runasdomain => false,
+ :jdbcscheme => 'h2:mem',
+ :options => {},
+ :jndiname => 'jboss:/datasources/testing'
+ }
+ end
+ before :each do
+ cli = '/subsystem=datasources/xa-data-source=testing:read-resource(recursive=true)'
+ expect(provider).to receive(:executeAndGet).with(cli).at_least(:once).and_return({
+ :result => true,
+ :data => {
+ 'jta' => false
+ }
+ })
+ provider.exists?
+ end
+ context 'while using JBoss EAP 6.4.0.GA' do
+ describe 'jta()' do
+ subject { provider.jta }
+ it { expect(subject).not_to be_nil }
+ it { expect(subject).to eq('true') }
+ end
+ describe 'jta_opt(cmd)' do
+ before :each do
+ provider.jta = true
+ end
+ let(:cmd) { [] }
+ subject { provider.jta_opt(cmd) }
+ it { expect(subject).to be_nil }
+ it { expect(cmd).to be_empty }
+ end
+ end
+ context 'while using JBoss EAP 6.2.0.GA' do
+ let(:mock_values) do
+ {
+ :product => 'jboss-eap',
+ :version => '6.2.0.GA',
+ :controller => '127.0.0.1:9999'
+ }
+ end
+ describe 'jta()' do
+ subject { provider.jta }
+ it { expect(subject).not_to be_nil }
+ it { expect(subject).to eq('false') }
+ end
+ describe 'jta_opt(cmd)' do
+ before :each do
+ cli2 = '/subsystem=datasources/xa-data-source=testing:write-attribute(name="jta", value="true")'
+ expect(provider).to receive(:executeAndGet).with(cli2).and_return({
+ :result => true,
+ :data => {}
+ })
+ provider.jta = true
+ end
+ let(:cmd) { [] }
+ subject { provider.jta_opt(cmd) }
+ it { expect(subject).not_to be_nil }
+ it { expect(cmd).to be_empty }
+ end
+
+ describe 'create()' do
+ before :each do
+ cmd = 'xa-data-source add --name=testing --jta=true --jndi-name="jboss:/datasources/testing" ' +
+ '--driver-name=nil --min-pool-size=nil --max-pool-size=nil' +
+ ' --user-name=nil --password=nil --xa-datasource-properties=' +
+ '[ServerName=nil,PortNumber=nil,DatabaseName="testing"]'
+ expect(provider).to receive(:executeWithFail).with('Datasource', cmd, 'to create')
+ cli = '/subsystem=datasources/xa-data-source=testing:read-attribute(name=enabled)'
+ expect(provider).to receive(:executeAndGet).with(cli).and_return({
+ :result => true,
+ :data => true
+ })
+ end
+ subject { provider.create }
+ it { expect { subject }.not_to raise_error }
+ end
+
+ describe 'destroy()' do
+ before :each do
+ cmd = 'xa-data-source remove --name=testing'
+ expect(provider).to receive(:executeWithFail).with('Datasource', cmd, 'to remove')
+ end
+ subject { provider.destroy }
+ it { expect { subject }.not_to raise_error }
+ end
+ end
+ end
+
+ describe 'prepare_resource()' do
+ before :each do
+ provider.instance_variable_set(:@resource, nil)
+ end
+ subject { provider.prepare_resource }
+ it { expect { subject }.not_to raise_error }
+ end
+
+ end
+end
\ No newline at end of file
diff --git a/spec/unit/types/jboss_datasource_spec.rb b/spec/unit/types/jboss_datasource_spec.rb
new file mode 100644
index 0000000..5275b57
--- /dev/null
+++ b/spec/unit/types/jboss_datasource_spec.rb
@@ -0,0 +1,179 @@
+require 'spec_helper'
+
+describe 'jboss_datasource', :type => :type do
+ let(:described_class) { Puppet::Type.type(:jboss_datasource) }
+ subject { described_class }
+ it { expect(subject).not_to be_nil }
+ let(:ex_class) { if Puppet.version > '3.0.0' then Puppet::ResourceError else Puppet::Error end }
+
+ def extend_params(given)
+ {
+ :title => 'spec-datasource'
+ }.merge(given)
+ end
+
+ let(:type) { described_class.new(params) }
+
+ describe 'controller' do
+ context 'given :undef' do
+ let(:params) { extend_params({ :controller => :undef }) }
+ it do
+ expect { type }.to raise_error(ex_class,
+ 'Parameter controller failed on Jboss_datasource[spec-datasource]: Domain controller must be provided')
+ end
+ end
+ end
+
+ describe 'port' do
+ context 'given invalid text' do
+ let(:params) { extend_params({ :port => "an invalid port" }) }
+ it do
+ expect { type }.to raise_error(ex_class,
+ 'Parameter port failed on Jboss_datasource[spec-datasource]: Datasource port is invalid, given "an invalid port"')
+ end
+ end
+ context 'given "5x45"' do
+ let(:params) { extend_params({ :port => "5x45" }) }
+ before { skip('FIXME: A buggy host validation, ref: coi-gov-pl/puppet-jboss#8') }
+ it do
+ expect { type }.to raise_error(ex_class,
+ 'Parameter port failed on Jboss_datasource[spec-datasource]: Datasource port is invalid, given "an invalid port"')
+ end
+ end
+ context 'property :port' do
+ subject { type.property :port }
+ context 'given as "7778"' do
+ let(:params) { extend_params({ :port => "7778" }) }
+ its(:value) { should == 7778 }
+ end
+ context 'given as ""' do
+ let(:params) { extend_params({ :port => "" }) }
+ its(:value) { should == 0 }
+ end
+ end
+ end
+
+ describe 'host' do
+ context 'given invalid text " "' do
+ let(:params) { extend_params({ :host => ' ' }) }
+ it do
+ expect { type }.to raise_error(ex_class,
+ 'Parameter host failed on Jboss_datasource[spec-datasource]: Datasource host is invalid, given " "')
+ end
+ end
+ context 'given "an invalid host"' do
+ before { skip('FIXME: A buggy host validation, ref: coi-gov-pl/puppet-jboss#8') }
+ let(:params) { extend_params({ :host => "an invalid host" }) }
+ it do
+ expect { type }.to raise_error(ex_class,
+ 'Parameter host failed on Jboss_datasource[spec-datasource]: Datasource host is invalid, given "an invalid host"')
+ end
+ end
+ end
+
+ describe 'minpoolsize' do
+ subject { type.property :minpoolsize }
+ context 'given invalid text' do
+ let(:params) { extend_params({ :minpoolsize => "an invalid text" }) }
+ its(:value) { should == 1 }
+ end
+ context 'given 13.45' do
+ let(:params) { extend_params({ :minpoolsize => 13.45 }) }
+ its(:value) { should == 13 }
+ end
+ context 'given :undef' do
+ let(:params) { extend_params({ :minpoolsize => :undef }) }
+ its(:value) { should == 1 }
+ end
+ context 'given "17"' do
+ let(:params) { extend_params({ :minpoolsize => '17' }) }
+ its(:value) { should == 17 }
+ end
+ end
+
+ describe 'maxpoolsize' do
+ subject { type.property :maxpoolsize }
+ context 'given invalid text' do
+ let(:params) { extend_params({ :maxpoolsize => "an invalid text" }) }
+ its(:value) { should == 50 }
+ end
+ context 'given 13.45' do
+ let(:params) { extend_params({ :maxpoolsize => 13.45 }) }
+ its(:value) { should == 13 }
+ end
+ context 'given :undef' do
+ let(:params) { extend_params({ :maxpoolsize => :undef }) }
+ its(:value) { should == 50 }
+ end
+ context 'given "17"' do
+ let(:params) { extend_params({ :maxpoolsize => '17' }) }
+ its(:value) { should == 17 }
+ end
+ end
+
+ describe 'password' do
+ let(:params) { extend_params({ :password => "an invalid text" }) }
+ let(:expected_message) { 'password has been changed.' }
+ subject { type.property(:password).change_to_s(from, to) }
+ context 'change_to_s' do
+ context ':absent, "test-passwd"' do
+ let(:from) { :absent }
+ let(:to) { 'test-passwd' }
+ it { expect(subject).to eq(expected_message) }
+ end
+ context '"test-passwd", :absent' do
+ let(:from) { 'test-passwd' }
+ let(:to) { :absent }
+ it { expect(subject).to eq(expected_message) }
+ end
+ end
+ end
+
+ describe 'options' do
+ let(:params) do
+ extend_params({
+ :options => options
+ })
+ end
+ context 'given invalid text' do
+ before { skip('FIXME: String should not be accepted as a parameter, ref: coi-gov-pl/puppet-jboss#9')}
+ let(:options) { "an invalid text" }
+ it do
+ expect { type }.to raise_error(ex_class,
+ 'Parameter options failed on Jboss_datasource[spec-datasource]: You can pass only hash-like objects')
+ end
+ end
+ context 'given invalid boolean' do
+ let(:options) { true }
+ it do
+ expect { type }.to raise_error(ex_class,
+ 'Parameter options failed on Jboss_datasource[spec-datasource]: You can pass only hash-like objects')
+ end
+ end
+ context 'given' do
+ let(:options) { {} }
+ subject { type.property(:options).change_to_s(from, to) }
+ context 'from :absent and to hash', :from => :absent, :to => { 'alice' => 'five', 'bob' => 'seven' } do
+ before do
+ msg = 'FIXME: Handle :symbols as parameters in change_to_s, ref: coi-gov-pl/puppet-jboss#9'
+ skip(msg) if RUBY_VERSION < '1.9.0'
+ end
+ let(:from) { |expl| expl.metadata[:from] }
+ let(:to) { |expl| expl.metadata[:to] }
+ it { expect(subject).to eq("option 'alice' has changed from nil to \"five\", option 'bob' has changed from nil to \"seven\"") }
+ end
+ context 'from hash and to changed hash', :from => { 'alice' => 'five', 'bob' => 'nine' }, :to => { 'alice' => 'five', 'bob' => 'seven' } do
+ let(:from) { |expl| expl.metadata[:from] }
+ let(:to) { |expl| expl.metadata[:to] }
+ it { expect(subject).to eq("option 'bob' has changed from \"nine\" to \"seven\"") }
+ end
+ context 'from hash and to :absent', :from => { 'alice' => 'five', 'bob' => 'nine' }, :to => :absent do
+ before { skip('FIXME: A proper message while executing change_to_s for :to == :absent, ref: coi-gov-pl/puppet-jboss#9')}
+ let(:from) { |expl| expl.metadata[:from] }
+ let(:to) { |expl| expl.metadata[:to] }
+ it { expect(subject).to eq('options has been removed') }
+ end
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/spec/unit/types/jboss_jdbcdriver_spec.rb b/spec/unit/types/jboss_jdbcdriver_spec.rb
new file mode 100644
index 0000000..716416e
--- /dev/null
+++ b/spec/unit/types/jboss_jdbcdriver_spec.rb
@@ -0,0 +1,23 @@
+require 'spec_helper'
+
+describe 'jboss_jdbcdriver', :type => :type do
+ let(:described_class) { Puppet::Type.type(:jboss_jdbcdriver) }
+ subject { described_class }
+ it { expect(subject).not_to be_nil }
+
+ context 'controller == nil' do
+ let(:params) do
+ {
+ :title => 'test-driver',
+ :controller => :undef
+ }
+ end
+ subject { described_class.new(params) }
+
+ it do
+ ex_class = if Puppet.version > '3.0.0' then Puppet::ResourceError else Puppet::Error end
+ expect { subject }.to raise_error(ex_class,
+ 'Parameter controller failed on Jboss_jdbcdriver[test-driver]: Domain controller must be provided')
+ end
+ end
+end
\ No newline at end of file
diff --git a/templates/jboss-as.conf.erb b/templates/jboss-as.conf.erb
index b4b04e6..73970ee 100644
--- a/templates/jboss-as.conf.erb
+++ b/templates/jboss-as.conf.erb
@@ -1,11 +1,46 @@
+# General configuration for the init.d scripts,
+# not necessarily for JBoss AS itself.
+# The Jboss home directory.
+#
+JBOSS_HOME=<%= @home %>
-JAVA_HOME=/etc/alternatives/java_sdk
-JBOSS_HOME=<%= scope.lookupvar('jboss_path') %>
-JBOSS_USER=<%= scope.lookupvar('jboss::params::jboss_user') %>
+# The JBoss product name.
+#
+JBOSS_PRODUCT=<%= @product %>
+# The JBoss version.
+#
+JBOSS_VERSION=<%= @version %>
-export JAVA_HOME
-export JBOSS_HOME
-export JBOSS_USER
+# The JBoss configuration file
+#
+JBOSS_CONFIG=<%= @configfile %>
+# The username who should own the process.
+#
+JBOSS_USER=<%= @user %>
+
+# The amount of time to wait for startup
+#
+# STARTUP_WAIT=30
+
+# The amount of time to wait for shutdown
+#
+# SHUTDOWN_WAIT=30
+
+# Location to keep the console log
+#
+JBOSS_CONSOLE_LOG=<%= @logfile %>
+
+# Runs JBoss in domain mode?
+JBOSS_RUNASDOMAIN=<%= @runasdomain.inspect %>
+
+# JBoss running mode: domain or standalone
+JBOSS_MODE=<%= @runasdomain ? 'domain' : 'standalone' %>
+
+# Default JBoss domain controller
+JBOSS_CONTROLLER=<%= @controller %>
+
+# Default JBoss domain profile
+JBOSS_PROFILE=<%= @profile %>
diff --git a/templates/jboss-cli.erb b/templates/jboss-cli.erb
index 0f16a0a..9991989 100644
--- a/templates/jboss-cli.erb
+++ b/templates/jboss-cli.erb
@@ -1,11 +1,19 @@
#! /bin/bash
-JBOSSPATH=<%= scope.lookupvar('jboss_path') %>
+# Source jboss config (JBOSS_HOME)
+if [ -f /etc/jboss-as/jboss-as.conf ]; then
+ . /etc/jboss-as/jboss-as.conf
+fi
+
+if [ ! -z "$JBOSS_HOME" ]; then
+ JBOSS_HOME=<%= @home %>
+fi
+JBOSSPATH=$JBOSS_HOME
JBOSSCLI='./bin/jboss-cli.sh'
CWD=`pwd`
cd $JBOSSPATH
-$JBOSSCLI $@
+$JBOSSCLI "$@"
RET=$?
cd $CWD
exit $RET
diff --git a/templates/jboss-init.erb b/templates/jboss-init.erb
deleted file mode 100644
index 0cf5aa4..0000000
--- a/templates/jboss-init.erb
+++ /dev/null
@@ -1,88 +0,0 @@
-#! /bin/bash
-
-### BEGIN INIT INFO
-# Provides:
-# Required-Start: $network $local_fs $remote_fs
-# Required-Stop:
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Application Server ver. <%= scope.lookupvar('version') %>
-### END INIT INFO
-
-USER=<%= scope.lookupvar('jboss::params::jboss_user') %>
-JBOSSPATH=<%= scope.lookupvar('jboss_path') %>/bin
-__NAME="Application Server"
-echo $USER
-echo $USER
-echo $JBOSSPATH
-#test -x ${JBOSSPATH}/jboss-cli || exit 2
-test -x ${JBOSSPATH}/standalone.sh || exit 2
-echo $USER
-. /lib/lsb/init-functions
-
-function procStart() {
- # Make sure only root can run our script
- if [[ $EUID -ne 0 ]]; then
- echo "This script must be run as root" 1>&2
- exit 1
- fi
- log_daemon_msg "Starting $__NAME"
- _isOk=0
- sudo -u $USER $JBOSSPATH/standalone.sh & > $jboss_pid22
- echo $jboss_pid22
- if [[ $? -ne 0 ]]; then
- _isOk=2
- fi
- log_end_msg $_isOk
- return $_isOk
-}
-function procStop() {
- # Make sure only root can run our script
- if [[ $EUID -ne 0 ]]; then
- echo "This script must be run as root" 1>&2
- exit 1
- fi
- log_daemon_msg "Stoping $__NAME"
- _isOk=0
- sudo -u $USER ${JBOSSPATH}/jboss-cli.sh --connect command=:shutdown > /dev/null
- if [[ $? -ne 0 ]]; then
- _isOk=3
- fi
- log_end_msg $_isOk
- return $_isOk
-}
-
-case "$1" in
- start)
- procStart
- exit $?
- ;;
- stop)
- procStop
- exit $?
- ;;
- status)
- echo -n "$__NAME status: "
- count=`sudo -u $USER ${JBOSSPATH}/jboss-cli list-domains | grep run | grep -v not | wc -l`
- if test "$count" -gt "0"; then
- realpath=`dirname $(readlink -f $JBOSSPATH)`
- pid=`ps aux | grep $realpath | grep -v grep | awk '{print $2}'`
- echo "running (pid: $pid)"
- exit 0
- else
- echo stopped
- exit 4
- fi
- ;;
- restart)
- procStop
- if test "$?" != "0"; then
- exit 3
- fi
- procStart
- exit $?
- ;;
- *)
- echo $"usage: $0 {start|stop|status|restart}"
- exit 1
-esac
\ No newline at end of file
diff --git a/templates/jboss2.erb b/templates/jboss2.erb
deleted file mode 100644
index 44c4bd9..0000000
--- a/templates/jboss2.erb
+++ /dev/null
@@ -1,244 +0,0 @@
-#!/bin/sh
-#
-# JBoss standalone control script
-#
-# Provided in JBoss AS 7.1.1
-# Modified for Ubuntu Server 10.04 by koma
-#
-# chkconfig: - 80 20
-# description: JBoss AS Standalone
-# processname: standalone
-# pidfile: /var/run/jboss-as/jboss-as-standalone.pid
-# config: /etc/default/jboss-as
-#
-### BEGIN INIT INFO
-# Provides: jboss-as
-# Required-Start: $local_fs $remote_fs $network
-# Required-Stop: $local_fs $remote_fs $network
-# Should-Start: $named
-# Should-Stop: $named
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Start JBoss AS
-# Description: Start JBoss Application Server.
-### END INIT INFO
-#
-
-# Inspired by tomcat6 init script, might be somewhat redundant
-#PATH=???
-NAME=jboss-as
-DESC="JBoss AS"
-DEFAULT=/etc/default/$NAME
-
-# Source function library.
-#. /etc/init.d/functions
-# Ubuntu has it here (but probably different !)
-. /lib/lsb/init-functions
-
-# Load Java configuration.
-# Ubuntu has it in /etc/default
-[ -r /etc/default/java ] && . /etc/default/java
-export JAVA_HOME
-
-# Load JBoss AS init.d configuration.
-if [ -z "$JBOSS_CONF" ]; then
-# Ubuntu: seems more logical there
- JBOSS_CONF="/etc/default/jboss-as"
-fi
-
-[ -r "$JBOSS_CONF" ] && . "${JBOSS_CONF}"
-
-# Set defaults.
-
-if [ -z "$JBOSS_HOME" ]; then
- JBOSS_HOME=<%= scope.lookupvar('jboss_path') %>/bin
-fi
-export JBOSS_HOME
-
-# might be unbeautiful
-# this made chown fail because JBOSS_USER was empty
-if [ -z "$JBOSS_USER" ]; then
- JBOSS_USER="jboss"
-fi
-export JBOSS_USER
-
-if [ -z "$JBOSS_PIDFILE" ]; then
- JBOSS_PIDFILE=/var/run/jboss-as/jboss-as-standalone.pid
-fi
-export JBOSS_PIDFILE
-
-#if [ -z "$JBOSS_CONSOLE_LOG" ]; then
-# JBOSS_CONSOLE_LOG=/var/log/jboss-as/console.log
-#fi
-# use JBOSS_LOG_DIR from jboss script instead
-if [ -z "$JBOSS_LOG_DIR" ]; then
- JBOSS_LOG_DIR=/var/log/jboss-as
-fi
-export JBOSS_LOG_DIR
-
-# We need this to be set to get a pidfile !
-if [ -z "$LAUNCH_JBOSS_IN_BACKGROUND" ]; then
- LAUNCH_JBOSS_IN_BACKGROUND=true
-fi
-export LAUNCH_JBOSS_IN_BACKGROUND
-
-if [ -z "$STARTUP_WAIT" ]; then
- STARTUP_WAIT=120
-fi
-
-if [ -z "$SHUTDOWN_WAIT" ]; then
- SHUTDOWN_WAIT=120
-fi
-
-if [ -z "$JBOSS_CONFIG" ]; then
- JBOSS_CONFIG=standalone.xml
-fi
-
-JBOSS_SCRIPT=$JBOSS_HOME/bin/standalone.sh
-
-prog='jboss-as'
-
-
-start() {
- log_daemon_msg "Starting $DESC"
- id $JBOSS_USER > /dev/null 2>&1
- if [ $? -ne 0 -o -z "$JBOSS_USER" ]; then
- log_failure_msg "User $JBOSS_USER does not exist..."
- log_end_msg 1
- exit 1
- fi
- if [ -f $JBOSS_PIDFILE ]; then
- read ppid < $JBOSS_PIDFILE
- if [ `ps --pid $ppid 2> /dev/null | grep -c $ppid 2> /dev/null` -eq '1' ]; then
- log_progress_msg "$prog is already running"
- log_end_msg 0
- exit 0
- else
- rm -f $JBOSS_PIDFILE
- fi
- fi
- mkdir -p $JBOSS_LOG_DIR
- # not sure: clear boot.log ... dunno if good, dunno if hardcoding boot.log good
- cat /dev/null > ${JBOSS_LOG_DIR}"/boot.log"
- # same as for boot.log, but we need to clear server.log to get proper launch detection (grepping later)
- cat /dev/null > ${JBOSS_LOG_DIR}"/server.log"
- chown -R ${JBOSS_USER}: $JBOSS_LOG_DIR
-
- mkdir -p $(dirname $JBOSS_PIDFILE)
- chown ${JBOSS_USER}: $(dirname $JBOSS_PIDFILE) || true
-
- if [ ! -z "$JBOSS_USER" ]; then
- start-stop-daemon --start -b -u "$JBOSS_USER" -c "$JBOSS_USER" -d "$JBOSS_HOME" -p "$JBOSS_PIDFILE" -x ${JBOSS_HOME}/"bin/standalone.sh" -- -Djboss.server.log.dir="$JBOSS_LOG_DIR"
- else
- log_failure_msg "Error: Environment variable JBOSS_USER not set or empty."
- log_end_msg 1
- exit 1
- fi
-
- count=0
- launched=false
-
- until [ $count -gt $STARTUP_WAIT ]
- do
- grep 'JBoss AS.*started' ${JBOSS_LOG_DIR}"/server.log" > /dev/null
- if [ $? -eq 0 ] ; then
- launched=true
- break
- fi
- sleep 1
- count=$((count+1));
- done
-
- if [ $launched=true ]; then
- if [ -f $JBOSS_PIDFILE ] && [ -s $JBOSS_PIDFILE ]; then
- log_progress_msg "Successfully started $DESC."
- else
- log_progress_msg "Successfully started $DESC, but problems with pidfile."
- fi
- else
- log_failure_msg "Launching $DESC failed."
- # If the pidfile exists, try to kill the process
- if [ -f $JBOSS_PIDFILE ] && [ -s $JBOSS_PIDFILE ]; then
- read kpid < $JBOSS_PIDFILE
- log_progress_msg "Pidfile detected. Please take care of process $kpid manually."
- fi
- log_end_msg 1
- exit 1
- fi
-
- # success
- log_end_msg 0
- return 0
-}
-
-stop() {
- log_daemon_msg "Stopping $DESC"
- count=0;
-
- if [ -f $JBOSS_PIDFILE ]; then
- read kpid < $JBOSS_PIDFILE
- kwait=$SHUTDOWN_WAIT
-
- # Try issuing SIGTERM
-
- kill -15 $kpid
- until [ `ps --pid $kpid 2> /dev/null | grep -c $kpid 2> /dev/null` -eq '0' ] || [ $count -gt $kwait ]
- do
- sleep 1
- count=$((count+1));
- done
-
- if [ $count -gt $kwait ]; then
- kill -9 $kpid
- fi
- fi
- rm -f $JBOSS_PIDFILE
- log_end_msg 0
- return 0
-}
-
-status() {
- if [ -f $JBOSS_PIDFILE ]; then
- read ppid < $JBOSS_PIDFILE
- if [ `ps --pid $ppid 2> /dev/null | grep -c $ppid 2> /dev/null` -eq '1' ]; then
- log_success_msg "$prog is running (pid $ppid)"
- exit 0
- else
- log_success_msg "$prog dead but pid file exists"
- exit 1
- fi
- fi
- log_success_msg "$prog is not running"
- exit 3
-}
-
-reload() {
- log_begin_msg "Reloading $prog ..."
- start-stop-daemon --start --quiet --background --chuid jboss --exec ${JBOSS_HOME}/bin/jboss-cli.sh -- --connect command=:reload
- log_end_msg $?
- exit $?
-}
-
-case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- $0 stop
- $0 start
- ;;
- status)
- status
- ;;
- reload)
- reload
- ;;
- *)
- ## If no parameters are given, print which are avaiable.
- echo "Usage: $0 {start|stop|status|restart|reload}"
- exit 1
- ;;
-esac
\ No newline at end of file
diff --git a/templates/mod_cluster_mgmt.conf.erb b/templates/mod_cluster_mgmt.conf.erb
new file mode 100644
index 0000000..701ba38
--- /dev/null
+++ b/templates/mod_cluster_mgmt.conf.erb
@@ -0,0 +1,24 @@
+
+ Options +Indexes
+ Order deny,allow
+ Deny from all
+ Allow from 172.
+
+
+# This directive allows you to view mod_cluster status at URL /mod_cluster-manager
+
+ SetHandler mod_cluster-manager
+ Order deny,allow
+ Deny from all
+ Allow from 172.
+
+
+
+ SetHandler server-status
+ Order deny,allow
+ Deny from all
+ Allow from all
+
+
+KeepAliveTimeout 60
+MaxKeepAliveRequests 0
diff --git a/templates/module/module.xml.erb b/templates/module/module.xml.erb
new file mode 100644
index 0000000..f4e00ae
--- /dev/null
+++ b/templates/module/module.xml.erb
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+ <% @artifacts.each do |artifact| -%>
+
+ <% end -%>
+
+
+
+ <% @dependencies.each do |dep| -%>
+
+ <% end -%>
+
+
+
+
\ No newline at end of file
diff --git a/tests/datasource.pp b/tests/datasource.pp
new file mode 100644
index 0000000..96a6cc5
--- /dev/null
+++ b/tests/datasource.pp
@@ -0,0 +1,37 @@
+class { 'jboss':
+ enableconsole => true,
+}
+
+jboss::user { 'admin':
+ password => 'seCret1!',
+}
+
+# Non-XA data source
+jboss::datasource { 'test-datasource':
+ ensure => 'present',
+ username => 'test-username',
+ password => 'test-password',
+ jdbcscheme => 'h2:mem',
+ dbname => 'testing;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE',
+ host => '',
+ port => '',
+ driver => {
+ 'name' => 'h2',
+ }
+}
+
+# XA data source
+jboss::datasource { 'test-xa-datasource':
+ ensure => 'present',
+ xa => true,
+ username => 'test-username',
+ password => 'test-password',
+ jdbcscheme => 'h2:mem',
+ dbname => 'testing-xa;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE',
+ host => '',
+ port => '',
+ driver => {
+ 'name' => 'h2',
+ 'driver-xa-datasource-class-name' => 'org.h2.jdbcx.JdbcDataSource'
+ }
+}
diff --git a/tests/init.pp b/tests/init.pp
index af29d14..de68dcc 100644
--- a/tests/init.pp
+++ b/tests/init.pp
@@ -1 +1 @@
-include jboss
+class { 'jboss': }
diff --git a/tests/jboss-as.pp b/tests/jboss-as.pp
new file mode 100644
index 0000000..62eed9c
--- /dev/null
+++ b/tests/jboss-as.pp
@@ -0,0 +1,6 @@
+class { 'jboss':
+ product => 'jboss-as',
+ version => '7.1.1.Final',
+ download_url => 'http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip',
+ enableconsole => true,
+}
diff --git a/tests/jmsqueue.pp b/tests/jmsqueue.pp
new file mode 100644
index 0000000..789aeba
--- /dev/null
+++ b/tests/jmsqueue.pp
@@ -0,0 +1,10 @@
+include jboss
+
+jboss::jmsqueue { 'app-mails':
+ ensure => 'present',
+ durable => true,
+ entries => [
+ 'queue/app-mails',
+ 'java:jboss/exported/jms/queue/app-mails',
+ ],
+}
diff --git a/tests/user.pp b/tests/user.pp
new file mode 100644
index 0000000..7ab5ef0
--- /dev/null
+++ b/tests/user.pp
@@ -0,0 +1,6 @@
+include jboss
+
+jboss::user { 'admin':
+ ensure => 'present',
+ password => 'seCret1!',
+}