Skip to content

Commit 98cf15c

Browse files
eimlavsheenaajay
authored andcommitted
(FM-7923) Implement Puppet Strings (puppetlabs#1916)
* (FM-7923) - Implement Puppet Strings. Authors: David Swan david.swan@puppet.com Eimhin Laverty eimhin.laverty@puppet.com Claire Cadman claire.cadman@puppet.com
1 parent da33fc1 commit 98cf15c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+13636
-5418
lines changed

README.md

+10-5,148
Large diffs are not rendered by default.

REFERENCE.md

+9,349
Large diffs are not rendered by default.

lib/puppet/functions/apache/apache_pw_hash.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
# Hashes a password in a format suitable for htpasswd files read by apache.
1+
# @summary
2+
# Hashes a password in a format suitable for htpasswd files read by apache.
23
#
34
# Currently uses SHA-hashes, because although this format is considered insecure, its the
45
# most secure format supported by the most platforms.
56
Puppet::Functions.create_function(:'apache::apache_pw_hash') do
7+
# @param password
8+
# The input that is to be hashed.
9+
#
10+
# @return
11+
# Return's the hash of the input that was given.
612
dispatch :apache_pw_hash do
713
required_param 'String[1]', :password
814
return_type 'String'

lib/puppet/functions/apache/bool2httpd.rb

+16-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
# Transform a supposed boolean to On or Off. Pass all other values through.
2-
# Given a nil value (undef), bool2httpd will return 'Off'
1+
# @summary
2+
# Transform a supposed boolean to On or Off. Passes all other values through.
33
#
4-
# Example:
5-
#
6-
# $trace_enable = false
7-
# $server_signature = 'mail'
8-
#
9-
# bool2httpd($trace_enable)
10-
# # => 'Off'
11-
# bool2httpd($server_signature)
12-
# # => 'mail'
13-
# bool2httpd(undef)
14-
# # => 'Off'
154
Puppet::Functions.create_function(:'apache::bool2httpd') do
5+
# @param arg
6+
# The value to be converted into a string.
7+
#
8+
# @return
9+
# Will return either `On` or `Off` if given a boolean value. Return's a string of any
10+
# other given value.
11+
# @example
12+
# $trace_enable = false
13+
# $server_signature = 'mail'
14+
#
15+
# bool2httpd($trace_enable) # returns 'Off'
16+
# bool2httpd($server_signature) # returns 'mail'
17+
# bool2httpd(undef) # returns 'Off'
18+
#
1619
def bool2httpd(arg)
1720
return 'Off' if arg.nil? || arg == false || arg =~ %r{false}i || arg == :undef
1821
return 'On' if arg == true || arg =~ %r{true}i

lib/puppet/functions/apache/validate_apache_log_level.rb

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
# Perform simple validation of a string against the list of known log
2-
# levels as per http://httpd.apache.org/docs/current/mod/core.html#loglevel
3-
# validate_apache_loglevel('info')
1+
# @summary
2+
# Perform simple validation of a string against the list of known log levels.
43
#
5-
# Modules maybe specified with their own levels like these:
6-
# validate_apache_loglevel('warn ssl:info')
7-
# validate_apache_loglevel('warn mod_ssl.c:info')
8-
# validate_apache_loglevel('warn ssl_module:info')
4+
# As per http://httpd.apache.org/docs/current/mod/core.html#loglevel
5+
# * validate_apache_loglevel('info')
96
#
10-
# Expected to be used from the main or vhost.
11-
# Might be used from directory too later as apache supports that
7+
# Modules maybe specified with their own levels like these:
8+
# * validate_apache_loglevel('warn ssl:info')
9+
# * validate_apache_loglevel('warn mod_ssl.c:info')
10+
# * validate_apache_loglevel('warn ssl_module:info')
11+
#
12+
# Expected to be used from the main or vhost.
13+
# Might be used from directory too later as apache supports that
1214
Puppet::Functions.create_function(:'apache::validate_apache_log_level') do
15+
# @param log_level
16+
# The string that is to be validated.
17+
#
18+
# @return
19+
# Return's an error if the validation fails.
1320
dispatch :validate_apache_log_level do
1421
required_param 'String', :log_level
1522
end

lib/puppet/parser/functions/apache_pw_hash.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
require 'base64'
22

33
Puppet::Parser::Functions.newfunction(:apache_pw_hash, type: :rvalue, doc: <<-DOC
4-
Hashes a password in a format suitable for htpasswd files read by apache.
4+
@summary
5+
Hashes a password in a format suitable for htpasswd files read by apache.
6+
57
Currently uses SHA-hashes, because although this format is considered insecure, its the
68
most secure format supported by the most platforms.
9+
10+
@param password
11+
The input that is to be hashed.
12+
13+
@return
14+
Return's the hash of the input that was given.
715
DOC
816
) do |args|
917
raise(Puppet::ParseError, "apache_pw_hash() wrong number of arguments. Given: #{args.size} for 1)") if args.size != 1

lib/puppet/parser/functions/bool2httpd.rb

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
Puppet::Parser::Functions.newfunction(:bool2httpd, type: :rvalue, doc: <<-DOC
2-
Transform a supposed boolean to On or Off. Pass all other values through.
3-
Given a nil value (undef), bool2httpd will return 'Off'
4-
Example:
5-
$trace_enable = false
6-
$server_signature = 'mail'
7-
bool2httpd($trace_enable)
8-
# => 'Off'
9-
bool2httpd($server_signature)
10-
# => 'mail'
11-
bool2httpd(undef)
12-
# => 'Off'
2+
@summary
3+
Transform a supposed boolean to On or Off. Pass all other values through.
4+
5+
@param arg
6+
The value to be converted into a string.
7+
8+
@return
9+
Will return either `On` or `Off` if given a boolean value. Return's a string of any
10+
other given value.
11+
12+
@example
13+
$trace_enable = false
14+
$server_signature = 'mail'
15+
16+
bool2httpd($trace_enable) # returns 'Off'
17+
bool2httpd($server_signature) # returns 'mail'
18+
bool2httpd(undef) # returns 'Off'
1319
DOC
1420
) do |args|
1521
raise(Puppet::ParseError, "bool2httpd() wrong number of arguments. Given: #{args.size} for 1)") if args.size != 1

lib/puppet/parser/functions/validate_apache_log_level.rb

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
# validate_apache_log_level.rb
22
module Puppet::Parser::Functions
33
newfunction(:validate_apache_log_level, doc: <<-DOC
4-
Perform simple validation of a string against the list of known log
5-
levels as per http://httpd.apache.org/docs/current/mod/core.html#loglevel
6-
validate_apache_loglevel('info')
4+
@summary
5+
Perform simple validation of a string against the list of known log levels.
6+
7+
As per http://httpd.apache.org/docs/current/mod/core.html#loglevel
8+
* validate_apache_loglevel('info')
79
Modules maybe specified with their own levels like these:
8-
validate_apache_loglevel('warn ssl:info')
9-
validate_apache_loglevel('warn mod_ssl.c:info')
10-
validate_apache_loglevel('warn ssl_module:info')
10+
* validate_apache_loglevel('warn ssl:info')
11+
* validate_apache_loglevel('warn mod_ssl.c:info')
12+
* validate_apache_loglevel('warn ssl_module:info')
1113
Expected to be used from the main or vhost.
1214
Might be used from directory too later as apaceh supports that
15+
16+
@param log_level
17+
The string that is to be validated.
18+
19+
@return
20+
Return's an error if the validation fails.
1321
DOC
1422
) do |args|
1523
if args.size != 1

lib/puppet/provider/a2mod.rb

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# a2mod.rb
22
class Puppet::Provider::A2mod < Puppet::Provider
3+
# Fetches the mod provider
34
def self.prefetch(mods)
45
instances.each do |prov|
56
mod = mods[prov.name]
@@ -9,10 +10,12 @@ def self.prefetch(mods)
910
end
1011
end
1112

13+
# Clear's the property_hash
1214
def flush
1315
@property_hash.clear
1416
end
1517

18+
# Returns a copy of the property_hash
1619
def properties
1720
if @property_hash.empty?
1821
@property_hash = query || { ensure: :absent }
@@ -21,6 +24,7 @@ def properties
2124
@property_hash.dup
2225
end
2326

27+
# Returns the properties of the given mod if it exists.
2428
def query
2529
self.class.instances.each do |mod|
2630
if mod.name == name || mod.name.downcase == name
@@ -30,6 +34,7 @@ def query
3034
nil
3135
end
3236

37+
# Return's if the ensure property is absent or not
3338
def exists?
3439
properties[:ensure] != :absent
3540
end

manifests/balancer.pp

+31-34
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,46 @@
1-
# == Define Resource Type: apache::balancer
1+
# @summary
2+
# This type will create an apache balancer cluster file inside the conf.d
3+
# directory.
24
#
3-
# This type will create an apache balancer cluster file inside the conf.d
4-
# directory. Each balancer cluster needs one or more balancer members (that can
5+
# Each balancer cluster needs one or more balancer members (that can
56
# be declared with the apache::balancermember defined resource type). Using
67
# storeconfigs, you can export the apache::balancermember resources on all
78
# balancer members, and then collect them on a single apache load balancer
89
# server.
910
#
10-
# === Requirement/Dependencies:
11+
# @note
12+
# Currently requires the puppetlabs/concat module on the Puppet Forge and uses
13+
# storeconfigs on the Puppet Master to export/collect resources from all
14+
# balancer members.
1115
#
12-
# Currently requires the puppetlabs/concat module on the Puppet Forge and uses
13-
# storeconfigs on the Puppet Master to export/collect resources from all
14-
# balancer members.
16+
# @param name
17+
# The namevar of the defined resource type is the balancer clusters name.<br />
18+
# This name is also used in the name of the conf.d file
1519
#
16-
# === Parameters
20+
# @param proxy_set
21+
# Configures key-value pairs to be used as a ProxySet lines in the configuration.
1722
#
18-
# [*name*]
19-
# The namevar of the defined resource type is the balancer clusters name.
20-
# This name is also used in the name of the conf.d file
23+
# @param target
24+
# The path to the file the balancer definition will be written in.
2125
#
22-
# [*proxy_set*]
23-
# Hash, default empty. If given, each key-value pair will be used as a ProxySet
24-
# line in the configuration.
26+
# @param collect_exported
27+
# Determines whether to use exported resources.<br />
28+
# If you statically declare all of your backend servers, set this parameter to false to rely
29+
# on existing, declared balancer member resources. Also, use apache::balancermember with array
30+
# arguments.<br />
31+
# To dynamically declare backend servers via exported resources collected on a central node,
32+
# set this parameter to true to collect the balancer member resources exported by the balancer
33+
# member nodes.<br />
34+
# If you don't use exported resources, a single Puppet run configures all balancer members. If
35+
# you use exported resources, Puppet has to run on the balanced nodes first, then run on the
36+
# balancer.
2537
#
26-
# [*target*]
27-
# String, default undef. If given, path to the file the balancer definition will
28-
# be written.
38+
# @param options
39+
# Specifies an array of [options](https://httpd.apache.org/docs/current/mod/mod_proxy.html#balancermember)
40+
# after the balancer URL, and accepts any key-value pairs available to `ProxyPass`.
2941
#
30-
# [*collect_exported*]
31-
# Boolean, default 'true'. True means 'collect exported @@balancermember
32-
# resources' (for the case when every balancermember node exports itself),
33-
# false means 'rely on the existing declared balancermember resources' (for the
34-
# case when you know the full set of balancermembers in advance and use
35-
# apache::balancermember with array arguments, which allows you to deploy
36-
# everything in 1 run)
37-
#
38-
# [*options*]
39-
# Array, default empty. If given, additional directives may be added to the
40-
# <Proxy balancer://xyz OPTIONS> block.
41-
#
42-
# === Examples
43-
#
44-
# Exporting the resource for a balancer member:
45-
#
46-
# apache::balancer { 'puppet00': }
42+
# @example
43+
# apache::balancer { 'puppet00': }
4744
#
4845
define apache::balancer (
4946
$proxy_set = {},

manifests/balancermember.pp

+28-29
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
1-
# == Define Resource Type: apache::balancermember
2-
#
1+
# @summary
2+
# Defines members of `mod_proxy_balancer`
3+
#
4+
# Sets up a balancer member inside a listening service configuration block in
5+
# the load balancer's `apache.cfg`.
6+
#
37
# This type will setup a balancer member inside a listening service
48
# configuration block in /etc/apache/apache.cfg on the load balancer.
5-
# currently it only has the ability to specify the instance name, url and an
9+
# Currently it only has the ability to specify the instance name, url and an
610
# array of options. More features can be added as needed. The best way to
711
# implement this is to export this resource for all apache balancer member
812
# servers, and then collect them on the main apache load balancer.
913
#
10-
# === Requirement/Dependencies:
11-
#
12-
# Currently requires the puppetlabs/concat module on the Puppet Forge and
13-
# uses storeconfigs on the Puppet Master to export/collect resources
14-
# from all balancer members.
15-
#
16-
# === Parameters
17-
#
18-
# [*name*]
19-
# The title of the resource is arbitrary and only utilized in the concat
20-
# fragment name.
21-
#
22-
# [*balancer_cluster*]
23-
# The apache service's instance name (or, the title of the apache::balancer
24-
# resource). This must match up with a declared apache::balancer resource.
14+
# @note
15+
# Currently requires the puppetlabs/concat module on the Puppet Forge and
16+
# uses storeconfigs on the Puppet Master to export/collect resources
17+
# from all balancer members.
2518
#
26-
# [*url*]
27-
# The url used to contact the balancer member server.
19+
# @param name
20+
# The title of the resource is arbitrary and only utilized in the concat
21+
# fragment name.
2822
#
29-
# [*options*]
30-
# An array of options to be specified after the url.
23+
# @param balancer_cluster
24+
# The apache service's instance name (or, the title of the apache::balancer
25+
# resource). This must match up with a declared apache::balancer resource.
3126
#
32-
# === Examples
27+
# @param url
28+
# The url used to contact the balancer member server.
3329
#
34-
# Exporting the resource for a balancer member:
30+
# @param options
31+
# Specifies an array of [options](https://httpd.apache.org/docs/current/mod/mod_proxy.html#balancermember)
32+
# after the URL, and accepts any key-value pairs available to `ProxyPass`.
3533
#
36-
# @@apache::balancermember { 'apache':
37-
# balancer_cluster => 'puppet00',
38-
# url => "ajp://${::fqdn}:8009"
39-
# options => ['ping=5', 'disablereuse=on', 'retry=5', 'ttl=120'],
40-
# }
34+
# @example
35+
# @@apache::balancermember { 'apache':
36+
# balancer_cluster => 'puppet00',
37+
# url => "ajp://${::fqdn}:8009"
38+
# options => ['ping=5', 'disablereuse=on', 'retry=5', 'ttl=120'],
39+
# }
4140
#
4241
define apache::balancermember(
4342
$balancer_cluster,

manifests/confd/no_accf.pp

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# @summary
2+
# Manages the `no-accf.conf` file.
3+
#
4+
# @api private
15
class apache::confd::no_accf {
26
# Template uses no variables
37
file { 'no-accf.conf':

0 commit comments

Comments
 (0)