Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into mergeup
Browse files Browse the repository at this point in the history
  • Loading branch information
bmjen committed Jan 21, 2016
2 parents f4241b5 + ca98a14 commit 7d35d56
Show file tree
Hide file tree
Showing 27 changed files with 380 additions and 146 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
@@ -1 +1 @@
*.sh eol=lf
*.rb eol=lf
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -8,3 +8,4 @@ coverage/
.idea/
*.iml
*.swp
log/
40 changes: 26 additions & 14 deletions CHANGELOG.md
@@ -1,5 +1,20 @@
=======
##2015-06-02 - Supported Release 2.0.1
##Supported Release 1.2.5
###Summary

Small release for support of newer PE versions. This increments the version of PE in the metadata.json file.

##2015-07-21 - Supported Release 1.2.4
###Summary

This release includes some ruby path and lint fixes.

####Bugfixes
- Use correct ruby path with PE and AIO
- Lint fixes
- Use correct ruby path on FreeBSD
- Test fixes

##2015-06-02 - Supported Release 2.0.1 [YANKED]
###Summary

This is a bugfix release.
Expand All @@ -9,27 +24,24 @@ This is a bugfix release.
- Fixes handling fragment target.
- Fixes the defaulted force behavior to handle empty concats correctly.

=======
##2015-05-12 - Supported Release 2.0.0
##2015-06-02 - Supported Release 1.2.3
###Summary

This is a major release. Includes re-implementation of concat to use native Type and Providers, resulting in significantly improved performance and testability. Also includes a bugfix to alpha ordering of fragments.

####Features
- Re-implementation of concat to use native Type and Providers.
This release includes a README fix to document correct behavior of fragment target parameter.

####Bugfixes
- Fixes a bug in alpha ordering of fragments.
- README Fix to correctly document how a fragment $target param should work.

=======
##2015-06-02 - Supported Release 1.2.3
##2015-05-12 - Supported Release 2.0.0 [YANKED]
###Summary

This release includes a README fix to document correct behavior of fragment target parameter.
This is a major release. Includes re-implementation of concat to use native Type and Providers, resulting in significantly improved performance and testability. Also includes a bugfix to alpha ordering of fragments.

####Bugfixes
####Features
- Re-implementation of concat to use native Type and Providers.

- README Fix to correctly document how a fragment $target param should work.
####Bugfixes
- Fixes a bug in alpha ordering of fragments.

##2015-05-12 - Supported Release 1.2.2
###Summary
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -28,6 +28,7 @@ group :system_tests do
gem 'beaker-rspec', :require => false
end
gem 'serverspec', :require => false
gem 'beaker-puppet_install_helper', :require => false
end


Expand Down
41 changes: 40 additions & 1 deletion README.md
Expand Up @@ -134,6 +134,10 @@ All the parameters listed below are optional.

Specifies whether (and how) to back up the destination file before overwriting it. Your value gets passed on to Puppet's [native `file` resource](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-backup) for execution. Valid options: 'true', 'false', or a string representing either a target filebucket or a filename extension beginning with ".". Default value: 'puppet'.

#####`backup_fragments`

Specifies whether to backup concat fragments using the backup setting of the target concat file. Valid options: 'true' and 'false'. Default value: 'false'.

#####`ensure`

Specifies whether the destination file should exist. Setting to 'absent' tells Puppet to delete the destination file if it exists, and negates the effect of any other parameters. Valid options: 'present' and 'absent'. Default value: 'present'.
Expand Down Expand Up @@ -172,6 +176,10 @@ Specifies a destination file for the combined fragments. Valid options: a string

Specifies whether to overwrite the destination file if it already exists. Valid options: 'true' and 'false'. Default value: 'true'.

#####`show_diff`

Specifies whether to set the show_diff parameter for the file resource. Useful for hiding secrets stored in hiera from insecure reporting methods. Valid options: 'true

#####`validate_cmd`

Specifies a validation command to apply to the destination file. Requires Puppet version 3.5 or newer. Valid options: a string to be passed to a file resource. Default value: undefined.
Expand All @@ -187,9 +195,40 @@ If you set 'warn' to 'true', `concat` adds the following line with an `order` of
~~~

Before 2.0.0, this parameter would add a newline at the end of the warn
message. To improve flexibilty, this was removed. Please add it explicitely if
message. To improve flexibilty, this was removed. Please add it explicitly if
you need it.

#####`selinux_ignore_defaults`

See the `file` type's
[`selinux_ignore_defaults`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selinux_ignore_defaults)
documentention.

#####`selrange`

See the `file` type's
[`selrange`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selrange)
documentention.

#####`selrole`

See the `file` type's
[`selrole`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selrole)
documentention.

#####`seltype`

See the `file` type's
[`seltype`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-seltype)
documentention.

#####`seluser`

See the `file` type's
[`seluser`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-seluser)
documentention.


####Define: `concat::fragment`

Except where noted, all the below parameters are optional.
Expand Down
33 changes: 32 additions & 1 deletion lib/puppet/type/concat_file.rb
Expand Up @@ -81,6 +81,26 @@ def exists?
defaultto false
end

# Inherit File parameters
newparam(:selinux_ignore_defaults) do
end

newparam(:selrange) do
end

newparam(:selrole) do
end

newparam(:seltype) do
end

newparam(:seluser) do
end

newparam(:show_diff) do
end
# End file parameters

autorequire(:concat_fragment) do
catalog.resources.collect do |r|
if r.is_a?(Puppet::Type.type(:concat_fragment)) && r[:tag] == self[:tag]
Expand Down Expand Up @@ -158,7 +178,18 @@ def generate
:ensure => self[:ensure] == :absent ? :absent : :file,
}
[:path, :owner, :group, :mode, :replace, :backup].each do |param|
[:path,
:owner,
:group,
:mode,
:replace,
:backup,
:selinux_ignore_defaults,
:selrange,
:selrole,
:seltype,
:seluser,
:show_diff].each do |param|
unless self[param].nil?
file_opts[param] = self[param]
end
Expand Down
79 changes: 55 additions & 24 deletions manifests/init.pp
Expand Up @@ -16,6 +16,9 @@
# Who will own the file
# [*mode*]
# The mode of the final file
# [*show_diff*]
# Use metaparam for files to show/hide diffs for reporting when using eyaml
# secrets. Defaults to true
# [*warn*]
# Adds a normal shell style comment top of the file indicating that it is
# built by puppet.
Expand All @@ -33,34 +36,49 @@
# [*ensure_newline*]
# Specifies whether to ensure there's a new line at the end of each fragment.
# Valid options: 'true' and 'false'. Default value: 'false'.
# [*selinux_ignore_defaults*]
# [*selrange*]
# [*selrole*]
# [*seltype*]
# [*validate_cmd*]
# Specifies a validation command to apply to the destination file.
# Requires Puppet version 3.5 or newer. Valid options: a string to be passed
# to a file resource. Default value: undefined.
#

define concat(
$ensure = 'present',
$path = $name,
$owner = undef,
$group = undef,
$mode = '0644',
$warn = false,
$force = undef,
$backup = 'puppet',
$replace = true,
$order = 'alpha',
$ensure_newline = false,
$validate_cmd = undef,
$ensure = 'present',
$path = $name,
$owner = undef,
$group = undef,
$mode = '0644',
$warn = false,
$force = undef,
$show_diff = true,
$backup = 'puppet',
$replace = true,
$order = 'alpha',
$ensure_newline = false,
$validate_cmd = undef,
$selinux_ignore_defaults = undef,
$selrange = undef,
$selrole = undef,
$seltype = undef,
$seluser = undef
) {
validate_re($ensure, '^present$|^absent$')
validate_absolute_path($path)
validate_string($owner)
validate_string($group)
validate_string($mode)
if ! (is_string($owner) or is_integer($owner)) {
fail("\$owner must be a string or integer, got ${owner}")
}
if ! (is_string($group) or is_integer($group)) {
fail("\$group must be a string or integer, got ${group}")
}
if ! (is_string($warn) or $warn == true or $warn == false) {
fail('$warn is not a string or boolean')
}
validate_bool($show_diff)
if ! is_bool($backup) and ! is_string($backup) {
fail('$backup must be string or bool!')
}
Expand All @@ -75,6 +93,13 @@
if $force != undef {
warning('The $force parameter to concat is deprecated and has no effect.')
}
if $selinux_ignore_defaults {
validate_bool($selinux_ignore_defaults)
}
validate_string($selrange)
validate_string($selrole)
validate_string($seltype)
validate_string($seluser)

$safe_name = regsubst($name, '[/:\n\s\(\)]', '_', 'G')
$default_warn_message = "# This file is managed by Puppet. DO NOT EDIT.\n"
Expand All @@ -96,16 +121,22 @@

if $ensure == 'present' {
concat_file { $name:
tag => $safe_name,
path => $path,
owner => $owner,
group => $group,
mode => $mode,
replace => $replace,
backup => $backup,
order => $order,
ensure_newline => $ensure_newline,
validate_cmd => $validate_cmd,
tag => $safe_name,
path => $path,
owner => $owner,
group => $group,
mode => $mode,
selinux_ignore_defaults => $selinux_ignore_defaults,
selrange => $selrange,
selrole => $selrole,
seltype => $seltype,
seluser => $seluser,
replace => $replace,
backup => $backup,
show_diff => $show_diff,
order => $order,
ensure_newline => $ensure_newline,
validate_cmd => $validate_cmd,
}

if $_append_header {
Expand Down
10 changes: 5 additions & 5 deletions metadata.json
Expand Up @@ -7,6 +7,9 @@
"source": "https://github.com/puppetlabs/puppetlabs-concat",
"project_page": "https://github.com/puppetlabs/puppetlabs-concat",
"issues_url": "https://tickets.puppetlabs.com/browse/MODULES",
"dependencies": [
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0 < 5.0.0"}
],
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
Expand Down Expand Up @@ -97,14 +100,11 @@
"requirements": [
{
"name": "pe",
"version_requirement": ">= 3.7.0 < 4.0.0"
"version_requirement": ">= 3.7.0 < 2015.4.0"
},
{
"name": "puppet",
"version_requirement": "3.x"
"version_requirement": ">= 3.0.0 < 5.0.0"
}
],
"dependencies": [
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0 < 5.0.0"}
]
}
22 changes: 17 additions & 5 deletions spec/acceptance/concat_spec.rb
Expand Up @@ -5,28 +5,40 @@
username = 'root'
groupname = 'system'
scriptname = 'concatfragments.rb'
vardir = default['puppetvardir']
vardir = default.puppet['vardir']
if vardir.nil? or vardir == ''
vardir = '/opt/puppetlabs/puppet/cache'
end
when 'Darwin'
username = 'root'
groupname = 'wheel'
scriptname = 'concatfragments.rb'
vardir = default['puppetvardir']
vardir = default.puppet['vardir']
if vardir.nil? or vardir == ''
vardir = '/opt/puppetlabs/puppet/cache'
end
when 'windows'
username = 'Administrator'
groupname = 'Administrators'
scriptname = 'concatfragments.rb'
result = on default, "echo #{default['puppetvardir']}"
result = on default, "echo #{default.puppet['vardir']}"
vardir = result.raw_output.chomp
when 'Solaris'
username = 'root'
groupname = 'root'
scriptname = 'concatfragments.rb'
vardir = default['puppetvardir']
vardir = default.puppet['vardir']
if vardir.nil? or vardir == ''
vardir = '/opt/puppetlabs/puppet/cache'
end
else
username = 'root'
groupname = 'root'
scriptname = 'concatfragments.rb'
vardir = default['puppetvardir']
vardir = default.puppet['vardir']
if vardir.nil? or vardir == ''
vardir = '/opt/puppetlabs/puppet/cache'
end
end

describe 'basic concat test' do
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/nodesets/centos-59-x64.yml
Expand Up @@ -4,7 +4,7 @@ HOSTS:
- master
platform: el-5-x86_64
box : centos-59-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box
box_url : https://atlas.hashicorp.com/puppetlabs/boxes/centos-59-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: git
2 changes: 1 addition & 1 deletion spec/acceptance/nodesets/centos-64-x64-pe.yml
Expand Up @@ -6,7 +6,7 @@ HOSTS:
- dashboard
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
box_url : https://atlas.hashicorp.com/puppetlabs/boxes/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: pe

0 comments on commit 7d35d56

Please sign in to comment.