diff --git a/.fixtures.yml b/.fixtures.yml index fb0f76a..3d0f23a 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,10 +1,10 @@ fixtures: repositories: 'stdlib': repo: 'git://github.com/puppetlabs/puppetlabs-stdlib.git' ref: '4.5.1' 'file_concat': repo: 'git://github.com/electrical/puppet-lib-file_concat.git' - branch: '1.0.0' + ref: '1.0.1' symlinks: 'concat': '#{source_dir}' diff --git a/manifests/fragment.pp b/manifests/fragment.pp index fabc359..a3d42ef 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -1,55 +1,55 @@ # == Define: concat::fragment # # Creates a file_fragment in the catalogue # # === Options: # # [*target*] # The file that these fragments belong to # [*content*] # If present puts the content into the file # [*source*] # If content was not specified, use the source # [*order*] # By default all files gets a 10_ prefix in the directory you can set it to # anything else using this to influence the order of the content in the file # define concat::fragment( $target, $ensure = undef, $content = undef, $source = undef, $order = '10', ) { validate_string($target) if $ensure != undef { warning('The $ensure parameter to concat::fragment is deprecated and has no effect.') } validate_string($content) if !(is_string($source) or is_array($source)) { fail('$source is not a string or an Array.') } if !(is_string($order) or is_integer($order)) { fail('$order is not a string or integer.') } elsif (is_string($order) and $order =~ /[:\n\/]/) { fail("Order cannot contain '/', ':', or '\n'.") } if ! ($content or $source) { crit('No content, source or symlink specified') } elsif ($content and $source) { fail("Can't use 'source' and 'content' at the same time") } - $safe_target_name = regsubst($target, '[/:\n\s]', '_', 'GM') + $safe_target_name = regsubst($target, '[/:\n\s\\]', '_', 'GM') file_fragment { $name: tag => $safe_target_name, order => $order, content => $content, source => $source, } } diff --git a/manifests/init.pp b/manifests/init.pp index 981a5c2..69dc46e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,123 +1,123 @@ # == Define: concat # # Sets up so that you can use fragments to build a final config file, # # === Options: # # [*ensure*] # Present/Absent # [*path*] # The path to the final file. Use this in case you want to differentiate # between the name of a resource and the file path. Note: Use the name you # provided in the target of your fragments. # [*owner*] # Who will own the file # [*group*] # Who will own the file # [*mode*] # The mode of the final file # [*warn_header*] # Adds a normal shell style comment top of the file indicating that it is # built by puppet # [*backup*] # Controls the filebucketing behavior of the final file and see File type # reference for its use. Defaults to 'puppet' # [*replace*] # Whether to replace a file that already exists on the local system # [*order*] # Select whether to order associated fragments by 'alpha' or 'numeric'. # Defaults to 'alpha'. # # === Actions: # * Creates a file_concat resource from the electrical/puppet-lib-file_concat library. # * Creates file_fragment resources from electrical/puppet-lib-file_concat # # === Aliases: # # * The exec can notified using Exec["concat_/path/to/file"] or # Exec["concat_/path/to/directory"] # * The final file can be referenced as File["/path/to/file"] or # File["concat_/path/to/file"] # define concat( $ensure = 'present', $path = $name, $owner = undef, $group = undef, $mode = '0644', $warn = false, $force = undef, $backup = 'puppet', $replace = true, $order = 'alpha', $validate_cmd = undef, ) { validate_re($ensure, '^present$|^absent$') validate_absolute_path($path) validate_string($owner) validate_string($group) validate_string($mode) if ! (is_string($warn) or $warn == true or $warn == false) { fail('$warn is not a string or boolean') } if ! is_bool($backup) and ! is_string($backup) { fail('$backup must be string or bool!') } validate_bool($replace) validate_re($order, '^alpha$|^numeric$') if $validate_cmd and ! is_string($validate_cmd) { fail('$validate_cmd must be a string') } if $force != undef { warning('The $force parameter to concat is deprecated and has no effect.') } - $safe_name = regsubst($name, '[/:\n\s]', '_', 'G') + $safe_name = regsubst($name, '[/:\n\s\\]', '_', 'G') $default_warn_message = "# This file is managed by Puppet. DO NOT EDIT.\n" case $warn { true: { $warn_message = $default_warn_message $append_header = true } false: { $warn_message = '' } default: { $warn_message = $warn $append_header = true } } if $ensure == 'present' { file_concat { $name: tag => $safe_name, path => $path, owner => $owner, group => $group, mode => $mode, replace => $replace, backup => $backup, order => $order, validate_cmd => $validate_cmd, } if $append_header { file_fragment { "#{$name}_header": tag => $safe_name, content => $warn_message, order => '0', } } } else { file_concat { $name: ensure => $ensure, tag => $safe_name, path => $path, backup => $backup, } } } diff --git a/metadata.json b/metadata.json index e4688ec..137499e 100644 --- a/metadata.json +++ b/metadata.json @@ -1,111 +1,111 @@ { "name": "puppetlabs-concat", "version": "2.0.0", "author": "Puppet Labs", "summary": "Construct files from multiple fragments.", "license": "Apache-2.0", "source": "https://github.com/puppetlabs/puppetlabs-concat", "project_page": "https://github.com/puppetlabs/puppetlabs-concat", "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "SLES", "operatingsystemrelease": [ "10 SP4", "11 SP1", "12" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] }, { "operatingsystem": "Solaris", "operatingsystemrelease": [ "10", "11" ] }, { "operatingsystem": "Windows", "operatingsystemrelease": [ "Server 2003 R2", "Server 2008 R2", "Server 2012", "Server 2012 R2" ] }, { "operatingsystem": "AIX", "operatingsystemrelease": [ "5.3", "6.1", "7.1" ] }, { "operatingsystem": "OSX", "operatingsystemrelease": [ "10.9" ] } ], "requirements": [ { "name": "pe", "version_requirement": "3.x" }, { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [ {"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0 < 5.0.0"}, - {"name":"electrical/file_concat","version_requirement":">= 1.0.0"} + {"name":"electrical/file_concat","version_requirement":">= 1.0.1"} ] } diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 1a3ffc0..80aa2f7 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,69 +1,69 @@ require 'beaker-rspec/spec_helper' require 'beaker-rspec/helpers/serverspec' require 'acceptance/specinfra_stubs' unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' # 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'} if default.is_pe?; then install_pe; else install_puppet(foss_opts); end hosts.each do |host| on hosts, "mkdir -p #{host['distmoduledir']}" if host['platform'] =~ /sles-1/i || host['platform'] =~ /solaris-1/i get_deps = <<-EOS package{'wget':} exec{'download-stdlib': command => "wget -P /root/ https://forgeapi.puppetlabs.com/v3/files/puppetlabs-stdlib-4.5.1.tar.gz --no-check-certificate", path => ['/opt/csw/bin/','/usr/bin/'] } exec{'download-file_concat': - command => "wget -P /root/ https://forgeapi.puppetlabs.com/v3/files/electrical-file_concat-1.0.0.tar.gz --no-check-certificate", + command => "wget -P /root/ https://forgeapi.puppetlabs.com/v3/files/electrical-file_concat-1.0.1.tar.gz --no-check-certificate", path => ['/opt/csw/bin/','/usr/bin/'] } EOS apply_manifest_on(host, get_deps) # have to use force otherwise it checks ssl cert even though it is a local file on host, puppet('module install /root/puppetlabs-stdlib-4.5.1.tar.gz --force --ignore-dependencies'), {:acceptable_exit_codes => [0, 1]} - on host, puppet('module install /root/electrical-file_concat-1.0.0.tar.gz --force --ignore-dependencies'), {:acceptable_exit_codes => [0, 1]} + on host, puppet('module install /root/electrical-file_concat-1.0.1.tar.gz --force --ignore-dependencies'), {:acceptable_exit_codes => [0, 1]} elsif host['platform'] =~ /windows/i on host, shell('curl -k -o c:/puppetlabs-stdlib-4.5.1.tar.gz https://forgeapi.puppetlabs.com/v3/files/puppetlabs-stdlib-4.5.1.tar.gz') on host, puppet('module install c:/puppetlabs-stdlib-4.5.1.tar.gz --force --ignore-dependencies'), {:acceptable_exit_codes => [0, 1]} - on host, shell('curl -k -o c:/electrical-file_concat-1.0.0.tar.gz https://forgeapi.puppetlabs.com/v3/files/electrical-file_concat-1.0.0.tar.gz') + on host, shell('curl -k -o c:/electrical-file_concat-1.0.1.tar.gz https://forgeapi.puppetlabs.com/v3/files/electrical-file_concat-1.0.1.tar.gz') on host, puppet('module install c:/electrical-file_concat-1.0.0.tar.gz --force --ignore-dependencies'), {:acceptable_exit_codes => [0, 1]} else on host, puppet('module install puppetlabs-stdlib'), {:acceptable_exit_codes => [0, 1]} on host, puppet('module install electrical-file_concat'), {:acceptable_exit_codes => [0, 1]} end end end RSpec.configure do |c| # Project root proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) # Readable test descriptions c.formatter = :documentation # Configure all nodes in nodeset c.before :suite do hosts.each do |host| copy_module_to(host, :source => proj_root, :module_name => 'concat') end end c.before(:all) do shell('mkdir -p /tmp/concat') end c.after(:all) do shell('rm -rf /tmp/concat /var/lib/puppet/concat') end c.treat_symbols_as_metadata_keys_with_true_values = true end