Version information
This version is compatible with:
- Puppet Enterprise 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
- Puppet >= 4.7.0 < 7.0.0
- , , , , ,
Start using this module
Add this module to your Puppetfile:
mod 'puppetlabs-puppet_authorization', '0.5.1'
Learn more about managing modules with a PuppetfileDocumentation
puppet_authorization
Table of Contents
- Module Description - What the module does and why it is useful
- Setup - The basics of getting started with puppet_authorization
- Usage - Configuration options and additional functionality
- Reference - An under-the-hood peek at what the module is doing and how
- Limitations - OS compatibility, etc.
- Development - Guide for contributing to the module
Module Description
The puppet_authorization module generates or changes the auth.conf file using authorization rules written as Puppet resources.
Note that this module is used only for the new auth.conf file used by Puppet Server 2.2.0 and later. If you are using the auth.conf file used by core Puppet, this module will not affect it. See Puppet Server documentation for detailed information about the auth.conf file.
This module allows you to add custom rules to your auth.conf file by writing Puppet resources that can create, modify, or remove the associated rules from the auth.conf file. It allows the auth.conf to be created entirely from Puppet code---you never have to touch the auth.conf file directly.
Setup
Beginning with puppet_authorization
Note that this section applies only to open source Puppet. In Puppet Enterprise, this resource is managed automatically.
The puppet_authorization
resource sets up the auth.conf and configures settings that apply globally, rather than being specific to individual rules.
For example, this code:
puppet_authorization { '/etc/puppetlabs/puppetserver/conf.d/auth.conf':
version => 1,
allow_header_cert_info => false
}
...would populate the following corresponding settings into the "auth.conf" file:
authorization: {
version: 1
allow-header-cert-info: false
rules: ...
}
Note that the value for rules
in this case would be set to [] if the rules
array was not yet present in the file. Otherwise, whatever value was already in the target file for rules
is preserved.
The values used above are:
version
: Currently, 1 is the only supported value and is the default.allow-header-cert-info
: Controls whether the identity of the client will be inferred from the client's SSL certificate, when false, or from special X-Client HTTP headers, when true. The default for this setting is false. See Puppet Server documentation for information about disabling HTTPS for Puppet Server andallow-header-cert-info
setting.
Usage
The following usage examples assume an empty auth.conf file that looks like this:
authorization: {
version: 1
rules: []
}
Add a rule
The main resource to use is puppet_authorization::rule
, which manages a single
rule in the authorization configuration file (auth.conf). This authorization file also
needs to be managed with a resource, which is done with puppet_authorization
.
The following declares a resource to manage the top-level structure, followed by a resource to add a rule for controlling access to the "environments" HTTP endpoint:
puppet_authorization::rule { 'environments':
match_request_path => '/puppet/v3/environments',
match_request_type => 'path',
match_request_method => 'get',
allow => 'your.special.admin',
sort_order => 300,
path => '/etc/puppetlabs/puppetserver/conf.d/auth.conf',
}
Here, we've declared that only 'your.special.admin'
can access the
/puppet/v3/environments
endpoint.
Delete a rule
Continuing from the previous example to add the "environments" rule, the following example declares a resource that removes it from the file.
puppet_authorization::rule { 'environments':
ensure => absent,
path => '/etc/puppetlabs/puppetserver/conf.d/auth.conf',
}
When removing a rule, you have only to provide the rule name and path to
the configuration file where it can be found. Since rules must have unique names,
you don't have to define the other attributes (match_request_path
, etc);
the rule with the matching name will be removed, regardless.
Configure the catalog endpoint
You can configure the catalog HTTP endpoint for Puppet Server to:
- Permit an administrative node to access the catalog for any node.
- Permit other nodes to be able to access their own catalog, but no other node’s catalog.
In this example, we'll configure the rule to apply only to requests made to the production or test directory environments in Puppet.
puppet_authorization::rule { 'catalog_request':
match_request_path => '^/puppet/v3/catalog/([^/]+)$',
match_request_type => 'regex',
match_request_method => ['get','post'],
match_request_query_params => {'environment' => [ 'production', 'test' ]},
allow => ['$1', 'adminhost.mydomain.com'],
sort_order => 200,
path => '/etc/puppetlabs/puppetserver/conf.d/auth.conf',
}
If the original auth.conf file looked like this:
authorization: {
version: 1
allow-header-cert-info: false
rules: []
}
...then it should look something like this after the new rule is applied:
authorization: {
version: 1
allow-header-cert-info: false
rules: [
{
"allow" : [
"$1",
"adminhost.mydomain.com",
],
"match-request" : {
"method" : [
"get",
"post"
],
"path" : "^/puppet/v3/catalog/([^/]+)$",
"query-params" : {
"environment" : [
"production",
"test"
]
},
"type" : "regex"
},
"name" : "catalog_request",
"sort-order" : 200
}
,
]
}
Trigger rule changes
Puppet Server does not automatically start using the new rule definitions in the auth.conf file as they are applied. Before your auth.conf file changes take effect, the Puppet Server service needs to be restarted. Add the following code to each rule resource to restart the service any time rules in the auth.conf file changes.
If you're using open source Puppet Server, add the following code to your rule resource:
notify => Service['puppetserver']
If you're using Puppet Server in PE, add:
notify => Service['pe-puppetserver']
For example, with this code added, the full rule definition might look like this:
puppet_authorization::rule { 'catalog_request':
match_request_path => '^/puppet/v3/catalog/([^/]+)$',
match_request_type => 'regex',
match_request_method => ['get','post'],
match_request_query_params => {'environment' => [ 'production', 'test' ]},
allow => ['$1', 'adminhost.mydomain.com'],
sort_order => 200,
path => '/etc/puppetlabs/puppetserver/conf.d/auth.conf',
notify => Service['pe-puppetserver'],
}
Reference
Defined Types
Providers
Defined Type: puppet_authorization
Sets up the skeleton server auth.conf file if it doesn't exist.
Parameters (all optional)
-
version
: Theauthorization.version
setting in the server auth.conf. Valid options: an integer (currently, 1 is the only supported value). Default:1
. -
allow_header_cert_info
: Theauthorization.allow-header-cert-info
setting in the server auth.conf. Valid options:true
,false
. Default:false
. -
replace
: Whether or not to replace existing file atpath
. If set to true this will cause the file to be regenerated on every puppet run. Valid options:true
,false
. Default:false
. -
path
: Absolute path for auth.conf. Defaults toname
.
Defined Type: puppet_authorization::rule
Adds individual rules to auth.conf.
Parameters (optional unless otherwise specified)
-
match_request_path
: Required. Valid options: a string. -
match_request_type
: Required. Valid options: 'path', 'regex'. -
path
: Required. The absolute path for the auth.conf file. -
ensure
: Whether to add or remove the rule. Valid options: 'present', 'absent'. Defaults to 'present'. -
rule_name
: Thename
setting for the rule. Valid options: a string. Defaults toname
. -
allow
: Theallow
setting for the rule. Cannot be set along with anallow_unauthenticated
value of true. Valid options: a hash, a string or an array of strings and/or hashes. A hash here must contain only one ofextensions
orcertname
. Defaults to undef. For more details on theallow
setting, see https://github.com/puppetlabs/trapperkeeper-authorization/blob/master/doc/authorization-config.md#allow. -
deny
: Thedeny
setting for the rule. Cannot be set along with anallow_unauthenticated
value of true. Valid options: a hash, a string or an array of strings and/or hashes. A hash here must contain only one ofextensions
orcertname
. Defaults to undef. For more details on thedeny
setting, see https://github.com/puppetlabs/trapperkeeper-authorization/blob/master/doc/authorization-config.md#deny. -
allow_unauthenticated
: Theallow_unauthenticated
setting for the rule. Cannot be set to true along withdeny
orallow
. Valid options: true, false. Defaults to false. -
match_request_method
: Themethod
setting for thematch_request
in the rule. Valid options: String or array of strings containing: 'put', 'post', 'get', 'head', 'delete'. Defaults to undef. -
match_request_query_params
: Thequery_params
setting for thematch_request
in the rule. Valid options: Hash. Defaults to {}. -
sort_order
: The sort order for the rule. Valid options: an integer. Defaults to 200.
Limitations
The auth.conf file this module writes is supported only in open source Puppet Server 2.2.0 or greater or Puppet Enterprise 2015.3.0 or greater. See (https://docs.puppetlabs.com/puppetserver/latest/config_file_auth.html) for more details about authorization in Puppet Server.
Reference
Table of Contents
Defined types
Resource types
puppet_authorization_hocon_rule
: An arbitrary name used as the identity of the resource.
Data types
Defined types
puppet_authorization
The puppet_authorization class.
Parameters
The following parameters are available in the puppet_authorization
defined type.
version
Data type: Integer
Default value: 1
allow_header_cert_info
Data type: Boolean
Default value: false
replace
Data type: Boolean
Default value: false
path
Data type: Stdlib::Absolutepath
Default value: $name
puppet_authorization::rule
The puppet_authorization::rule class.
Parameters
The following parameters are available in the puppet_authorization::rule
defined type.
match_request_path
Data type: Optional[String]
Default value: undef
match_request_type
Data type: Optional[Enum['path', 'regex']]
Default value: undef
path
Data type: Stdlib::Absolutepath
ensure
Data type: Enum['present', 'absent']
Default value: 'present'
rule_name
Data type: String
Default value: $name
allow
Data type: Variant[Array[Variant[String, Hash]], String, Hash, Undef]
Default value: undef
allow_unauthenticated
Data type: Boolean
Default value: false
deny
Data type: Variant[Array[Variant[String, Hash]], String, Hash, Undef]
Default value: undef
match_request_method
Data type: Variant[Array[Puppet_authorization::Httpmethod], Puppet_authorization::Httpmethod, Undef]
Default value: undef
match_request_query_params
Data type: Hash
Default value: {}
sort_order
Data type: Integer
Default value: 200
Resource types
puppet_authorization_hocon_rule
An arbitrary name used as the identity of the resource.
Properties
The following properties are available in the puppet_authorization_hocon_rule
type.
ensure
Valid values: present, absent
The basic property that the resource should be in.
Default value: present
value
The value of the setting to be defined.
Parameters
The following parameters are available in the puppet_authorization_hocon_rule
type.
name
namevar
An arbitrary name used as the identity of the resource.
path
The file Puppet will ensure contains the specified setting.
Data types
Puppet_authorization::Httpmethod
The Puppet_authorization::Httpmethod data type.
Alias of Enum['put', 'post', 'get', 'head', 'delete']
Change log
All notable changes to this project will be documented in this file. The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
v0.5.1 (2020-03-09)
Added
- (MODULES-10578) Add EL8 to metadata.json #32 (trevor-vaughan)
- Support puppetlabs/concat 6.x and puppetlabs/stdlib 6.x. #31 (pillarsdotnet)
At this point, the module was converted to the PDK.
Unsupported Release 0.5.0
Summary
This release increases the upper bounds of several dependencies and adds support for two new OS.
Changed
- Moved upper bound of compatible puppet from >= 6.0.0 to >= 7.0.0.
- Moved upper bound of compatible puppetlabs-stdlib from >= 5.0.0 to >= 6.0.0.
- Moved upper bound of compatible puppetlabs-concat from >= 5.0.0 to >= 6.0.0.
- Support added for Ubuntu 16.04 and 18.04.
Unsupported Release 0.4.0
Summary
This release drops outdated stdlib validate functions.
Changed
- Moved lower bound of compatible puppet from >= 4.0.0 to >= 4.7.0
Fixed
- Fixed warnings raised by old
validate_*
methods
Unsupported Release 0.3.0
Summary
Small release that updates module dependencies.
Changed
- puppetlabs-concat and puppetlabs-stdlib dependencies
Removed
- Puppet Enterprise requirement. This dependency is no longer used for modules.
Unsupported Release 0.2.0
Summary
A small release including a couple of added features and metadata/readme fixes.
Added
- Hash to data types for allow and deny rules
- support for extensions matching - updates the validation to ensure that a valid allow/deny entry has been supplied
Fixed
- the concat version dependancy
- readme updates - removed unused links also
Unsupported Release 0.1.0
Summary
This is the initial release of the module.
Features
- Manages the
auth.conf
file using authorization rules written as Puppet resources.
* This Changelog was automatically generated by github_changelog_generator
Dependencies
- puppetlabs-stdlib (>= 4.6.0 < 7.0.0)
- puppetlabs-concat (>= 1.1.1 < 7.0.0)
- puppetlabs-hocon (>= 0.9.3 < 2.0.0)