Mercurial > repos > other > Puppet
changeset 479:162dc4376331
Remove unused modules
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Thu, 29 Aug 2024 18:48:03 +0100 |
parents | adf6fe9bbc17 |
children | 2c3e745be8d2 |
files | modules/common/CHANGELOG modules/common/Gemfile modules/common/LICENSE modules/common/README.md modules/common/Rakefile modules/common/checksums.json modules/common/lib/puppet/parser/functions/interface2factname.rb modules/common/lib/puppet/parser/functions/strip_file_extension.rb modules/common/manifests/init.pp modules/common/manifests/mkdir_p.pp modules/common/manifests/mkuser.pp modules/common/manifests/remove_if_empty.pp modules/common/metadata.json modules/common/spec/classes/init_spec.rb modules/common/spec/classes/mkuser_use_cases_spec.rb modules/common/spec/defines/mkdir_p_spec.rb modules/common/spec/defines/mkuser_spec.rb modules/common/spec/defines/remove_if_empty_spec.rb modules/common/spec/functions/interface2factname_spec.rb modules/common/spec/functions/strip_file_extension_spec.rb modules/common/spec/spec_helper.rb modules/common/tests/init.pp modules/translate/CHANGELOG.md modules/translate/CONTRIBUTING.md modules/translate/Gemfile modules/translate/HISTORY.md modules/translate/LICENSE modules/translate/MAINTAINERS.md modules/translate/NOTICE modules/translate/README.md modules/translate/REFERENCE.md modules/translate/Rakefile modules/translate/checksums.json modules/translate/distelli-manifest.yml modules/translate/lib/puppet/functions/translate.rb modules/translate/locales/config.yaml modules/translate/metadata.json modules/translate/provision.yaml modules/translate/spec/acceptance/spec_helper_acceptance.rb modules/translate/spec/acceptance/translate_spec.rb modules/translate/spec/default_facts.yml modules/translate/spec/functions/translate_spec.rb modules/translate/spec/spec_helper.rb modules/translate/spec/spec_helper_local.rb |
diffstat | 44 files changed, 0 insertions(+), 3183 deletions(-) [+] |
line wrap: on
line diff
--- a/modules/common/CHANGELOG Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -1.0.0 - 2013-05-24 - -Add spec tests and become viable for first major release. - -Albin Gustavsson - 2ef8ddb Removed some commented out code from the spec tests - d8fd795 Added spec testing for functions and defines - 558a99f Added spec testing for common::mkuser - -Garrett Honeycutt - 21c7d9a Ensure all modules are listed in README - 49f726d Add facter to .gemfile - fd2a905 Test for both attributes of mkdir_p with a variable - 81067a2 Travis - fix allowed failure for 2.7.x - 556d1be Travis - test against Puppet 3.2.1 and display graphic in README - 676bdeb Travis - remove 2.6.9 testing and test 3.x - c64244c Add travis-ci.org support - 419e530 Split mkuser testing into its own file and clarify usernames. - 93beb4f Add spec tests - -0.0.1 - 2013-05-12 Garrett Honeycutt <code@garretthoneycutt.com> -* Rework of some old code such that no action is taken by default
--- a/modules/common/Gemfile Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -source ENV['GEM_SOURCE'] || 'https://rubygems.org' - -if puppetversion = ENV['PUPPET_GEM_VERSION'] - gem 'puppet', puppetversion, :require => false -else - gem 'puppet', :require => false -end - -gem 'facter', '>= 2.2.0' -gem 'rspec-puppet', '~> 2.0' -gem 'puppet-lint' -gem 'puppet-lint-absolute_classname-check' -gem 'puppet-lint-alias-check' -gem 'puppet-lint-empty_string-check' -gem 'puppet-lint-file_ensure-check' -gem 'puppet-lint-file_source_rights-check' -gem 'puppet-lint-leading_zero-check' -gem 'puppet-lint-spaceship_operator_without_tag-check' -gem 'puppet-lint-trailing_comma-check' -gem 'puppet-lint-undef_in_function-check' -gem 'puppet-lint-unquoted_string-check' -gem 'puppet-lint-variable_contains_upcase' - -gem 'rspec', '~> 2.0' if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9' -gem 'rake', '~> 10.0' if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9' -gem 'json', '<= 1.8' if RUBY_VERSION < '2.0.0' -gem 'json_pure', '<= 2.0.1' if RUBY_VERSION < '2.0.0' -gem 'metadata-json-lint', '0.0.11' if RUBY_VERSION <= '1.9.3' -gem 'metadata-json-lint' if RUBY_VERSION > '1.9.3' -gem 'public_suffix', '~> 1.1.0' if RUBY_VERSION < '2.1.1' && RUBY_VERSION >= '1.9' -gem 'public_suffix', '1.3.0' if RUBY_VERSION < '1.9' - -gem 'puppetlabs_spec_helper', '2.0.2', :require => false if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9' -gem 'puppetlabs_spec_helper', '>= 2.0.0', :require => false if RUBY_VERSION >= '1.9' -gem 'parallel_tests', '<= 2.9.0', :require => false if RUBY_VERSION < '2.0.0' && RUBY_VERSION >= '1.9' -gem 'parallel_tests', '1.0.9', :require => false if RUBY_VERSION < '1.9' -gem 'parallel', '1.3.3.1', :require => false if RUBY_VERSION < '1.9' - -if puppetversion && puppetversion < '5.0' && RUBY_VERSION >= '2.1.9' - gem 'semantic_puppet', :require => false -end
--- a/modules/common/LICENSE Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -Copyright (C) 2007-2020 Garrett Honeycutt <code@garretthoneycutt.com> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.
--- a/modules/common/README.md Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,377 +0,0 @@ -# puppet-module-common # - -[![Build Status]( -https://api.travis-ci.org/ghoneycutt/puppet-module-common.png?branch=master)](https://travis-ci.org/ghoneycutt/puppet-module-common) - -common module to be applied to **ALL** nodes - -# Compatibility # - -Module is generic enough to work on any system, though the individual modules that it could potentially include could be very platform specific. - -=== - -# Common class # -Optionally include classes that are common to all systems, such as `dnsclient`, `ntp`, `puppet::agent`, and `vim`. By default we do not take any action, so you must enable the classes. This should be done in Hiera such as the following example. Ideally you would do this in your least specific level of hiera (often times labeled as 'common' or 'global') and potentially override at other levels. - -<pre> ---- -common::manage_root_password: true -common::enable_dnsclient: true -common::enable_ntp: true -common::enable_puppet_agent: true -common::enable_vim: true -</pre> - -## Parameters for class `common`## - -users ------ -Hash of users to ensure with common::mkusers - -- *Default*: undef - -groups ------- -Hash of groups to ensure - -- *Default*: undef - -manage_root_password --------------------- - -- *Default*: false - -root_password -------------- - -- *Default*: MD5 crypt of `puppet` - -create_opt_lsb_provider_name_dir --------------------------------- -Boolean to ensure `/opt/${lsb_provider_name}` - -- *Default*: false - -lsb_provider_name ------------------ -LSB Provider Name as assigned by LANANA - [http://www.lanana.org/lsbreg/providers/index.html](http://www.lanana.org/lsbreg/providers/index.html) - -- *Default*: `UNSET` - -enable_dnsclient ----------------- -Boolean to include ghoneycutt/dnsclient - -- *Default*: false - -enable_hosts ------------- -Boolean to include ghoneycutt/hosts - -- *Default*: false - -enable_inittab --------------- -Boolean to include ghoneycutt/inittab - -- *Default*: false - -enable_mailaliases ------------------- -Boolean to include ghoneycutt/mailaliases - -- *Default*: false - -enable_motd ------------ -Boolean to include ghoneycutt/motd - -- *Default*: false - -enable_network --------------- -Boolean to include ghoneycutt/network - -- *Default*: false - -enable_nsswitch ---------------- -Boolean to include ghoneycutt/nsswitch - -- *Default*: false - -enable_ntp ----------- -Boolean to include ghoneycutt/ntp - -- *Default*: false - -enable_pam ----------- -Boolean to include ghoneycutt/pam - -- *Default*: false - -enable_puppet_agent -------------------- -Boolean to include ghoneycutt/puppet::agent - -- *Default*: false - -enable_rsyslog --------------- -Boolean to include ghoneycutt/rsyslog - -- *Default*: false - -enable_selinux --------------- -Boolean to include ghoneycutt/selinux - -- *Default*: false - -enable_ssh ----------- -Boolean to include ghoneycutt/ssh - -- *Default*: false - -enable_utils ------------- -Boolean to include ghoneycutt/utils - -- *Default*: false - -enable_vim ----------- -Boolean to include ghoneycutt/vim - -- *Default*: false - -enable_wget ------------ -Boolean to include ghoneycutt/wget - -- *Default*: false - -### includes classes based on `osfamily` fact ### - -enable_debian ------------ -Boolean to include ghoneycutt/debian - -- *Default*: false - -enable_redhat ------------ -Boolean to include ghoneycutt/redhat - -- *Default*: false - -enable_solaris ------------ -Boolean to include ghoneycutt/solaris - -- *Default*: false - -enable_suse ------------ -Boolean to include ghoneycutt/suse - -- *Default*: false - -=== - -# common::mkdir_p define # -Provide `mkdir -p` functionality for a directory. - -Used in conjunction with a file resource. - -## Example usage: ## -<pre> -common::mkdir_p { '/some/dir/structure': } - -file { '/some/dir/structure': - ensure => directory, - require => Common::Mkdir_p['/some/dir/structure'], -} -</pre> - -## Parameters for `common::mkdir_p` define ## - -None. - -=== - -# common::remove_if_empty define # -Removes a file if it exists and is empty. - -## Example usage: ## -<pre> -common::remove_if_empty { '/path/to/potentially_empty_file': } -</pre> - -## Parameters for `common::remove_if_empty` define ## - -None. - -=== - -# common::mkuser define # -Ensures user/groups - -## Usage ## -You can specify hash each for users and groups and use Hiera to manage them. - -This example uses the YAML backend, though that is not mandatory. - -In Hiera's hierarchy add two levels, `users`, and `groups` such as the following example. - -`hiera.yaml` -<pre> ---- -:backends: - - yaml -:hierarchy: - - fqdn/%{fqdn} - - users - - groups - - %{environment} - - common -:yaml: - :datadir: -</pre> - -`users.yaml` -<pre> ---- -common::users: - gh: - uid: "30000" - comment: "Garrett Honeycutt" - groups: admin - ssh_auth_key: ssh-public-key -</pre> - -`groups.yaml` -<pre> ---- -common::groups: - admin: - gid: "32000" -</pre> - - -## Parameters for `common::mkuser` define ## - -uid ---- -String - UID of user - -- *Required* - -gid ---- -String - GID of user - -- *Default*: `$uid` - -name ----- -String - username - -group ------ -String - group name of user - -- *Default*: `$name` - -shell ------ -String - user's shell - -- *Default*: '/bin/bash' - -home ------- -String - home directory - -- *Default*: `/home/${username}` - -ensure ------- -Present or Absent - -- *Default*: present - -managehome ----------- -Boolean for manage home attribute of user resource - -- *Default*: true - -manage_dotssh -------------- -Boolean to optionally create `~/.ssh` directory - -- *Default*: true - -comment -------- -String - GECOS field for passed - -- *Default*: 'created via puppet' - -groups ------- -Array - additional groups the user should be associated with - -- *Default*: undef - -password --------- -String - password crypt for user - -- *Default*: '!!' - -mode ----- -String - mode of home directory - -- *Default*: 0700 - -ssh_auth_key ------------------ -String - The ssh key for the user - -- *Default*: undef - -ssh_auth_key_type ------------------ -String - Anything that the ssh_authorized_key resource can take for the type attribute, such as `ssh-dss` or `ssh-rsa`. - -- *Default*: 'ssh-dss' - -purge_ssh_keys ------------------ -Boolean - Purge any keys that aren’t managed as ssh_authorized_key resources. As this parameter was introduced with Puppet 3.6, -it will only work with Puppet >= 3.6. On earlier version this parameter will be silently ignored. - - -- *Default*: false - -=== - -# Functions # - -## interface2factname() ## -Takes one argument, the interface name, and returns it formatted for use with facter. - -Example: `interface2factname('bond0:0')` would return `ipaddress_bond0_0`. - -## strip_file_extension() ## -Takes two arguments, a file name which can include the path, and the extension to be removed. Returns the file name without the extension as a string. - -Example: `strip_file_extension('myapp.war','war')` would return `myapp`. -
--- a/modules/common/Rakefile Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' -PuppetLint.configuration.send('disable_80chars') -PuppetLint.configuration.send('disable_140chars') -PuppetLint.configuration.relative = true -PuppetLint.configuration.ignore_paths = ['spec/**/*.pp', 'pkg/**/*.pp', 'vendor/**/*.pp'] - -desc 'Validate manifests, templates, and ruby files' -task :validate do - Dir['spec/**/*.rb', 'lib/**/*.rb'].each do |ruby_file| - sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/ - end - Dir['files/**/*.sh'].each do |shell_script| - sh "bash -n #{shell_script}" - end -end
--- a/modules/common/checksums.json Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -{ - "CHANGELOG": "9d9dbf369b52edf7b6264fa51e59ed2e", - "Gemfile": "abaa884ee8a4c85f81ac9e7820d4424d", - "LICENSE": "62044e17123096d332a8be8ffdbaa01a", - "README.md": "8c5408dad2bea307610e131a7ab97bcb", - "Rakefile": "36b2f69bac69998352ee24ce8b8270a5", - "lib/puppet/parser/functions/interface2factname.rb": "fb5ab2ed1ffe64de903a34b337a4102d", - "lib/puppet/parser/functions/strip_file_extension.rb": "7b9d678e8346e044ab05f208e602ffb0", - "manifests/init.pp": "4f5b33941d784c1ce1e923e404032e8b", - "manifests/mkdir_p.pp": "cb3b9916ad43f66b8734249323bffc87", - "manifests/mkuser.pp": "7e7b652cd0b89c50c07d10952f9be6c4", - "manifests/remove_if_empty.pp": "305f39a2cc3bd2653cb8ca6520e31788", - "metadata.json": "0d0fe8b97d8af745fc0a492fb2553f64", - "spec/classes/init_spec.rb": "25be7248db2412adf4f5b1b9fb968251", - "spec/classes/mkuser_use_cases_spec.rb": "7201f2bec9cdac5826b285241140da5b", - "spec/defines/mkdir_p_spec.rb": "3a6b8db7f2860eefbf31ef22400ea84a", - "spec/defines/mkuser_spec.rb": "d1c659770f960997f58c32c1683d51da", - "spec/defines/remove_if_empty_spec.rb": "6e18465a4f78263d4ca47c04f41497ef", - "spec/functions/interface2factname_spec.rb": "afee2b300871c5ead9e5bddb55bfa9b6", - "spec/functions/strip_file_extension_spec.rb": "58809e0c56e0e8237c9010d306081831", - "spec/spec_helper.rb": "63a6a4e0cb806d5f46095edb8bb4c08f", - "tests/init.pp": "c1c9f68a35b8bd5a6147341c0eed884b" -} \ No newline at end of file
--- a/modules/common/lib/puppet/parser/functions/interface2factname.rb Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:interface2factname, :type => :rvalue, :doc => <<-EOS - Takes one argument, the interface name, and returns it formatted for use - with facter. Example: interface2factname(bond0:0) would return 'ipaddress_bond0_0' - EOS - ) do |args| - - raise(Puppet::ParseError, "interface2factname(): Wrong number of arguments " + - "given (#{args.size} for 1)") if args.size != 1 - - interface = "ipaddress_#{args[0]}" - interface.gsub(/[^a-z0-9_]/i, '_') - end -end
--- a/modules/common/lib/puppet/parser/functions/strip_file_extension.rb Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -module Puppet::Parser::Functions - newfunction(:strip_file_extension, :type => :rvalue, :doc => <<-EOS - Takes two arguments, a file name which can include the path, and the - extension to be removed. Returns the file name without the extension - as a string. - EOS - ) do |args| - - raise(Puppet::ParseError, "strip_file_extension(): Wrong number of arguments " + - "given (#{args.size} for 2)") if args.size != 2 - - filename = args[0] - - # allow the extension to optionally start with a period. - if args[1] =~ /^\./ - extension = args[1] - else - extension = ".#{args[1]}" - end - - File.basename(filename,extension) - end -end
--- a/modules/common/manifests/init.pp Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,312 +0,0 @@ -# == Class: common -# -# This class is applied to *ALL* nodes -# -# === Copyright -# -# Copyright 2013 GH Solutions, LLC -# -class common ( - $users = undef, - $groups = undef, - $manage_root_password = false, - $root_password = '$1$cI5K51$dexSpdv6346YReZcK2H1k.', # puppet - $create_opt_lsb_provider_name_dir = false, - $lsb_provider_name = 'UNSET', - $enable_dnsclient = false, - $enable_hosts = false, - $enable_inittab = false, - $enable_mailaliases = false, - $enable_motd = false, - $enable_network = false, - $enable_nsswitch = false, - $enable_ntp = false, - $enable_pam = false, - $enable_puppet_agent = false, - $enable_rsyslog = false, - $enable_selinux = false, - $enable_ssh = false, - $enable_utils = false, - $enable_vim = false, - $enable_wget = false, - # include classes based on osfamily fact - $enable_debian = false, - $enable_redhat = false, - $enable_solaris = false, - $enable_suse = false, -) { - - # validate type and convert string to boolean if necessary - if is_string($enable_dnsclient) { - $dnsclient_enabled = str2bool($enable_dnsclient) - } else { - $dnsclient_enabled = $enable_dnsclient - } - if $dnsclient_enabled == true { - include ::dnsclient - } - - # validate type and convert string to boolean if necessary - if is_string($enable_hosts) { - $hosts_enabled = str2bool($enable_hosts) - } else { - $hosts_enabled = $enable_hosts - } - if $hosts_enabled == true { - include ::hosts - } - - # validate type and convert string to boolean if necessary - if is_string($enable_inittab) { - $inittab_enabled = str2bool($enable_inittab) - } else { - $inittab_enabled = $enable_inittab - } - if $inittab_enabled == true { - include ::inittab - } - - # validate type and convert string to boolean if necessary - if is_string($enable_mailaliases) { - $mailaliases_enabled = str2bool($enable_mailaliases) - } else { - $mailaliases_enabled = $enable_mailaliases - } - if $mailaliases_enabled == true { - include ::mailaliases - } - - # validate type and convert string to boolean if necessary - if is_string($enable_mailaliases) { - $motd_enabled = str2bool($enable_motd) - } else { - $motd_enabled = $enable_motd - } - if $motd_enabled == true { - include ::motd - } - - # validate type and convert string to boolean if necessary - if is_string($enable_network) { - $network_enabled = str2bool($enable_network) - } else { - $network_enabled = $enable_network - } - if $network_enabled == true { - include ::network - } - - # validate type and convert string to boolean if necessary - if is_string($enable_nsswitch) { - $nsswitch_enabled = str2bool($enable_nsswitch) - } else { - $nsswitch_enabled = $enable_nsswitch - } - if $nsswitch_enabled == true { - include ::nsswitch - } - - # validate type and convert string to boolean if necessary - if is_string($enable_ntp) { - $ntp_enabled = str2bool($enable_ntp) - } else { - $ntp_enabled = $enable_ntp - } - if $ntp_enabled == true { - include ::ntp - } - - # validate type and convert string to boolean if necessary - if is_string($enable_pam) { - $pam_enabled = str2bool($enable_pam) - } else { - $pam_enabled = $enable_pam - } - if $pam_enabled == true { - include ::pam - } - - # validate type and convert string to boolean if necessary - if is_string($enable_puppet_agent) { - $puppet_agent_enabled = str2bool($enable_puppet_agent) - } else { - $puppet_agent_enabled = $enable_puppet_agent - } - if $puppet_agent_enabled == true { - include ::puppet::agent - } - - # validate type and convert string to boolean if necessary - if is_string($enable_rsyslog) { - $rsyslog_enabled = str2bool($enable_rsyslog) - } else { - $rsyslog_enabled = $enable_rsyslog - } - if $rsyslog_enabled == true { - include ::rsyslog - } - - # validate type and convert string to boolean if necessary - if is_string($enable_selinux) { - $selinux_enabled = str2bool($enable_selinux) - } else { - $selinux_enabled = $enable_selinux - } - if $selinux_enabled == true { - include ::selinux - } - - # validate type and convert string to boolean if necessary - if is_string($enable_ssh) { - $ssh_enabled = str2bool($enable_ssh) - } else { - $ssh_enabled = $enable_ssh - } - if $ssh_enabled == true { - include ::ssh - } - - # validate type and convert string to boolean if necessary - if is_string($enable_utils) { - $utils_enabled = str2bool($enable_utils) - } else { - $utils_enabled = $enable_utils - } - if $utils_enabled == true { - include ::utils - } - - # validate type and convert string to boolean if necessary - if is_string($enable_vim) { - $vim_enabled = str2bool($enable_vim) - } else { - $vim_enabled = $enable_vim - } - if $vim_enabled == true { - include ::vim - } - - # validate type and convert string to boolean if necessary - if is_string($enable_wget) { - $wget_enabled = str2bool($enable_wget) - } else { - $wget_enabled = $enable_wget - } - if $wget_enabled == true { - include ::wget - } - - # only allow supported OS's - case $::osfamily { - 'debian': { - # validate type and convert string to boolean if necessary - if is_string($enable_debian) { - $debian_enabled = str2bool($enable_debian) - } else { - $debian_enabled = $enable_debian - } - if $debian_enabled == true { - include ::debian - } - } - 'redhat': { - # validate type and convert string to boolean if necessary - if is_string($enable_redhat) { - $redhat_enabled = str2bool($enable_redhat) - } else { - $redhat_enabled = $enable_redhat - } - if $redhat_enabled == true { - include ::redhat - } - } - 'solaris': { - # validate type and convert string to boolean if necessary - if is_string($enable_solaris) { - $solaris_enabled = str2bool($enable_solaris) - } else { - $solaris_enabled = $enable_solaris - } - if $solaris_enabled == true { - include ::solaris - } - } - 'suse': { - # validate type and convert string to boolean if necessary - if is_string($enable_suse) { - $suse_enabled = str2bool($enable_suse) - } else { - $suse_enabled = $enable_suse - } - if $suse_enabled == true { - include ::suse - } - } - default: { - fail("Supported OS families are Debian, RedHat, Solaris, and Suse. Detected osfamily is ${::osfamily}.") - } - } - - # validate type and convert string to boolean if necessary - if is_string($manage_root_password) { - $manage_root_password_real = str2bool($manage_root_password) - } else { - $manage_root_password_real = $manage_root_password - } - - if $manage_root_password_real == true { - - # validate root_password - fail if not a string - if !is_string($root_password) { - fail('common::root_password is not a string.') - } - - user { 'root': - password => $root_password, - } - } - - # validate type and convert string to boolean if necessary - if is_string($create_opt_lsb_provider_name_dir) { - $create_opt_lsb_provider_name_dir_real = str2bool($create_opt_lsb_provider_name_dir) - } else { - $create_opt_lsb_provider_name_dir_real = $create_opt_lsb_provider_name_dir - } - - if $create_opt_lsb_provider_name_dir_real == true { - - # validate lsb_provider_name - fail if not a string - if !is_string($lsb_provider_name) { - fail('common::lsb_provider_name is not a string.') - } - - if $lsb_provider_name != 'UNSET' { - - # basic filesystem requirements - file { "/opt/${lsb_provider_name}": - ensure => directory, - owner => 'root', - group => 'root', - mode => '0755', - } - } - } - - if $users != undef { - - # Create virtual user resources - create_resources('@common::mkuser',$common::users) - - # Collect all virtual users - Common::Mkuser <||> # lint:ignore:spaceship_operator_without_tag - } - - if $groups != undef { - - # Create virtual group resources - create_resources('@group',$common::groups) - - # Collect all virtual groups - Group <||> # lint:ignore:spaceship_operator_without_tag - } -}
--- a/modules/common/manifests/mkdir_p.pp Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -# == Define: common::mkdir_p -# -# Provide `mkdir -p` functionality for a directory -# -# Idea is to use this mkdir_p in conjunction with a file resource -# -# Example usage: -# -# common::mkdir_p { '/some/dir/structure': } -# -# file { '/some/dir/structure': -# ensure => directory, -# require => Common::Mkdir_p['/some/dir/structure'], -# } -# -define common::mkdir_p () { - - validate_absolute_path($name) - - exec { "mkdir_p-${name}": - command => "mkdir -p ${name}", - unless => "test -d ${name}", - path => '/bin:/usr/bin', - } -}
--- a/modules/common/manifests/mkuser.pp Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,203 +0,0 @@ -# == Define: common::mkuser -# -# mkuser creates a user/group that can be realized in the module that employs it -# -# Copyright 2007-2013 Garrett Honeycutt -# contact@garretthoneycutt.com - Licensed GPLv2 -# -# Parameters: -# $uid - UID of user -# $gid - GID of user, defaults to UID -# $group - group name of user, defaults to username -# $shell - user's shell, defaults to '/bin/bash' -# $home - home directory, defaults to /home/<username> -# $ensure - present by default -# $managehome - true by default -# $manage_dotssh - true by default. creates ~/.ssh -# $comment - comment field for passwd -# $groups - additional groups the user should be associated with -# $password - defaults to '!!' -# $mode - mode of home directory, defaults to 0700 -# $ssh_auth_key - ssh key of the user -# $ssh_auth_key_type - defaults to 'ssh-dss' -# -# Actions: creates a user/group -# -# Requires: -# $uid -# -# Sample Usage: -# # create apachehup user and realize it -# @mkuser { 'apachehup': -# uid => '32001', -# home => '/home/apachehup', -# comment => 'Apache Restart User', -# } # @mkuser -# -# realize Common::Mkuser[apachehup] -# -define common::mkuser ( - $uid, - $gid = undef, - $group = undef, - $shell = undef, - $home = undef, - $ensure = 'present', - $managehome = true, - $manage_dotssh = true, - $comment = 'created via puppet', - $groups = undef, - $password = undef, - $mode = undef, - $ssh_auth_key = undef, - $create_group = true, - $ssh_auth_key_type = undef, - $purge_ssh_keys = undef, -) { - - if $shell { - $myshell = $shell - } else { - $myshell = '/bin/bash' - } - - # if gid is unspecified, match with uid - if $gid { - $mygid = $gid - } else { - $mygid = $uid - } # fi $gid - - # if groups is unspecified, match with name - if $groups { - $mygroups = $groups - } else { - $mygroups = $name - } - - # if group is unspecified, use the username - if $group { - $mygroup = $group - } else { - $mygroup = $name - } - - if $password { - $mypassword = $password - } else { - $mypassword = '!!' - } - - # if home is unspecified, use /home/<username> - if $home { - $myhome = $home - } else { - $myhome = "/home/${name}" - } - - # if mode is unspecified, use 0700, which is the default when you enable the - # managehome attribute. - if $mode { - $mymode = $mode - } else { - $mymode = '0700' - } - - if $purge_ssh_keys != undef { - $mypurgekey = str2bool($purge_ssh_keys) - validate_bool($mypurgekey) - } else { - $mypurgekey = false - } - - if versioncmp("${::puppetversion}", '3.6') >= 0 { # lint:ignore:only_variable_string - User { - purge_ssh_keys => $mypurgekey, - } - } - - # ensure managehome is boolean - if is_bool($managehome){ - $my_managehome = $managehome - } elsif is_string($managehome) { - $my_managehome = str2bool($managehome) - } else { - fail("${name}::managehome must be boolean or string.") - } - - # create user - user { $name: - ensure => $ensure, - uid => $uid, - gid => $mygid, - shell => $myshell, - groups => $mygroups, - password => $mypassword, - managehome => $my_managehome, - home => $myhome, - comment => $comment, - } # user - - if $create_group { - # If the group is not already defined, ensure its existence - if !defined(Group[$name]) { - group { $name: - ensure => $ensure, - gid => $mygid, - name => $mygroup, - } - } - } - - # If managing home, then set the mode of the home directory. This allows for - # modes other than 0700 for $HOME. - if $my_managehome == true { - - common::mkdir_p { $myhome: } - - file { $myhome: - owner => $name, - group => $mygroup, - mode => $mymode, - require => Common::Mkdir_p[$myhome], - } - - # ensure manage_dotssh is boolean - if is_bool($manage_dotssh){ - $my_manage_dotssh = $manage_dotssh - } elsif is_string($manage_dotssh) { - $my_manage_dotssh = str2bool($manage_dotssh) - } else { - fail("${name}::manage_dotssh must be boolean or string.") - } - - # create ~/.ssh - if $my_manage_dotssh == true { - file { "${myhome}/.ssh": - ensure => directory, - mode => '0700', - owner => $name, - group => $name, - require => User[$name], - } - } - } - - # if ssh_auth_key_type is unspecified, use ssh-dss - if $ssh_auth_key_type { - $my_ssh_auth_key_type = $ssh_auth_key_type - } else { - $my_ssh_auth_key_type = 'ssh-dss' - } - - # if we specify a key, then it should be present - if $ssh_auth_key { - ssh_authorized_key { $name: - ensure => present, - user => $name, - key => $ssh_auth_key, - type => $my_ssh_auth_key_type, - require => File["${myhome}/.ssh"], - } - } -}
--- a/modules/common/manifests/remove_if_empty.pp Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -# == Define: common::remove_if_empty -# -# Removes a file if it exists and is empty. -# -# Example usage: -# -# common::remove_if_empty { '/path/to/potentially_empty_file': } -# -define common::remove_if_empty () { - - validate_absolute_path($name) - - exec { "remove_if_empty-${name}": - command => "rm -f ${name}", - unless => "test -f ${name}; if [ $? == '0' ]; then test -s ${name}; fi", - path => '/bin:/usr/bin:/sbin:/usr/sbin', - } -}
--- a/modules/common/metadata.json Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -{ - "name": "ghoneycutt-common", - "version": "1.10.0", - "author": "ghoneycutt", - "summary": "common module to be applied to all nodes", - "license": "Apache-2.0", - "source": "git://github.com/ghoneycutt/puppet-module-common.git", - "project_page": "https://github.com/ghoneycutt/puppet-module-common", - "issues_url": "https://github.com/ghoneycutt/puppet-module-common/issues", - "dependencies": [ - { - "name": "puppetlabs/sshkeys_core", - "version_requirement": ">= 1.0.1 <2.0.0" - }, - { - "name": "puppetlabs/stdlib", - "version_requirement": ">= 4.6.0 < 7.0.0" - } - ], - "data_provider": null, - "description": "Provide ability to include modules that are common to all nodes.", - "requirements": [ - { - "name": "puppet", - "version_requirement": ">= 3.0.0 < 7.0.0" - } - ], - "operatingsystem_support": [ - { - "operatingsystem": "Debian" - }, - { - "operatingsystem": "RedHat" - }, - { - "operatingsystem": "CentOS" - }, - { - "operatingsystem": "OracleLinux" - }, - { - "operatingsystem": "Scientific" - }, - { - "operatingsystem": "Solaris" - }, - { - "operatingsystem": "SLES" - }, - { - "operatingsystem": "SLED" - }, - { - "operatingsystem": "Ubuntu" - } - ] -}
--- a/modules/common/spec/classes/init_spec.rb Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -require 'spec_helper' -describe 'common' do - - describe 'class common' do - - context 'default options with supported OS' do - let(:facts) { { :osfamily => 'RedHat' } } - - it { should contain_class('common') } - end - - context 'default options with unsupported osfamily, Gentoo, should fail' do - let(:facts) { { :osfamily => 'Gentoo' } } - it do - expect { - should contain_class('common') - }.to raise_error(Puppet::Error,/Supported OS families are Debian, RedHat, Solaris, and Suse\. Detected osfamily is Gentoo\./) - end - end - - describe 'managing root password' do - context 'manage_root_password => true with default root_password' do - let(:facts) { { :osfamily => 'RedHat' } } - let(:params) { { :manage_root_password => true } } - - it { should contain_class('common') } - - it { - should contain_user('root').with({ - 'password' => '$1$cI5K51$dexSpdv6346YReZcK2H1k.', - }) - } - end - - context 'manage_root_password => true and root_password => foo' do - let(:facts) { { :osfamily => 'RedHat' } } - let(:params) do - { :manage_root_password => true, - :root_password => 'foo', - } - end - - it { should contain_class('common') } - - it { - should contain_user('root').with({ - 'password' => 'foo', - }) - } - end - end - - describe 'managing /opt/$lanana' do - context 'create_opt_lsb_provider_name_dir => true and lsb_provider_name => UNSET [default]' do - let(:facts) { { :osfamily => 'RedHat' } } - let(:params) do - { :create_opt_lsb_provider_name_dir => true, - :lsb_provider_name => 'UNSET', - } - end - - it { should contain_class('common') } - - it { should_not contain_file('/opt/UNSET') } - end - - context 'create_opt_lsb_provider_name_dir => true and lsb_provider_name => foo' do - let(:facts) { { :osfamily => 'RedHat' } } - let(:params) do - { :create_opt_lsb_provider_name_dir => true, - :lsb_provider_name => 'foo', - } - end - - it { should contain_class('common') } - - it { - should contain_file('/opt/foo').with({ - 'ensure' => 'directory', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0755', - }) - } - end - end - end -end
--- a/modules/common/spec/classes/mkuser_use_cases_spec.rb Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,338 +0,0 @@ -require 'spec_helper' - -clientversion = `facter puppetversion` - -describe 'common' do - let(:facts) do - { :osfamily => 'RedHat', - :puppetversion => clientversion, - } - end - - context 'one user with default values' do - let(:facts) do - { :osfamily => 'RedHat', - :puppetversion => clientversion, - } - end - let(:params) do - { :users => { - 'alice' => { - 'uid' => 1000, - } - } - } - end - - it { - should contain_user('alice').with({ - 'uid' => '1000', - 'gid' => '1000', - 'shell' => '/bin/bash', - 'home' => '/home/alice', - 'ensure' => 'present', - 'groups' => 'alice', - 'password' => '!!', - 'managehome' => 'true', - 'comment' => 'created via puppet', - }) - } - - it { - should contain_file('/home/alice').with({ - 'owner' => 'alice', - 'mode' => '0700', - 'require' => 'Common::Mkdir_p[/home/alice]', - }) - } - - it { - should contain_file('/home/alice/.ssh').with({ - 'ensure' => 'directory', - 'mode' => '0700', - 'owner' => 'alice', - 'group' => 'alice', - 'require' => 'User[alice]', - }) - } - - it { should contain_common__mkdir_p('/home/alice') } - - it { - should contain_group('alice').with({ - 'ensure' => 'present', - 'gid' => 1000, - 'name' => 'alice', - }) - } - - it { should_not contain_ssh_authorized_key('alice') } - end - - context 'one user with custom values' do - let(:facts) do - { :osfamily => 'RedHat', - :puppetversion => clientversion, - } - end - let(:params) do - { :users => { - 'myuser' => { - 'uid' => 2000, - 'group' => 'superusers', - 'gid' => 2000, - 'shell' => '/bin/zsh', - 'home' => '/home/superu', - 'groups' => ['superusers', 'development', 'admins'], - 'password' => 'puppet', - 'mode' => '0701', - 'comment' => 'a puppet master', - } - } - } - end - - it { - should contain_user('myuser').with({ - 'uid' => '2000', - 'gid' => '2000', - 'shell' => '/bin/zsh', - 'home' => '/home/superu', - 'groups' => ['superusers', 'development', 'admins'], - 'password' => 'puppet', - 'comment' => 'a puppet master', - }) - } - - it { - should contain_file('/home/superu').with({ - 'owner' => 'myuser', - 'mode' => '0701', - 'require' => 'Common::Mkdir_p[/home/superu]', - }) - } - - it { - should contain_file('/home/superu/.ssh').with({ - 'ensure' => 'directory', - 'mode' => '0700', - 'owner' => 'myuser', - 'group' => 'myuser', - 'require' => 'User[myuser]', - }) - } - - it { should contain_common__mkdir_p('/home/superu') } - - it { should_not contain_ssh_authorized_key('myuser') } - end - - context 'two users with default values' do - let(:facts) do - { :osfamily => 'RedHat', - :puppetversion => clientversion, - } - end - let(:params) do - { :users => { - 'alice' => { - 'uid' => 1000, - }, - 'bob' => { - 'uid' => 1001, - } - } - } - end - - it { - should contain_user('alice').with({ - 'uid' => 1000, - 'gid' => 1000, - 'shell' => '/bin/bash', - 'home' => '/home/alice', - 'ensure' => 'present', - 'managehome' => true, - 'groups' => 'alice', - 'password' => '!!', - 'comment' => 'created via puppet', - }) - } - - it { - should contain_user('bob').with({ - 'uid' => 1001, - 'gid' => 1001, - 'shell' => '/bin/bash', - 'home' => '/home/bob', - 'ensure' => 'present', - 'managehome' => true, - 'groups' => 'bob', - 'password' => '!!', - 'comment' => 'created via puppet', - }) - } - - it { should contain_common__mkdir_p('/home/alice') } - it { should contain_common__mkdir_p('/home/bob') } - - it { - should contain_file('/home/alice').with({ - 'owner' => 'alice', - 'mode' => '0700', - 'require' => 'Common::Mkdir_p[/home/alice]', - }) - } - - it { - should contain_file('/home/bob').with({ - 'owner' => 'bob', - 'mode' => '0700', - 'require' => 'Common::Mkdir_p[/home/bob]', - }) - } - - it { - should contain_file('/home/alice/.ssh').with({ - 'ensure' => 'directory', - 'mode' => '0700', - 'owner' => 'alice', - 'group' => 'alice', - 'require' => 'User[alice]', - }) - } - - it { - should contain_file('/home/bob/.ssh').with({ - 'ensure' => 'directory', - 'mode' => '0700', - 'owner' => 'bob', - 'group' => 'bob', - 'require' => 'User[bob]', - }) - } - - it { - should contain_group('alice').with({ - 'ensure' => 'present', - 'gid' => 1000, - 'name' => 'alice', - }) - } - - it { - should contain_group('bob').with({ - 'ensure' => 'present', - 'gid' => 1001, - 'name' => 'bob', - }) - } - - ['alice','bob'].each do |name| - it { should_not contain_ssh_authorized_key(name) } - end - end - - context 'do not manage home' do - let(:facts) do - { :osfamily => 'RedHat', - :puppetversion => clientversion, - } - end - let(:params) do - { :users => { - 'alice' => { - 'uid' => 1000, - 'managehome' => false - } - } - } - end - - it { should_not contain_file('/home/alice') } - - it { should_not contain_common__mkdir_p('/home/alice') } - - it { should contain_user('alice').with_managehome(false) } - end - - context 'do not manage dotssh' do - let(:facts) do - { :osfamily => 'RedHat', - :puppetversion => clientversion, - } - end - let(:params) do - { :users => { - 'alice' => { - 'uid' => 1000, - 'manage_dotssh' => false - } - } - } - end - - it { should_not contain_file('/home/alice/.ssh') } - - it { should_not contain_ssh_authorized_key('alice') } - end - - describe 'with ssh_auth_key parameter specified' do - context 'with defaults for ssh_auth_key_type parameter' do - let(:facts) do - { :osfamily => 'RedHat', - :puppetversion => clientversion, - } - end - let(:params) do - { - :users => { - 'alice' => { - 'uid' => 1000, - 'ssh_auth_key' => 'AAAB3NzaC1yc2EAAAABIwAAAQEArGElx46pD6NNnlxVaTbp0ZJMgBKCmbTCT3RaeCk0ZUJtQ8wkcwTtqIXmmiuFsynUT0DFSd8UIodnBOPqitimmooAVAiAi30TtJVzADfPScMiUnBJKZajIBkEMkwUcqsfh630jyBvLPE/kyQcxbEeGtbu1DG3monkeymanOBW1AKc5o+cJLXcInLnbowMG7NXzujT3BRYn/9s5vtT1V9cuZJs4XLRXQ50NluxJI7sVfRPVvQI9EMbTS4AFBXUej3yfgaLSV+nPZC/lmJ2gR4t/tKvMFF9m16f8IcZKK7o0rK7v81G/tREbOT5YhcKLK+0wBfR6RsmHzwy4EddZloyLQ==', - } - } - } - end - - it { - should contain_ssh_authorized_key('alice').with({ - 'ensure' => 'present', - 'user' => 'alice', - 'key' => 'AAAB3NzaC1yc2EAAAABIwAAAQEArGElx46pD6NNnlxVaTbp0ZJMgBKCmbTCT3RaeCk0ZUJtQ8wkcwTtqIXmmiuFsynUT0DFSd8UIodnBOPqitimmooAVAiAi30TtJVzADfPScMiUnBJKZajIBkEMkwUcqsfh630jyBvLPE/kyQcxbEeGtbu1DG3monkeymanOBW1AKc5o+cJLXcInLnbowMG7NXzujT3BRYn/9s5vtT1V9cuZJs4XLRXQ50NluxJI7sVfRPVvQI9EMbTS4AFBXUej3yfgaLSV+nPZC/lmJ2gR4t/tKvMFF9m16f8IcZKK7o0rK7v81G/tREbOT5YhcKLK+0wBfR6RsmHzwy4EddZloyLQ==', - 'type' => 'ssh-dss', - 'require' => 'File[/home/alice/.ssh]', - }) - } - end - - context 'with ssh_auth_key_type parameter specified' do - let(:facts) do - { :osfamily => 'RedHat', - :puppetversion => clientversion, - } - end - let(:params) do - { - :users => { - 'alice' => { - 'uid' => 1000, - 'ssh_auth_key' => 'AAAB3NzaC1yc2EAAAABIwAAAQEArGElx46pD6NNnlxVaTbp0ZJMgBKCmbTCT3RaeCk0ZUJtQ8wkcwTtqIXmmiuFsynUT0DFSd8UIodnBOPqitimmooAVAiAi30TtJVzADfPScMiUnBJKZajIBkEMkwUcqsfh630jyBvLPE/kyQcxbEeGtbu1DG3monkeymanOBW1AKc5o+cJLXcInLnbowMG7NXzujT3BRYn/9s5vtT1V9cuZJs4XLRXQ50NluxJI7sVfRPVvQI9EMbTS4AFBXUej3yfgaLSV+nPZC/lmJ2gR4t/tKvMFF9m16f8IcZKK7o0rK7v81G/tREbOT5YhcKLK+0wBfR6RsmHzwy4EddZloyLQ==', - 'ssh_auth_key_type' => 'ssh-rsa', - } - } - } - end - - it { - should contain_ssh_authorized_key('alice').with({ - 'ensure' => 'present', - 'user' => 'alice', - 'key' => 'AAAB3NzaC1yc2EAAAABIwAAAQEArGElx46pD6NNnlxVaTbp0ZJMgBKCmbTCT3RaeCk0ZUJtQ8wkcwTtqIXmmiuFsynUT0DFSd8UIodnBOPqitimmooAVAiAi30TtJVzADfPScMiUnBJKZajIBkEMkwUcqsfh630jyBvLPE/kyQcxbEeGtbu1DG3monkeymanOBW1AKc5o+cJLXcInLnbowMG7NXzujT3BRYn/9s5vtT1V9cuZJs4XLRXQ50NluxJI7sVfRPVvQI9EMbTS4AFBXUej3yfgaLSV+nPZC/lmJ2gR4t/tKvMFF9m16f8IcZKK7o0rK7v81G/tREbOT5YhcKLK+0wBfR6RsmHzwy4EddZloyLQ==', - 'type' => 'ssh-rsa', - 'require' => 'File[/home/alice/.ssh]', - }) - } - end - end -end
--- a/modules/common/spec/defines/mkdir_p_spec.rb Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -require 'spec_helper' - -describe 'common::mkdir_p' do - context 'should create new directory' do - let(:title) { '/some/dir/structure' } - - it { - should contain_exec('mkdir_p-/some/dir/structure').with({ - 'command' => 'mkdir -p /some/dir/structure', - 'unless' => 'test -d /some/dir/structure', - }) - } - end - - context 'should fail with a path that is not absolute' do - let(:title) { 'not/a/valid/absolute/path' } - - it do - expect { - should contain_exec('mkdir_p-not/a/valid/absolute/path').with({ - 'command' => 'mkdir -p not/a/valid/absolute/path', - 'unless' => 'test -d not/a/valid/absolute/path', - }) - }.to raise_error(Puppet::Error) - end - end -end
--- a/modules/common/spec/defines/mkuser_spec.rb Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,283 +0,0 @@ -require 'spec_helper' - -clientversion = `facter puppetversion` - -describe 'common::mkuser' do - let(:title) { 'alice' } - let(:facts) do - { :osfamily => 'RedHat', - :puppetversion => clientversion, - } - end - - context 'user alice with default values' do - let(:params) { { :uid => 1000 } } - - it do - should contain_user('alice').with({ - 'uid' => '1000', - 'gid' => '1000', - 'shell' => '/bin/bash', - 'home' => '/home/alice', - 'ensure' => 'present', - 'groups' => 'alice', - 'password' => '!!', - 'managehome' => 'true', - 'comment' => 'created via puppet', - }) - end - - it do - should contain_file('/home/alice').with({ - 'owner' => 'alice', - 'group' => 'alice', - 'mode' => '0700', - 'require' => 'Common::Mkdir_p[/home/alice]', - }) - end - - it do - should contain_file('/home/alice/.ssh').with({ - 'ensure' => 'directory', - 'mode' => '0700', - 'owner' => 'alice', - 'group' => 'alice', - 'require' => 'User[alice]', - }) - end - - it { should contain_common__mkdir_p('/home/alice') } - - it do - should contain_group('alice').with({ - 'ensure' => 'present', - 'gid' => 1000, - 'name' => 'alice', - }) - end - - it { should_not contain_ssh_authorized_key('alice') } - end - - context 'user alice with custom values' do - let(:params) do - { - 'uid' => 2000, - 'group' => 'superusers', - 'gid' => 2000, - 'shell' => '/bin/zsh', - 'home' => '/home/superu', - 'groups' => %w(superusers development admins), - 'password' => 'puppet', - 'mode' => '0701', - 'comment' => 'a puppet master', - } - end - - it do - should contain_user('alice').with({ - 'uid' => '2000', - 'gid' => '2000', - 'shell' => '/bin/zsh', - 'home' => '/home/superu', - 'groups' => %w(superusers development admins), - 'password' => 'puppet', - 'comment' => 'a puppet master', - }) - end - - it do - should contain_file('/home/superu').with({ - 'owner' => 'alice', - 'group' => 'superusers', - 'mode' => '0701', - 'require' => 'Common::Mkdir_p[/home/superu]', - }) - end - - it do - should contain_file('/home/superu/.ssh').with({ - 'ensure' => 'directory', - 'mode' => '0700', - 'owner' => 'alice', - 'group' => 'alice', - 'require' => 'User[alice]', - }) - end - - it { should contain_common__mkdir_p('/home/superu') } - - it { should_not contain_ssh_authorized_key('myuser') } - end - - context 'do not manage home' do - let(:params) do - { - 'uid' => 1000, - 'managehome' => false - } - end - - it { should_not contain_file('/home/alice') } - - it { should_not contain_common__mkdir_p('/home/alice') } - - it { should contain_user('alice').with_managehome(false) } - end - - context 'do not manage dotssh' do - let(:params) do - { - 'uid' => 1000, - 'manage_dotssh' => false - } - end - - it { should_not contain_file('/home/alice/.ssh') } - - it { should_not contain_ssh_authorized_key('alice') } - end - - describe 'with ssh_auth_key parameter specified' do - context 'with defaults for ssh_auth_key_type parameter' do - let(:params) do - { - 'uid' => 1000, - 'ssh_auth_key' => 'AAAB3NzaC1yc2EAAAABIwAAAQEArGElx46pD6NNnlxVaTbp0ZJMgBKCmbTCT3RaeCk0ZUJtQ8wkcwTtqIXmmiuFsynUT0DFSd8UIodnBOPqitimmooAVAiAi30TtJVzADfPScMiUnBJKZajIBkEMkwUcqsfh630jyBvLPE/kyQcxbEeGtbu1DG3monkeymanOBW1AKc5o+cJLXcInLnbowMG7NXzujT3BRYn/9s5vtT1V9cuZJs4XLRXQ50NluxJI7sVfRPVvQI9EMbTS4AFBXUej3yfgaLSV+nPZC/lmJ2gR4t/tKvMFF9m16f8IcZKK7o0rK7v81G/tREbOT5YhcKLK+0wBfR6RsmHzwy4EddZloyLQ==', - } - end - - it do - should contain_ssh_authorized_key('alice').with({ - 'ensure' => 'present', - 'user' => 'alice', - 'key' => 'AAAB3NzaC1yc2EAAAABIwAAAQEArGElx46pD6NNnlxVaTbp0ZJMgBKCmbTCT3RaeCk0ZUJtQ8wkcwTtqIXmmiuFsynUT0DFSd8UIodnBOPqitimmooAVAiAi30TtJVzADfPScMiUnBJKZajIBkEMkwUcqsfh630jyBvLPE/kyQcxbEeGtbu1DG3monkeymanOBW1AKc5o+cJLXcInLnbowMG7NXzujT3BRYn/9s5vtT1V9cuZJs4XLRXQ50NluxJI7sVfRPVvQI9EMbTS4AFBXUej3yfgaLSV+nPZC/lmJ2gR4t/tKvMFF9m16f8IcZKK7o0rK7v81G/tREbOT5YhcKLK+0wBfR6RsmHzwy4EddZloyLQ==', - 'type' => 'ssh-dss', - 'require' => 'File[/home/alice/.ssh]', - }) - end - end - - context 'with ssh_auth_key_type parameter specified' do - let(:params) do - { - 'uid' => 1000, - 'ssh_auth_key' => 'AAAB3NzaC1yc2EAAAABIwAAAQEArGElx46pD6NNnlxVaTbp0ZJMgBKCmbTCT3RaeCk0ZUJtQ8wkcwTtqIXmmiuFsynUT0DFSd8UIodnBOPqitimmooAVAiAi30TtJVzADfPScMiUnBJKZajIBkEMkwUcqsfh630jyBvLPE/kyQcxbEeGtbu1DG3monkeymanOBW1AKc5o+cJLXcInLnbowMG7NXzujT3BRYn/9s5vtT1V9cuZJs4XLRXQ50NluxJI7sVfRPVvQI9EMbTS4AFBXUej3yfgaLSV+nPZC/lmJ2gR4t/tKvMFF9m16f8IcZKK7o0rK7v81G/tREbOT5YhcKLK+0wBfR6RsmHzwy4EddZloyLQ==', - 'ssh_auth_key_type' => 'ssh-rsa', - } - end - - it do - should contain_ssh_authorized_key('alice').with({ - 'ensure' => 'present', - 'user' => 'alice', - 'key' => 'AAAB3NzaC1yc2EAAAABIwAAAQEArGElx46pD6NNnlxVaTbp0ZJMgBKCmbTCT3RaeCk0ZUJtQ8wkcwTtqIXmmiuFsynUT0DFSd8UIodnBOPqitimmooAVAiAi30TtJVzADfPScMiUnBJKZajIBkEMkwUcqsfh630jyBvLPE/kyQcxbEeGtbu1DG3monkeymanOBW1AKc5o+cJLXcInLnbowMG7NXzujT3BRYn/9s5vtT1V9cuZJs4XLRXQ50NluxJI7sVfRPVvQI9EMbTS4AFBXUej3yfgaLSV+nPZC/lmJ2gR4t/tKvMFF9m16f8IcZKK7o0rK7v81G/tREbOT5YhcKLK+0wBfR6RsmHzwy4EddZloyLQ==', - 'type' => 'ssh-rsa', - 'require' => 'File[/home/alice/.ssh]', - }) - end - end - end - - # purge_ssh_keys was introduced with Puppet 3.6.0 - # we need to know which version of Puppet is running this test - # to decide which results we need to expect - # dirty trick to get the running version of Puppet: - clientversion = `facter puppetversion` - # test environments contains no facts, we need to set it as fact - - describe "with purge_ssh_keys running on Puppet version #{clientversion}" do - let(:facts) do - { - :osfamily => 'RedHat', - :puppetversion => clientversion, - } - end - - context 'set to undef/nil' do - let(:params) { { :uid => 1000 } } - - if clientversion.to_f >= 3.6 - it { should contain_user('alice').with_purge_ssh_keys(false) } - else - it { should contain_user('alice').without_purge_ssh_keys } - end - end - - context 'set to true' do - let(:params) do - { - 'uid' => 1000, - 'purge_ssh_keys' => true, - } - end - - if clientversion.to_f >= 3.6 - it { should contain_user('alice').with_purge_ssh_keys(true) } - else - it { should contain_user('alice').without_purge_ssh_keys } - end - end - - context 'set to false' do - let(:params) do - { - 'uid' => 1000, - 'purge_ssh_keys' => false, - } - end - - if clientversion.to_f >= 3.6 - it { should contain_user('alice').with_purge_ssh_keys(false) } - else - it { should contain_user('alice').without_purge_ssh_keys } - end - end - end - - describe 'variable type and content validations' do - # set needed custom facts and variables - let(:facts) do - { - :osfamily => 'RedHat', - :puppetversion => clientversion, - } - end - let(:validation_params) do - { - :uid => 1000, - } - end - - validations = { - 'bool_stringified' => { - :name => %w(managehome manage_dotssh purge_ssh_keys), - :valid => [true, false, 'true', 'false'], - :invalid => ['invalid', %w(array), { 'ha' => 'sh' }, 3, 2.42, nil], - :message => '(str2bool|must be boolean or string)', - }, - } - - validations.sort.each do |type, var| - var[:name].each do |var_name| - var[:valid].each do |valid| - context "with #{var_name} (#{type}) set to valid #{valid} (as #{valid.class})" do - let(:params) { validation_params.merge({ :"#{var_name}" => valid, }) } - it { should compile } - end - end - - var[:invalid].each do |invalid| - context "with #{var_name} (#{type}) set to invalid #{invalid} (as #{invalid.class})" do - let(:params) { validation_params.merge({ :"#{var_name}" => invalid, }) } - it 'should fail' do - expect do - should contain_class(subject) - end.to raise_error(Puppet::Error, /#{var[:message]}/) - end - end - end - end # var[:name].each - end # validations.sort.each - end # describe 'variable type and content validations' -end
--- a/modules/common/spec/defines/remove_if_empty_spec.rb Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -require 'spec_helper' - -describe 'common::remove_if_empty' do - context 'should create new directory' do - let(:title) { '/some/dir/structure' } - - it { - should contain_exec('remove_if_empty-/some/dir/structure').with({ - 'command' => 'rm -f /some/dir/structure', - 'unless' => 'test -f /some/dir/structure; if [ $? == \'0\' ]; then test -s /some/dir/structure; fi', - 'path' => '/bin:/usr/bin:/sbin:/usr/sbin', - }) - } - end - - context 'should fail with a path that is not absolute' do - let(:title) { 'not/a/valid/absolute/path' } - - it do - expect { - should contain_exec('remove_if_empty-not/a/valid/absolute/path') - }.to raise_error(Puppet::Error) - end - end -end
--- a/modules/common/spec/functions/interface2factname_spec.rb Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -require 'spec_helper' - -describe 'interface2factname' do - - describe 'should return correct results' do - - it 'should run with eth0' do - should run.with_params('eth0').and_return('ipaddress_eth0') - end - - it 'should run with bond0:0' do - should run.with_params('bond0:0').and_return('ipaddress_bond0_0') - end - - it 'should run with bond0:1' do - should run.with_params('bond0:1').and_return('ipaddress_bond0_1') - end - end -end
--- a/modules/common/spec/functions/strip_file_extension_spec.rb Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe 'strip_file_extension' do - - describe 'strips file extensions' do - - it 'from single files' do - should run.with_params('puppet.conf', 'conf').and_return('puppet') - end - - it 'and removes full path' do - should run.with_params('/etc/puppet/puppet.conf', 'conf').and_return('puppet') - end - end -end
--- a/modules/common/spec/spec_helper.rb Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -require 'puppetlabs_spec_helper/module_spec_helper' - -RSpec.configure do |config| - config.hiera_config = 'spec/fixtures/hiera/hiera.yaml' - config.before :each do - # Ensure that we don't accidentally cache facts and environment between - # test cases. This requires each example group to explicitly load the - # facts being exercised with something like - # Facter.collection.loader.load(:ipaddress) - Facter.clear - Facter.clear_messages - end - config.default_facts = { - :environment => 'rp_env', - } -end
--- a/modules/common/tests/init.pp Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -# The baseline for module testing used by Puppet Labs is that each manifest -# should have a corresponding test manifest that declares that class or defined -# type. -# -# Tests are then run by using puppet apply --noop (to check for compilation errors -# and view a log of events) or by fully applying the test in a virtual environment -# (to compare the resulting system state to the desired state). -# -# Learn more about module testing here: http://docs.puppetlabs.com/guides/tests_smoke.html -# -include ::common
--- a/modules/translate/CHANGELOG.md Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -# Change log - -All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org). - -## [v2.1.0](https://github.com/puppetlabs/puppetlabs-translate/tree/v2.1.0) (2019-11-29) - -[Full Changelog](https://github.com/puppetlabs/puppetlabs-translate/compare/v2.0.0...v2.1.0) - -### Added - -- \(FM-8682\) - Addition of Support for CentOS 8 [\#59](https://github.com/puppetlabs/puppetlabs-translate/pull/59) ([david22swan](https://github.com/david22swan)) -- FM-8414 - Add support on Debian 10 [\#52](https://github.com/puppetlabs/puppetlabs-translate/pull/52) ([lionce](https://github.com/lionce)) - -## [v2.0.0](https://github.com/puppetlabs/puppetlabs-translate/tree/v2.0.0) (2019-06-13) - -[Full Changelog](https://github.com/puppetlabs/puppetlabs-translate/compare/1.2.0...v2.0.0) - -### Changed - -- pdksync - \(MODULES-8444\) - Raise lower Puppet bound [\#39](https://github.com/puppetlabs/puppetlabs-translate/pull/39) ([david22swan](https://github.com/david22swan)) -- \(FM-7711\) - Remove Debian 7 testing/support for Translate module [\#31](https://github.com/puppetlabs/puppetlabs-translate/pull/31) ([david22swan](https://github.com/david22swan)) - -### Added - -- \(FM-8034\) Add RedHat 8 support [\#42](https://github.com/puppetlabs/puppetlabs-translate/pull/42) ([eimlav](https://github.com/eimlav)) -- \[FM-7939\] Puppet Strings [\#41](https://github.com/puppetlabs/puppetlabs-translate/pull/41) ([carabasdaniel](https://github.com/carabasdaniel)) -- \(FM-7720/FM-7722/FM-7723\) - Update to windows support [\#33](https://github.com/puppetlabs/puppetlabs-translate/pull/33) ([david22swan](https://github.com/david22swan)) - -### Fixed - -- pdksync - \(FM-7655\) Fix rubygems-update for ruby \< 2.3 [\#28](https://github.com/puppetlabs/puppetlabs-translate/pull/28) ([tphoney](https://github.com/tphoney)) - -## [1.2.0](https://github.com/puppetlabs/puppetlabs-translate/tree/1.2.0) (2018-09-27) - -[Full Changelog](https://github.com/puppetlabs/puppetlabs-translate/compare/1.1.0...1.2.0) - -### Added - -- Update metadata.json for Puppet 6 support [\#23](https://github.com/puppetlabs/puppetlabs-translate/pull/23) ([eimlav](https://github.com/eimlav)) -- pdksync - \(FM-7392\) - Puppet 6 Testing Changes [\#22](https://github.com/puppetlabs/puppetlabs-translate/pull/22) ([pmcmaw](https://github.com/pmcmaw)) - -### Fixed - -- \(MODULES-7728\) - Reading beaker-hostgenerator and nokogiri gem [\#20](https://github.com/puppetlabs/puppetlabs-translate/pull/20) ([pmcmaw](https://github.com/pmcmaw)) - -## 1.1.0 -### Summary -A small addition release including a bump to the Puppet version requirements. - -#### Changed -- Updated the Puppet version to correctly reflect which version of Puppet includes the translation updates. - -#### Added -- Adding acceptance test directory along with several nodesets for testing. -- Addition of several files including maintainers, contributing and an update to existing Rakefiles and .travis files. - -## Supported Release [1.0.0] -### Summary -This is a feature release that includes support for interpolated strings. - -#### Added -- support for passing strings that use interpolation to the `translate` function - -#### Removed -- Debian 6 support - -## Supported Release [0.1.0] -### Summary -This is the initial release. - -[1.0.0]:https://github.com/puppetlabs/puppetlabs-translate/compare/0.1.0...1.0.0 -[0.1.0]:https://github.com/puppetlabs/puppetlabs-translate/commits/0.1.0 - - -\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
--- a/modules/translate/CONTRIBUTING.md Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,271 +0,0 @@ -# Contributing to Puppet modules - -So you want to contribute to a Puppet module: Great! Below are some instructions to get you started doing -that very thing while setting expectations around code quality as well as a few tips for making the -process as easy as possible. - -### Table of Contents - -1. [Getting Started](#getting-started) -1. [Commit Checklist](#commit-checklist) -1. [Submission](#submission) -1. [More about commits](#more-about-commits) -1. [Testing](#testing) - - [Running Tests](#running-tests) - - [Writing Tests](#writing-tests) -1. [Get Help](#get-help) - -## Getting Started - -- Fork the module repository on GitHub and clone to your workspace - -- Make your changes! - -## Commit Checklist - -### The Basics - -- [x] my commit is a single logical unit of work - -- [x] I have checked for unnecessary whitespace with "git diff --check" - -- [x] my commit does not include commented out code or unneeded files - -### The Content - -- [x] my commit includes tests for the bug I fixed or feature I added - -- [x] my commit includes appropriate documentation changes if it is introducing a new feature or changing existing functionality - -- [x] my code passes existing test suites - -### The Commit Message - -- [x] the first line of my commit message includes: - - - [x] an issue number (if applicable), e.g. "(MODULES-xxxx) This is the first line" - - - [x] a short description (50 characters is the soft limit, excluding ticket number(s)) - -- [x] the body of my commit message: - - - [x] is meaningful - - - [x] uses the imperative, present tense: "change", not "changed" or "changes" - - - [x] includes motivation for the change, and contrasts its implementation with the previous behavior - -## Submission - -### Pre-requisites - -- Make sure you have a [GitHub account](https://github.com/join) - -- [Create a ticket](https://tickets.puppet.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppet.com/browse/) you are patching for. - -### Push and PR - -- Push your changes to your fork - -- [Open a Pull Request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) against the repository in the puppetlabs organization - -## More about commits - - 1. Make separate commits for logically separate changes. - - Please break your commits down into logically consistent units - which include new or changed tests relevant to the rest of the - change. The goal of doing this is to make the diff easier to - read for whoever is reviewing your code. In general, the easier - your diff is to read, the more likely someone will be happy to - review it and get it into the code base. - - If you are going to refactor a piece of code, please do so as a - separate commit from your feature or bug fix changes. - - We also really appreciate changes that include tests to make - sure the bug is not re-introduced, and that the feature is not - accidentally broken. - - Describe the technical detail of the change(s). If your - description starts to get too long, that is a good sign that you - probably need to split up your commit into more finely grained - pieces. - - Commits which plainly describe the things which help - reviewers check the patch and future developers understand the - code are much more likely to be merged in with a minimum of - bike-shedding or requested changes. Ideally, the commit message - would include information, and be in a form suitable for - inclusion in the release notes for the version of Puppet that - includes them. - - Please also check that you are not introducing any trailing - whitespace or other "whitespace errors". You can do this by - running "git diff --check" on your changes before you commit. - - 2. Sending your patches - - To submit your changes via a GitHub pull request, we _highly_ - recommend that you have them on a topic branch, instead of - directly on "master". - It makes things much easier to keep track of, especially if - you decide to work on another thing before your first change - is merged in. - - GitHub has some pretty good - [general documentation](http://help.github.com/) on using - their site. They also have documentation on - [creating pull requests](https://help.github.com/articles/creating-a-pull-request-from-a-fork/). - - In general, after pushing your topic branch up to your - repository on GitHub, you can switch to the branch in the - GitHub UI and click "Pull Request" towards the top of the page - in order to open a pull request. - - 3. Update the related JIRA issue. - - If there is a JIRA issue associated with the change you - submitted, then you should update the ticket to include the - location of your branch, along with any other commentary you - may wish to make. - -# Testing - -## Getting Started - -Our Puppet modules provide [`Gemfile`](./Gemfile)s, which can tell a Ruby package manager such as [bundler](http://bundler.io/) what Ruby packages, -or Gems, are required to build, develop, and test this software. - -Please make sure you have [bundler installed](http://bundler.io/#getting-started) on your system, and then use it to -install all dependencies needed for this project in the project root by running - -```shell -% bundle install --path .bundle/gems -Fetching gem metadata from https://rubygems.org/........ -Fetching gem metadata from https://rubygems.org/.. -Using rake (10.1.0) -Using builder (3.2.2) --- 8><-- many more --><8 -- -Using rspec-system-puppet (2.2.0) -Using serverspec (0.6.3) -Using rspec-system-serverspec (1.0.0) -Using bundler (1.3.5) -Your bundle is complete! -Use `bundle show [gemname]` to see where a bundled gem is installed. -``` - -NOTE: some systems may require you to run this command with sudo. - -If you already have those gems installed, make sure they are up-to-date: - -```shell -% bundle update -``` - -## Running Tests - -With all dependencies in place and up-to-date, run the tests: - -### Unit Tests - -```shell -% bundle exec rake spec -``` - -This executes all the [rspec tests](http://rspec-puppet.com/) in the directories defined [here](https://github.com/puppetlabs/puppetlabs_spec_helper/blob/699d9fbca1d2489bff1736bb254bb7b7edb32c74/lib/puppetlabs_spec_helper/rake_tasks.rb#L17) and so on. -rspec tests may have the same kind of dependencies as the module they are testing. Although the module defines these dependencies in its [metadata.json](./metadata.json), -rspec tests define them in [.fixtures.yml](./fixtures.yml). - -### Acceptance Tests - -Some Puppet modules also come with acceptance tests, which use [beaker][]. These tests spin up a virtual machine under -[VirtualBox](https://www.virtualbox.org/), controlled with [Vagrant](http://www.vagrantup.com/), to simulate scripted test -scenarios. In order to run these, you need both Virtualbox and Vagrant installed on your system. - -Run the tests by issuing the following command - -```shell -% bundle exec rake spec_clean -% bundle exec rspec spec/acceptance -``` - -This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml), -install Puppet, copy this module, and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb) -and then run all the tests under [spec/acceptance](./spec/acceptance). - -## Writing Tests - -### Unit Tests - -When writing unit tests for Puppet, [rspec-puppet][] is your best friend. It provides tons of helper methods for testing your manifests against a -catalog (e.g. contain_file, contain_package, with_params, etc). It would be ridiculous to try and top rspec-puppet's [documentation][rspec-puppet_docs] -but here's a tiny sample: - -Sample manifest: - -```puppet -file { "a test file": - ensure => present, - path => "/etc/sample", -} -``` - -Sample test: - -```ruby -it 'does a thing' do - expect(subject).to contain_file("a test file").with({:path => "/etc/sample"}) -end -``` - -### Acceptance Tests - -Writing acceptance tests for Puppet involves [beaker][] and its cousin [beaker-rspec][]. A common pattern for acceptance tests is to create a test manifest, apply it -twice to check for idempotency or errors, then run expectations. - -```ruby -it 'does an end-to-end thing' do - pp = <<-EOF - file { 'a test file': - ensure => present, - path => "/etc/sample", - content => "test string", - } - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - -end - -describe file("/etc/sample") do - it { is_expected.to contain "test string" } -end - -``` - -# If you have commit access to the repository - -Even if you have commit access to the repository, you still need to go through the process above, and have someone else review and merge -in your changes. The rule is that **all changes must be reviewed by a project developer that did not write the code to ensure that -all changes go through a code review process.** - -The record of someone performing the merge is the record that they performed the code review. Again, this should be someone other than the author of the topic branch. - -# Get Help - -### On the web -* [Puppet help messageboard](http://puppet.com/community/get-help) -* [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing) -* [General GitHub documentation](http://help.github.com/) -* [GitHub pull request documentation](http://help.github.com/send-pull-requests/) - -### On chat -* Slack (slack.puppet.com) #forge-modules, #puppet-dev, #windows, #voxpupuli -* IRC (freenode) #puppet-dev, #voxpupuli - - -[rspec-puppet]: http://rspec-puppet.com/ -[rspec-puppet_docs]: http://rspec-puppet.com/documentation/ -[beaker]: https://github.com/puppetlabs/beaker -[beaker-rspec]: https://github.com/puppetlabs/beaker-rspec
--- a/modules/translate/Gemfile Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -source ENV['GEM_SOURCE'] || 'https://rubygems.org' - -def location_for(place_or_version, fake_version = nil) - git_url_regex = %r{\A(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?} - file_url_regex = %r{\Afile:\/\/(?<path>.*)} - - if place_or_version && (git_url = place_or_version.match(git_url_regex)) - [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact - elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) - ['>= 0', { path: File.expand_path(file_url[:path]), require: false }] - else - [place_or_version, { require: false }] - end -end - -ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments -minor_version = ruby_version_segments[0..1].join('.') - -group :development do - gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') - gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') - gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') - gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') - gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-posix-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby] - gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby] - gem "puppet-module-win-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-win-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "github_changelog_generator", require: false, git: 'https://github.com/skywinder/github-changelog-generator', ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2') -end - -puppet_version = ENV['PUPPET_GEM_VERSION'] -facter_version = ENV['FACTER_GEM_VERSION'] -hiera_version = ENV['HIERA_GEM_VERSION'] - -gems = {} - -gems['puppet'] = location_for(puppet_version) - -# If facter or hiera versions have been specified via the environment -# variables - -gems['facter'] = location_for(facter_version) if facter_version -gems['hiera'] = location_for(hiera_version) if hiera_version - -if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)} - # If we're using a Puppet gem on Windows which handles its own win32-xxx gem - # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). - gems['win32-dir'] = ['<= 0.4.9', require: false] - gems['win32-eventlog'] = ['<= 0.6.5', require: false] - gems['win32-process'] = ['<= 0.7.5', require: false] - gems['win32-security'] = ['<= 0.2.5', require: false] - gems['win32-service'] = ['0.8.8', require: false] -end - -gems.each do |gem_name, gem_params| - gem gem_name, *gem_params -end - -# Evaluate Gemfile.local and ~/.gemfile if they exist -extra_gemfiles = [ - "#{__FILE__}.local", - File.join(Dir.home, '.gemfile'), -] - -extra_gemfiles.each do |gemfile| - if File.file?(gemfile) && File.readable?(gemfile) - eval(File.read(gemfile), binding) - end -end -# vim: syntax=ruby
--- a/modules/translate/HISTORY.md Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -## 1.1.0 -### Summary -A small addition release including a bump to the Puppet version requirements. - -#### Changed -- Updated the Puppet version to correctly reflect which version of Puppet includes the translation updates. - -#### Added -- Adding acceptance test directory along with several nodesets for testing. -- Addition of several files including maintainers, contributing and an update to existing Rakefiles and .travis files. - -## Supported Release [1.0.0] -### Summary -This is a feature release that includes support for interpolated strings. - -#### Added -- support for passing strings that use interpolation to the `translate` function - -#### Removed -- Debian 6 support - -## Supported Release [0.1.0] -### Summary -This is the initial release. - -[1.0.0]:https://github.com/puppetlabs/puppetlabs-translate/compare/0.1.0...1.0.0 -[0.1.0]:https://github.com/puppetlabs/puppetlabs-translate/commits/0.1.0
--- a/modules/translate/LICENSE Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.
--- a/modules/translate/MAINTAINERS.md Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -## Maintenance - -Maintainers: - - Puppet Forge Modules Team `forge-modules |at| puppet |dot| com` - -Tickets: https://tickets.puppet.com/browse/MODULES. Make sure to set component to `translate`.
--- a/modules/translate/NOTICE Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -Puppet Module - puppetlabs-translate - -Copyright 2017 Puppet, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. \ No newline at end of file
--- a/modules/translate/README.md Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -# translate - -#### Table of Contents - -1. [Module Description - What the module does and why it is useful](#module-description) -2. [Setup - The basics of getting started with translate](#setup) -3. [Usage - Configuration options and additional functionality](#usage) -4. [Reference - An under-the-hood peek at what the module is doing and how](#reference) -5. [Limitations - OS compatibility, etc.](#limitations) -6. [Development - Guide for contributing to the module](#development) -7. [Contributors](#contributors) - -## Module description - -This module provides the `translate` function for Puppet. Wrapping a string in this function will mark it to be picked up by gettext and put into the .pot file for translation purposes. Currently, we are **only marking failures, errors, and warnings** in Puppet Supported modules. Feel free to do what you like with your own. - -## Setup - -Install this module with the Puppet Module Tool: -```shell -puppet module install puppetlabs-translate -``` - -## Reference - -For information on the classes and types, see the [REFERENCE.md](https://github.com/puppetlabs/puppetlabs-translate/blob/master/REFERENCE.md) - -## Limitations - -We do not yet support pluralization. - -## Development - -Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. For more information, see our [module contribution guide.](https://puppet.com/docs/puppet/latest/contributing.html) - -## Contributors - -The list of contributors can be found at: [https://github.com/puppetlabs/puppetlabs-translate/graphs/contributors](https://github.com/puppetlabs/puppetlabs-translate/graphs/contributors).
--- a/modules/translate/REFERENCE.md Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -# Reference -<!-- DO NOT EDIT: This document was generated by Puppet Strings --> - -## Table of Contents - -**Functions** - -* [`translate`](#translate): A function that calls the _() function in gettext. This is because _ is protected in the puppet language - -## Functions - -### translate - -Type: Ruby 4.x API - -A function that calls the _() function in gettext. This is because _ is protected in the puppet language - -* **Note** Translate with simple strings: - - Takes in a string and passes it to fast_gettext's _() function. Primarily used for 'marking' a string to be added to a .pot file. -Translate with interpolation: - - Takes in a string and a hash. Please note that variables in the message are wrapped with %{VAR} not ${VAR}. - - The hash contains key value pairs with marker and the variable it will be assigned to. - - The translate module passes it to fast_gettext's _() function. Primarily used for 'marking' a string to be added to a .pot file. - -#### Examples - -##### - -```puppet -fail(translate("Failure message")) -``` - -##### - -```puppet -fail(translate('message is %{color}'), {'color' => 'green'}) -``` - -#### `translate(String $message, Optional[Hash] $interpolation_values)` - -The translate function. - -Returns: `String` translated message. - -##### Examples - -###### - -```puppet -fail(translate("Failure message")) -``` - -###### - -```puppet -fail(translate('message is %{color}'), {'color' => 'green'}) -``` - -##### `message` - -Data type: `String` - -Message to translate - -##### `interpolation_values` - -Data type: `Optional[Hash]` - -Optional. -
--- a/modules/translate/Rakefile Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? -require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-syntax/tasks/puppet-syntax' -require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? -require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any? -require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any? - -def changelog_user - return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = nil || JSON.load(File.read('metadata.json'))['author'] - raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil? - puts "GitHubChangelogGenerator user:#{returnVal}" - returnVal -end - -def changelog_project - return unless Rake.application.top_level_tasks.include? "changelog" - - returnVal = nil - returnVal ||= begin - metadata_source = JSON.load(File.read('metadata.json'))['source'] - metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z}) - - metadata_source_match && metadata_source_match[1] - end - - raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil? - - puts "GitHubChangelogGenerator project:#{returnVal}" - returnVal -end - -def changelog_future_release - return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version'] - raise "unable to find the future_release (version) in metadata.json" if returnVal.nil? - puts "GitHubChangelogGenerator future_release:#{returnVal}" - returnVal -end - -PuppetLint.configuration.send('disable_relative') - -if Bundler.rubygems.find_name('github_changelog_generator').any? - GitHubChangelogGenerator::RakeTask.new :changelog do |config| - raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil? - config.user = "#{changelog_user}" - config.project = "#{changelog_project}" - config.future_release = "#{changelog_future_release}" - config.exclude_labels = ['maintenance'] - config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)." - config.add_pr_wo_labels = true - config.issues = false - config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM" - config.configure_sections = { - "Changed" => { - "prefix" => "### Changed", - "labels" => ["backwards-incompatible"], - }, - "Added" => { - "prefix" => "### Added", - "labels" => ["feature", "enhancement"], - }, - "Fixed" => { - "prefix" => "### Fixed", - "labels" => ["bugfix"], - }, - } - end -else - desc 'Generate a Changelog from GitHub' - task :changelog do - raise <<EOM -The changelog tasks depends on unreleased features of the github_changelog_generator gem. -Please manually add it to your .sync.yml for now, and run `pdk update`: ---- -Gemfile: - optional: - ':development': - - gem: 'github_changelog_generator' - git: 'https://github.com/skywinder/github-changelog-generator' - ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018' - condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')" -EOM - end -end -
--- a/modules/translate/checksums.json Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -{ - "CHANGELOG.md": "f6d40db0689a9cfd01db12fc8ae8935c", - "CONTRIBUTING.md": "4d17f3c942e7c93d1577cc4438a231e4", - "Gemfile": "1a5466fcfc1a2f40765b4abc5ea9ad06", - "HISTORY.md": "bc835a1a781369ba8c24681bdeab99f1", - "LICENSE": "3b83ef96387f14655fc854ddc3c6bd57", - "MAINTAINERS.md": "86bc26eb48e3994809990c1b49907550", - "NOTICE": "002a2b26ef50234b43afb62fa62a7b97", - "README.md": "09280f1b45c4250155d52a18aed02f37", - "REFERENCE.md": "57ac27e3762372254a0096f6fbf896e4", - "Rakefile": "35791ec85225c70e7b5a891f1bbd1b87", - "distelli-manifest.yml": "802c79b810412726002fee5029900c5f", - "lib/puppet/functions/translate.rb": "6b42a479316b1565dfe94760160e92b6", - "locales/config.yaml": "b291ec1700c36f3b902b5b135b841260", - "metadata.json": "7582e96d48c554e05bc604685f11d332", - "provision.yaml": "a2b212e922a952511bec76365230ee65", - "spec/acceptance/spec_helper_acceptance.rb": "9681de54bf44c9c507adc13d12bada2a", - "spec/acceptance/translate_spec.rb": "55bdb32fe0a766b66c27d4fcc6551897", - "spec/default_facts.yml": "973bd7e9b429cde3c8d45d57c2fa21ed", - "spec/functions/translate_spec.rb": "8f12d2a05773d09fea17a064f16b4cf9", - "spec/spec_helper.rb": "ec40d36ed109d8dba0df527c34c2c6db", - "spec/spec_helper_local.rb": "be320849409fd3a6ae2a21c04701d88a" -} \ No newline at end of file
--- a/modules/translate/distelli-manifest.yml Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -team-modules/puppetlabs-translate: - PreBuild: - - source /opt/rh/rh-ruby25/enable - - echo "--- LETS update BUNDLER ---" - - bundle install --path vendor/bundle --jobs 3 - Build: - - echo "--- PROVISIONING ---" - - source /opt/rh/rh-ruby25/enable - - bundle exec rake litmus:provision_list[release_checks] - - cat inventory.yaml - - echo "--- AGENT INSTALLATION ---" - - bundle exec rake litmus:install_agent - - echo "--- MODULE INSTALLATION ---" - - bundle exec rake litmus:install_module - - echo "--- TESTS RUNNING ---" - - bundle exec rake litmus:acceptance:parallel - AfterBuildSuccess: - - source /opt/rh/rh-ruby25/enable - - bundle exec rake litmus:tear_down - AfterBuildFailure: - - source /opt/rh/rh-ruby25/enable - - bundle exec rake litmus:tear_down - CommitData: - - RepoType: Git - - RepoPath: .
--- a/modules/translate/lib/puppet/functions/translate.rb Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -# @summary A function that calls the _() function in gettext. This is because _ is protected in the puppet language -# -# @note -# Translate with simple strings: -# - Takes in a string and passes it to fast_gettext's _() function. Primarily used for 'marking' a string to be added to a .pot file. -# Translate with interpolation: -# - Takes in a string and a hash. Please note that variables in the message are wrapped with %{VAR} not ${VAR}. -# - The hash contains key value pairs with marker and the variable it will be assigned to. -# - The translate module passes it to fast_gettext's _() function. Primarily used for 'marking' a string to be added to a .pot file. -# -# @example -# fail(translate("Failure message")) -# @example -# fail(translate('message is %{color}'), {'color' => 'green'}) -# -Puppet::Functions.create_function(:translate) do - # @param message Message to translate - # @param interpolation_values Optional. - # @return [String] translated message. - dispatch :translate do - param 'String', :message - optional_param 'Hash', :interpolation_values - end - - def translate(message, interpolation_values = nil) - if interpolation_values.nil? - _(message) - else - # convert keys to symbols - interpolation_values = Hash[interpolation_values.map { |k, v| [k.to_sym, v] }] - _(message) % interpolation_values - end - end -end
--- a/modules/translate/locales/config.yaml Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ ---- -# This is the project-specific configuration file for setting up -# fast_gettext for your project. -gettext: - # This is used for the name of the .pot and .po files; they will be - # called <project_name>.pot? - project_name: puppetlabs-translate - # This is used in comments in the .pot and .po files to indicate what - # project the files belong to and should bea little more desctiptive than - # <project_name> - package_name: puppetlabs-translate - # The locale that the default messages in the .pot file are in - default_locale: en - # The email used for sending bug reports. - bugs_address: docs@puppet.com - # The holder of the copyright. - copyright_holder: Puppet, Inc. - # This determines which comments in code should be eligible for translation. - # Any comments that start with this string will be externalized. (Leave - # empty to include all.) - comments_tag: TRANSLATOR - # Patterns for +Dir.glob+ used to find all files that might contain - # translatable content, relative to the project root directory - source_files: - - './lib/**/*.rb' -
--- a/modules/translate/metadata.json Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -{ - "name": "puppetlabs-translate", - "version": "2.1.0", - "author": "puppetlabs", - "summary": "Puppet module that provides the translate() function for internationalization.", - "license": "Apache-2.0", - "source": "https://github.com/puppetlabs/puppetlabs-translate", - "project_page": "https://github.com/puppetlabs/puppetlabs-translate", - "issues_url": "https://github.com/puppetlabs/puppetlabs-translate/issues", - "dependencies": [ - - ], - "data_provider": null, - "operatingsystem_support": [ - { - "operatingsystem": "Debian", - "operatingsystemrelease": [ - "8", - "9", - "10" - ] - }, - { - "operatingsystem": "RedHat", - "operatingsystemrelease": [ - "5", - "6", - "7", - "8" - ] - }, - { - "operatingsystem": "CentOS", - "operatingsystemrelease": [ - "8" - ] - }, - { - "operatingsystem": "Ubuntu", - "operatingsystemrelease": [ - "14.04", - "16.04" - ] - }, - { - "operatingsystem": "Windows", - "operatingsystemrelease": [ - "2012", - "2016", - "2018", - "10" - ] - } - ], - "requirements": [ - { - "name": "puppet", - "version_requirement": ">= 5.5.10 < 7.0.0" - } - ], - "pdk-version": "1.14.1", - "template-url": "https://github.com/puppetlabs/pdk-templates#master", - "template-ref": "tags/1.14.1-0-g0b5b39b" -}
--- a/modules/translate/provision.yaml Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -default: - provisioner: vmpooler - images: ['redhat-8-x86_64'] -travis_deb: - provisioner: docker - images: ['debian:8', 'debian:9', 'ubuntu:14.04', 'ubuntu:16.04', 'ubuntu:18.04'] -travis_el: - provisioner: docker - images: ['centos:6', 'centos:7', 'oraclelinux:6', 'oraclelinux:7', 'scientificlinux/sl:6', 'scientificlinux/sl:7'] -vagrant: - provisioner: vagrant - images: ['centos/7', 'generic/ubuntu1804', 'gusztavvargadr/windows-server'] -release_checks: - provisioner: vmpooler - images: ['debian-8-x86_64', 'debian-9-x86_64', 'debian-10-x86_64', 'ubuntu-1604-x86_64', 'redhat-5-x86_64', 'redhat-6-x86_64', 'redhat-7-x86_64', 'redhat-8-x86_64', 'centos-8-x86_64', 'sles-11-x86_64', 'sles-12-x86_64', 'win-2008r2-x86_64', 'win-2016-core-x86_64', 'win-2012r2-core-x86_64', 'win-10-ent-x86_64']
--- a/modules/translate/spec/acceptance/spec_helper_acceptance.rb Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -# frozen_string_literal: true - -require 'serverspec' -require 'puppet_litmus' -require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb')) -include PuppetLitmus - -if ENV['TARGET_HOST'].nil? || ENV['TARGET_HOST'] == 'localhost' - puts 'Running tests against this machine !' - if Gem.win_platform? - set :backend, :cmd - else - set :backend, :exec - end -else - # load inventory - inventory_hash = inventory_hash_from_inventory_file - node_config = config_from_node(inventory_hash, ENV['TARGET_HOST']) - - if target_in_group(inventory_hash, ENV['TARGET_HOST'], 'docker_nodes') - host = ENV['TARGET_HOST'] - set :backend, :docker - set :docker_container, host - elsif target_in_group(inventory_hash, ENV['TARGET_HOST'], 'ssh_nodes') - set :backend, :ssh - options = Net::SSH::Config.for(host) - options[:user] = node_config.dig('ssh', 'user') unless node_config.dig('ssh', 'user').nil? - options[:port] = node_config.dig('ssh', 'port') unless node_config.dig('ssh', 'port').nil? - options[:keys] = node_config.dig('ssh', 'private-key') unless node_config.dig('ssh', 'private-key').nil? - options[:password] = node_config.dig('ssh', 'password') unless node_config.dig('ssh', 'password').nil? - options[:verify_host_key] = Net::SSH::Verifiers::Null.new unless node_config.dig('ssh', 'host-key-check').nil? - host = if ENV['TARGET_HOST'].include?(':') - ENV['TARGET_HOST'].split(':').first - else - ENV['TARGET_HOST'] - end - set :host, options[:host_name] || host - set :ssh_options, options - set :request_pty, true - elsif target_in_group(inventory_hash, ENV['TARGET_HOST'], 'winrm_nodes') - require 'winrm' - - set :backend, :winrm - set :os, family: 'windows' - user = node_config.dig('winrm', 'user') unless node_config.dig('winrm', 'user').nil? - pass = node_config.dig('winrm', 'password') unless node_config.dig('winrm', 'password').nil? - endpoint = "http://#{ENV['TARGET_HOST']}:5985/wsman" - - opts = { - user: user, - password: pass, - endpoint: endpoint, - operation_timeout: 300, - } - - winrm = WinRM::Connection.new opts - Specinfra.configuration.winrm = winrm - end -end
--- a/modules/translate/spec/acceptance/translate_spec.rb Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -describe 'an example' do - it 'is a pending example' -end
--- a/modules/translate/spec/default_facts.yml Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -# Use default_module_facts.yml for module specific facts. -# -# Facts specified here will override the values provided by rspec-puppet-facts. ---- -ipaddress: "172.16.254.254" -ipaddress6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" -is_pe: false -macaddress: "AA:AA:AA:AA:AA:AA"
--- a/modules/translate/spec/functions/translate_spec.rb Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -require 'spec_helper' - -describe 'translate' do - it { is_expected.not_to eq nil } - it { is_expected.to run.with_params('test string') } - it { is_expected.to run.with_params(123).and_raise_error(ArgumentError) } - it { is_expected.to run.with_params('test string', 123).and_raise_error(ArgumentError) } - it { is_expected.to run.with_params('test %{interpolate_this}', 'interpolate_this' => 'ok').and_return('test ok') } - it { is_expected.to run.and_raise_error(ArgumentError) } -end
--- a/modules/translate/spec/spec_helper.rb Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -RSpec.configure do |c| - c.mock_with :rspec -end - -require 'puppetlabs_spec_helper/module_spec_helper' -require 'rspec-puppet-facts' - -require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) - -include RspecPuppetFacts - -default_facts = { - puppetversion: Puppet.version, - facterversion: Facter.version, -} - -default_fact_files = [ - File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')), - File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')), -] - -default_fact_files.each do |f| - next unless File.exist?(f) && File.readable?(f) && File.size?(f) - - begin - default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) - rescue => e - RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" - end -end - -# read default_facts and merge them over what is provided by facterdb -default_facts.each do |fact, value| - add_custom_fact fact, value -end - -RSpec.configure do |c| - c.default_facts = default_facts - c.before :each do - # set to strictest setting for testing - # by default Puppet runs at warning level - Puppet.settings[:strict] = :warning - end - c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] - c.after(:suite) do - RSpec::Puppet::Coverage.report!(0) - end -end - -# Ensures that a module is defined -# @param module_name Name of the module -def ensure_module_defined(module_name) - module_name.split('::').reduce(Object) do |last_module, next_module| - last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false) - last_module.const_get(next_module, false) - end -end - -# 'spec_overrides' from sync.yml will appear below this line
--- a/modules/translate/spec/spec_helper_local.rb Thu Aug 29 18:47:29 2024 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -if ENV['COVERAGE'] == 'yes' - require 'simplecov' - require 'simplecov-console' - require 'codecov' - - SimpleCov.formatters = [ - SimpleCov::Formatter::HTMLFormatter, - SimpleCov::Formatter::Console, - SimpleCov::Formatter::Codecov, - ] - SimpleCov.start do - track_files 'lib/**/*.rb' - - add_filter '/spec' - - # do not track vendored files - add_filter '/vendor' - add_filter '/.vendor' - - # do not track gitignored files - # this adds about 4 seconds to the coverage check - # this could definitely be optimized - add_filter do |f| - # system returns true if exit status is 0, which with git-check-ignore means file is ignored - system("git check-ignore --quiet #{f.filename}") - end - end -end