Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Modules 5519] Add port parameter in class mod::jk #1679

Merged
merged 21 commits into from Sep 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1c94664
Add ip and port parameters to class apache::mod::jk
Aug 22, 2017
80b80a2
Add parameter to make binding conditional in class apache::mod::jk
Aug 22, 2017
4332703
Add binding parameters validation in apache::mod::jk
Aug 22, 2017
2c796a5
Add default binding params in mod::jk spec test
Aug 22, 2017
9195d7a
Add context with alternative binding port in mod::jk spec test
Aug 22, 2017
c63a6f7
Add context without binding in mod::jk spec test
Aug 22, 2017
898fdb0
Add in README binding parameters info for class mod::jk
Aug 22, 2017
346e32d
Add in README use cases for apache::mod::jk binding params
Aug 23, 2017
a133493
Change default param treatment in mod::jk to allow spec test
Aug 23, 2017
0dcdb0a
Correct parameters in mod::jk spec test
Aug 23, 2017
569eb05
Use variable $facts for ip param default
Aug 23, 2017
d5cbb8d
Use facts for param defaults in mod::jk spec test
Aug 23, 2017
91752d5
Correct facts hash reference in class mod::jk
Aug 23, 2017
21f828d
Change param default treatment to allow spec test in class mod::jk
Aug 23, 2017
99ab672
Add resource count in all contexts in mod::jk spec test
Aug 23, 2017
d86fc2f
Change resource count for specific resource checks in mod::jk spec test
Aug 23, 2017
31f6c39
Add context for supplied IP param in mod::jk spec test
Aug 23, 2017
82ae34d
Align parameter values in class mod::jk
Aug 24, 2017
bbe9ad9
Change param apache::mod::jk::port type to integer
Aug 24, 2017
0c9e568
Change param apache::mod::jk::port type to integer in spec test
Aug 24, 2017
d42061c
Merge branch 'master' into MODULES-5519
EmersonPrado Aug 29, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 26 additions & 1 deletion README.md
Expand Up @@ -2154,6 +2154,7 @@ Installs and manages `mod_jk`, a connector for Apache httpd redirection to old v

``` puppet
class { '::apache::mod::jk':
ip = '192.168.2.15',
workers_file = 'conf/workers.properties',
mount_file = 'conf/uriworkermap.properties',
shm_file = 'run/jk.shm',
Expand All @@ -2166,7 +2167,31 @@ class { '::apache::mod::jk':

**Parameters within `apache::mod::jk`**:

The best source for understanding the `mod_jk` parameters is the [official documentation](https://tomcat.apache.org/connectors-doc/reference/apache.html), except for \*file_content:
The best source for understanding the `mod_jk` parameters is the [official documentation](https://tomcat.apache.org/connectors-doc/reference/apache.html), except for:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes! we like linking to official docs!


**add_listen**

Defines if a `Listen` directive according to parameters `ip` and `port` (see below), so that Apache listens to the IP/port combination and redirect to `mod_jk`.
Useful when another `Listen` directive, like `Listen *:<Port>` or `Listen <Port>`, can conflict with the one necessary for `mod_jk` binding.

Type: Boolean
Default: true

**ip**

IP for binding to `mod_jk`.
Useful when the binding address is not the primary network interface IP.

Type: String
Default: `$facts['ipaddress']`

**port**

Port for binding to `mod_jk`.
Useful when something else, like a reverse proxy or cache, is receiving requests at port 80, then needs to forward them to Apache at a different port.

Type: String (numerical)
Default: '80'

**workers\_file\_content**

Expand Down
94 changes: 54 additions & 40 deletions manifests/mod/jk.pp
Expand Up @@ -9,59 +9,73 @@
# https://tomcat.apache.org/connectors-doc/reference/apache.html
#
class apache::mod::jk (
$workers_file = undef,
$worker_property = {},
$logroot = undef,
$shm_file = undef,
$shm_size = undef,
$mount_file = undef,
$mount_file_reload = undef,
$mount = {},
$un_mount = {},
$auto_alias = undef,
$mount_copy = undef,
$worker_indicator = undef,
$watchdog_interval = undef,
$log_file = undef,
$log_level = undef,
$log_stamp_format = undef,
$request_log_format = undef,
$extract_ssl = undef,
$https_indicator = undef,
$sslprotocol_indicator = undef,
$certs_indicator = undef,
$cipher_indicator = undef,
$certchain_prefix = undef,
$session_indicator = undef,
$keysize_indicator = undef,
$local_name_indicator = undef,
$ignore_cl_indicator = undef,
$local_addr_indicator = undef,
$local_port_indicator = undef,
$remote_host_indicator = undef,
$remote_addr_indicator = undef,
$remote_port_indicator = undef,
$remote_user_indicator = undef,
$auth_type_indicator = undef,
$options = [],
$env_var = {},
$strip_session = undef,
# Binding to mod_jk
Optional[String] $ip = undef,
Integer $port = 80,
Boolean $add_listen = true,
# Conf file content
$workers_file = undef,
$worker_property = {},
$logroot = undef,
$shm_file = 'jk-runtime-status',
$shm_size = undef,
$mount_file = undef,
$mount_file_reload = undef,
$mount = {},
$un_mount = {},
$auto_alias = undef,
$mount_copy = undef,
$worker_indicator = undef,
$watchdog_interval = undef,
$log_file = 'mod_jk.log',
$log_level = undef,
$log_stamp_format = undef,
$request_log_format = undef,
$extract_ssl = undef,
$https_indicator = undef,
$sslprotocol_indicator = undef,
$certs_indicator = undef,
$cipher_indicator = undef,
$certchain_prefix = undef,
$session_indicator = undef,
$keysize_indicator = undef,
$local_name_indicator = undef,
$ignore_cl_indicator = undef,
$local_addr_indicator = undef,
$local_port_indicator = undef,
$remote_host_indicator = undef,
$remote_addr_indicator = undef,
$remote_port_indicator = undef,
$remote_user_indicator = undef,
$auth_type_indicator = undef,
$options = [],
$env_var = {},
$strip_session = undef,
# Location list
# See comments in template mod/jk.conf.erb
$location_list = [],
$location_list = [],
# Workers file content
# See comments in template mod/jk/workers.properties.erb
$workers_file_content = {},
$workers_file_content = {},
# Mount file content
# See comments in template mod/jk/uriworkermap.properties.erb
$mount_file_content = {},
$mount_file_content = {},
){

# Provides important variables
include ::apache
# Manages basic module config
::apache::mod { 'jk': }

# Binding to mod_jk
if $add_listen {
$_ip = $ip ? {
undef => $facts['ipaddress'],
default => $ip,
}
ensure_resource('apache::listen', "${_ip}:${port}", {})
}

# File resource common parameters
File {
ensure => file,
Expand Down
99 changes: 95 additions & 4 deletions spec/classes/mod/jk_spec.rb
Expand Up @@ -13,13 +13,19 @@
it { is_expected.to contain_file('jk.conf').with({ :path => "#{mod_dir}/jk.conf" }) }
end

context "RHEL 6 with only required facts and no parameters" do
default_ip = '192.168.1.1'
altern8_ip = '10.1.2.3'
default_port = 80
altern8_port = 8008

context "RHEL 6 with only required facts and default parameters" do

let (:facts) do
{
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6',
:ipaddress => default_ip,
}
end

Expand All @@ -28,26 +34,30 @@
end

let (:params) do
{ :logroot => '/var/log/httpd' }
{
:logroot => '/var/log/httpd',
}
end

mod_dir = '/etc/httpd/conf.d'
let (:mod_dir) { mod_dir }

it_behaves_like 'minimal resources', mod_dir
it { is_expected.to contain_apache__listen("#{default_ip}:#{default_port}") }
it {
verify_contents(catalogue, 'jk.conf', ['<IfModule jk_module>', '</IfModule>'])
}

end

context "Debian 8 with only required facts and no parameters" do
context "Debian 8 with only required facts and default parameters" do

let (:facts) do
{
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '8',
:ipaddress => default_ip,
}
end

Expand All @@ -56,19 +66,100 @@
end

let (:params) do
{ :logroot => '/var/log/apache2' }
{
:logroot => '/var/log/apache2',
}
end

mod_dir = '/etc/apache2/mods-available'
let (:mod_dir) { mod_dir }

it_behaves_like 'minimal resources', mod_dir
it { is_expected.to contain_apache__listen("#{default_ip}:#{default_port}") }
it {
verify_contents(catalogue, 'jk.conf', ['<IfModule jk_module>', '</IfModule>'])
}

end

context "RHEL 6 with required facts and alternative IP" do

let (:facts) do
{
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6',
:ipaddress => default_ip,
}
end

let (:pre_condition) do
'include apache'
end

let (:params) do
{
:ip => altern8_ip,
:logroot => '/var/log/httpd',
}
end

it { is_expected.to contain_apache__listen("#{altern8_ip}:#{default_port}") }

end

context "RHEL 6 with required facts and alternative port" do

let (:facts) do
{
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6',
:ipaddress => default_ip,
}
end

let (:pre_condition) do
'include apache'
end

let (:params) do
{
:port => altern8_port,
:logroot => '/var/log/httpd',
}
end

it { is_expected.to contain_apache__listen("#{default_ip}:#{altern8_port}") }

end

context "RHEL 6 with required facts and no binding" do

let (:facts) do
{
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6',
:ipaddress => default_ip,
}
end

let (:pre_condition) do
'include apache'
end

let (:params) do
{
:add_listen => false,
:logroot => '/var/log/httpd',
}
end

it { is_expected.not_to contain_apache__listen("#{default_ip}:#{default_port}") }

end

{
:default => {
:shm_file => :undef,
Expand Down