diff --git a/.ruby-gemset b/.ruby-gemset new file mode 100644 index 0000000..f5c9f65 --- /dev/null +++ b/.ruby-gemset @@ -0,0 +1 @@ +puppet-ulimit diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..8dbb0f2 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.1.10 diff --git a/Gemfile b/Gemfile index ddf6bff..f366309 100644 --- a/Gemfile +++ b/Gemfile @@ -1,21 +1,21 @@ source 'https://rubygems.org' -puppetversion = ENV.key?('PUPPET_VERSION') ? "~> #{ENV['PUPPET_VERSION']}" : ['>= 3.8.1'] -gem 'puppet', puppetversion +gem 'falkorlib' #, :path => '~/git/github.com/Falkor/falkorlib' -if puppetversion =~ /^3/ - ## rspec-hiera-puppet is puppet 3 only - gem 'rspec-hiera-puppet', '>=1.0.0' +group :test do + gem "rake" + gem "puppet", ENV['PUPPET_GEM_VERSION'] || '~> 4.10.0' + gem 'puppet-strings' + gem 'puppetlabs_spec_helper' + gem 'metadata-json-lint' + gem "puppet-lint-absolute_classname-check" + gem "puppet-lint-leading_zero-check" + gem "puppet-lint-trailing_comma-check" + gem "puppet-lint-version_comparison-check" + gem "puppet-lint-classes_and_types_beginning_with_digits-check" + gem "puppet-lint-unquoted_string-check" + gem 'puppet-lint-resource_reference_syntax' + gem 'puppet-syntax' end -facterversion = ENV.key?('FACTER_VERSION') ? "~> #{ENV['FACTER_VERSION']}" : ['>= 2.4.4'] - -gem 'facter', facterversion - -gem 'rake' -gem 'rspec' -gem 'puppet-lint', '>=1.1.0' -gem 'rspec-puppet', :git => 'https://github.com/rodjek/rspec-puppet.git' -gem 'puppetlabs_spec_helper', '>=0.10.3' -gem 'puppet-syntax' - +require 'falkorlib/tasks/puppet' diff --git a/Gemfile.lock b/Gemfile.lock index b2aa50c..80387ff 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,60 +1,142 @@ -GIT - remote: https://github.com/rodjek/rspec-puppet.git - revision: ee85f33a47a671207f0c88713e1c82a55c096081 - specs: - rspec-puppet (2.3.0) - rspec - GEM remote: https://rubygems.org/ specs: - CFPropertyList (2.2.8) - diff-lcs (1.2.5) - facter (2.4.4) - CFPropertyList (~> 2.2.6) - hiera (2.0.0) - json_pure - json_pure (1.8.2) + activesupport (4.2.10) + i18n (~> 0.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + addressable (2.5.2) + public_suffix (>= 2.0.2, < 4.0) + artii (2.1.2) + awesome_print (1.8.0) + configatron (3.2.0) + deep_merge (1.0.1) + diff-lcs (1.3) + diffy (3.2.0) + facter (2.4.6) + falkorlib (0.7.9) + activesupport (~> 4.0) + artii (>= 2.1) + awesome_print (~> 1.2) + configatron (~> 3.2) + deep_merge (~> 1.0.1) + diffy (>= 3.0) + facter (~> 2.4.1) + git_remote_branch (~> 0) + json (~> 1.8) + license-generator (~> 0) + logger (>= 1.2.8) + minigit (~> 0) + rake (~> 10.1, >= 10.1.0) + term-ansicolor (~> 1.3) + thor (>= 0.19) + thor-zsh_completion + fast_gettext (1.1.0) + gettext (3.2.4) + locale (>= 2.0.5) + text (>= 1.3.0) + gettext-setup (0.28) + fast_gettext (~> 1.1.0) + gettext (>= 3.0.2) + locale + git_remote_branch (0.3.8) + hiera (3.4.2) + i18n (0.8.6) + json (1.8.6) + json-schema (2.8.0) + addressable (>= 2.4) + json_pure (1.8.6) + license-generator (0.4.1) + thor + locale (2.1.2) + logger (1.2.8) metaclass (0.0.4) - mocha (1.1.0) + metadata-json-lint (2.0.2) + json-schema (~> 2.8) + spdx-licenses (~> 1.0) + minigit (0.0.4) + minitest (5.10.3) + mocha (1.3.0) metaclass (~> 0.0.1) - puppet (4.1.0) + public_suffix (3.0.0) + puppet (4.10.8) facter (> 2.0, < 4) - hiera (>= 2.0, < 3) - json_pure - puppet-lint (1.1.0) - puppet-syntax (2.0.0) + gettext-setup (>= 0.10, < 1) + hiera (>= 2.0, < 4) + json_pure (~> 1.8) + locale (~> 2.1) + puppet-lint (2.3.3) + puppet-lint-absolute_classname-check (0.2.4) + puppet-lint (>= 1.0, < 3.0) + puppet-lint-classes_and_types_beginning_with_digits-check (0.1.2) + puppet-lint (>= 1.0, < 3.0) + puppet-lint-leading_zero-check (0.1.1) + puppet-lint (>= 1.0, < 3.0) + puppet-lint-resource_reference_syntax (1.0.10) + puppet-lint (>= 1.0, < 3.0) + puppet-lint-trailing_comma-check (0.3.2) + puppet-lint (>= 1.0, < 3.0) + puppet-lint-unquoted_string-check (0.3.0) + puppet-lint (>= 1.0, < 3.0) + puppet-lint-version_comparison-check (0.2.1) + puppet-lint (>= 1.0, < 3.0) + puppet-strings (1.1.0) + yard (~> 0.9.5) + puppet-syntax (2.4.1) rake - puppetlabs_spec_helper (0.10.3) - mocha - puppet-lint - puppet-syntax - rake - rspec-puppet - rake (10.4.2) - rspec (3.2.0) - rspec-core (~> 3.2.0) - rspec-expectations (~> 3.2.0) - rspec-mocks (~> 3.2.0) - rspec-core (3.2.3) - rspec-support (~> 3.2.0) - rspec-expectations (3.2.1) + puppetlabs_spec_helper (2.3.2) + mocha (~> 1.0) + puppet-lint (~> 2.0) + puppet-syntax (~> 2.0) + rspec-puppet (~> 2.0) + rake (10.5.0) + rspec (3.6.0) + rspec-core (~> 3.6.0) + rspec-expectations (~> 3.6.0) + rspec-mocks (~> 3.6.0) + rspec-core (3.6.0) + rspec-support (~> 3.6.0) + rspec-expectations (3.6.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.2.0) - rspec-mocks (3.2.1) + rspec-support (~> 3.6.0) + rspec-mocks (3.6.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.2.0) - rspec-support (3.2.2) + rspec-support (~> 3.6.0) + rspec-puppet (2.6.9) + rspec + rspec-support (3.6.0) + spdx-licenses (1.1.0) + term-ansicolor (1.6.0) + tins (~> 1.0) + text (1.3.1) + thor (0.20.0) + thor-zsh_completion (0.1.4) + thor (~> 0) + thread_safe (0.3.6) + tins (1.15.0) + tzinfo (1.2.3) + thread_safe (~> 0.1) + yard (0.9.9) PLATFORMS ruby DEPENDENCIES - facter (>= 2.4.4) - puppet (>= 3.8.1) - puppet-lint (>= 1.1.0) + falkorlib + metadata-json-lint + puppet (~> 4.10.0) + puppet-lint-absolute_classname-check + puppet-lint-classes_and_types_beginning_with_digits-check + puppet-lint-leading_zero-check + puppet-lint-resource_reference_syntax + puppet-lint-trailing_comma-check + puppet-lint-unquoted_string-check + puppet-lint-version_comparison-check + puppet-strings puppet-syntax - puppetlabs_spec_helper (>= 0.10.3) + puppetlabs_spec_helper rake - rspec - rspec-puppet! + +BUNDLED WITH + 1.15.4 diff --git a/LICENSE b/LICENSE index b58f924..a394872 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ - Copyright (C) 2012 Tom De Vylder + Copyright (C) 2012-2017 Tom De Vylder, Sebastien Varrette Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index ff497f5..dbf30e8 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,148 @@ -# Puppet Ulimit +-*- mode: markdown; mode: visual-line; -*- -## Requirements +# Ulimit Puppet Module -## Tested on... +[![Puppet Forge](http://img.shields.io/puppetforge/v/svarrette/ulimit.svg)](https://forge.puppet.com/svarrette/ulimit) [![License](http://img.shields.io/:license-Apache2.0-blue.svg)](LICENSE) ![Supported Platforms](http://img.shields.io/badge/platform-debian|redhat|centos-lightgrey.svg) + + Copyright (c) 2015-2017 Tom De Vylder (aka arioch), Sebastien Varrette (aka Falkor) + +[ulimit](https://ss64.com/bash/ulimit.html) provides control over the resources available to the shell and to processes started by it, on systems that allow such control. + +This [Puppet](https://puppet.com/) module is designed to configure and manage ulimits on your Linux system, mainly with the `ulimit::rule` definition which permits to define soft and/or hard limits over various domains. + +* The soft limit is the value that the kernel enforces for the corresponding resource. +* The hard limit acts as a ceiling for the soft limit. + + +**`/! IMPORTANT`: This module is a fork from [arioch/puppet-ulimit](https://github.com/arioch/puppet-ulimit/)!!!** +This was done to allow a version release on my own namespace compliant with Puppet 4 until [Tom/arioch](https://github.com/arioch) released the official new version on his module. +In the mean time, I added more features (vagrant-based tests, support for arrays, content and source) yet **this module is expected to disappear** once [Tom/arioch](https://github.com/arioch) (hopefully) integrate my pull-request. + +In particular, this module implements the following elements: + +* class `ulimit`: The main class, piloting all aspects of the configuration +* class `ulimit::config`: an **internal** class taking care of global configurations and defaults +* definition `ulimit::rule`: permiting to define a rule in `'/etc/security/limits.d/'` + +All these components are configured through a set of variables you will find in [`manifests/params.pp`](https://github.com/Falkor/puppet-ulimit/blob/master/manifests/params.pp). + +### Setup Requirements + +This module have been successfully over Puppet 4.x. with: * Debian 5 (Lenny) * Debian 6 (Squeeze) * CentOS 5 * CentOS 6 * CentOS 7 +* RedHat 6 +* RedHat 7 -## Example usage +Over operating systems and support for Puppet 5.x will eventually be added. +Yet feel free to contribute to this module to help us extending the usage of this module. + +## Forge Module Dependencies + +See [`metadata.json`](https://github.com/Falkor/puppet-ulimit/blob/master/metadata.json). +In particular, this module depends on + +* [puppetlabs/stdlib](https://forge.puppetlabs.com/puppetlabs/stdlib) + +## Overview and Usage + +See also [`tests/rule.pp`](https://github.com/Falkor/puppet-ulimit/blob/master/tests/rule.pp) + +--------------- +```ruby +include ::ulimit + +::ulimit::rule{ 'example1': + ulimit_domain => '*', + ulimit_type => 'soft', + ulimit_item => 'nofile', + ulimit_value => '1024', +} +``` + +This will create the file `/etc/security/limits.d/80_example1.conf` with the following content: + + * soft nofile 1024 + +------------- +```ruby +include ::ulimit + +::ulimit::rule{ 'example2': + ulimit_domain => '*', + ulimit_type => 'soft', + ulimit_item => 'nofile', + ulimit_value => '1024', +} +``` + +This will create the file `/etc/security/limits.d/80_example2.conf` with the following content: + + * hard nproc 1024 + * hard nofile 1024 + +--------------- +```ruby +::ulimit::rule{ 'slurm': + ensure => 'present', + ulimit_domain => '*', + ulimit_type => [ 'soft', 'hard' ], + ulimit_item => [ 'memlock', 'stack' ], + ulimit_value => 'unlimited', +} +``` + + This will create the file `/etc/security/limits.d/80_slurm.conf` with the + following content: + + * soft memlock unlimited + * soft stack unlimited + * hard memlock unlimited + * hard stack unlimited + + +---------------- +```ruby +::ulimit::rule{ 'slurm-nproc': + ensure => 'present', + priority => 50, + ulimit_domain => '*', + ulimit_type => [ 'soft', 'hard' ], + ulimit_item => 'nproc', + ulimit_value => '10240', +} +``` + +This statement should create `/etc/security/limits.d/50_slurm-nproc.conf` with the following content: + + * soft nproc 10240 + * hard nproc 10240 + +--------------- +You can also pass the content yourself -- below statement will create `/etc/security/limits.d/60_content.conf` with that content + +```ruby +::ulimit::rule{ 'content': + ensure => 'present', + priority => 60, + content => template('ulimit/test.erb'), +} +``` + +... or pass directly the source file -- below statement will create `/etc/security/limits.d/70_source.conf` with that content: + +```ruby +::ulimit::rule{ 'source': + ensure => 'present', + priority => 70, + source => 'puppet:///modules/ulimit/test.conf', +} +``` - node /box/ { - include ulimit - - ulimit::rule { - 'example1': - ulimit_domain => '*', - ulimit_type => 'soft', - ulimit_item => 'nofile', - ulimit_value => '1024'; - - 'example2': - ensure => absent, - ulimit_domain => '*', - ulimit_type => 'hard', - ulimit_item => 'nofile', - ulimit_value => '50000'; - } - } ## Caveats @@ -42,3 +155,25 @@ While not advised you can disable this feature: } } +## Developments / Contributing to the code + +You are more than welcome to contribute to the development of this module. +Kindly proceed as follows: + +1. Fork it +2. Create your feature branch (`git checkout -b feature/`) +3. Commit your changes (`git commit -am 'Added some feature'`) +4. Push to the branch (`git flow feature publish `) +5. Create new [Pull request](https://help.github.com/articles/using-pull-requests). + +## Puppet modules tests within a Vagrant box + +The best way to test this module in a non-intrusive way is to rely on [Vagrant](http://www.vagrantup.com/). +The `Vagrantfile` at the root of the repository pilot the provisioning various vagrant boxes available on [Vagrant cloud](https://atlas.hashicorp.com/boxes/search?utf8=%E2%9C%93&sort=&provider=virtualbox&q=svarrette) you can use to test this module. + +## Licence + +This project and the sources proposed within this repository are released under the terms of the [Apache-2.0](LICENCE) licence. + + +[![Licence](https://www.apache.org/images/feather-small.gif)](LICENSE) diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..a3648d9 --- /dev/null +++ b/Rakefile @@ -0,0 +1,36 @@ +############################################################################## +# Rakefile - Configuration file for rake (http://rake.rubyforge.org/) +# Time-stamp: +# +# Copyright (c) 2017 <> +# ____ _ __ _ _ +# | _ \ __ _| | _____ / _(_) | ___ +# | |_) / _` | |/ / _ \ |_| | |/ _ \ +# | _ < (_| | < __/ _| | | __/ +# |_| \_\__,_|_|\_\___|_| |_|_|\___| +# +# Use 'rake -T' to list the available actions +# +# Resources: +# * http://www.stuartellis.eu/articles/rake/ +############################################################################## +require 'falkorlib' +require 'puppetlabs_spec_helper/rake_tasks' + +## placeholder for custom configuration of FalkorLib.config.* +## See https://github.com/Falkor/falkorlib + +FalkorLib.config.versioning do |c| + c[:type] = 'puppet_module' +end + +# Git flow customization +FalkorLib.config.gitflow do |c| + c[:branches] = { + :master => 'production', + :develop => 'master' + } +end + +require 'falkorlib/tasks/git' +require 'falkorlib/tasks/puppet' diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..29df3fe --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,140 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : +# Time-stamp: +########################################################################################### +# __ __ _ __ _ _ +# \ \ / /_ _ __ _ _ __ __ _ _ __ | |_ / _(_) | ___ +# \ \ / / _` |/ _` | '__/ _` | '_ \| __| |_| | |/ _ \ +# \ V / (_| | (_| | | | (_| | | | | |_| _| | | __/ +# \_/ \__,_|\__, |_| \__,_|_| |_|\__|_| |_|_|\___| +# |___/ +########################################################################################### +require 'yaml' +require 'ipaddr' +require 'deep_merge' + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" +TOP_SRCDIR = File.expand_path File.dirname(__FILE__) +TOP_VAGRANT_TESTDIR = File.join(TOP_SRCDIR, 'tests', 'vagrant') +config_file = File.join(TOP_VAGRANT_TESTDIR, 'config.yaml') + +###### Expected Vagrant plugins detection ###### +# For more information on the below plugins: +# - https://github.com/oscar-stack/vagrant-hosts +# - https://github.com/dotless-de/vagrant-vbguest +# - https://github.com/emyl/vagrant-triggers +# - https://github.com/fgrehm/vagrant-cachier +# Terminal-table is a nice ruby gem for automatically print tables with nice layout +### +[ 'vagrant-hosts', 'vagrant-vbguest', 'vagrant-triggers', 'vagrant-cachier', 'terminal-table' ].each do |plugin| + abort "Install the '#{plugin}' plugin with 'vagrant plugin install #{plugin}'" unless Vagrant.has_plugin?("#{plugin}") +end +require 'terminal-table' + +### Default settings ### +DEFAULT_SETTINGS = { + :defaults => { + :os => :centos7, + :ram => 256, + :vcpus => 1, + :vbguest_auto_update => true, + }, + # Default domain settings + :network => { + :domain => 'vagrant.dev', + :range => '10.10.1.0/24', + :ip_offset => 10, + }, + # Default Boxes + :boxes => { + :centos7 => 'centos/7', + :debian8 => 'debian/contrib-jessie64', + :ubuntu14 => 'ubuntu/trusty64' + }, + :vms => { + 'default' => { } + }, +} + +# List of default provisioning scripts +DEFAULT_PROVISIONING_SCRIPTS = [ + "tests/vagrant/bootstrap.sh", + "tests/vagrant/puppet_modules_setup.rb" +] + +# Load the settings (eventually overwritten using values from the yaml file 'config.yaml') +settings = DEFAULT_SETTINGS.clone +if File.exist?(config_file) + config = YAML::load_file config_file + settings.deep_merge!( config ) if config +end +abort "Undefined settings" if settings.nil? + + +############################################################ +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + defaults = settings[:defaults] + network = settings[:network] + + ### Common configs shared by all VMs ### + # Cache plugin -- Supports local cache, so you don't wast bandwitdh + # vagrant plugin install vagrant-cachier # see https://github.com/fgrehm/vagrant-cachier + config.cache.auto_detect = true if Vagrant.has_plugin?("vagrant-cachier") + + # check if VirtualBox Guest Additions are up to date + if Vagrant.has_plugin?("vagrant-vbguest") + # set auto_update to false, if you do NOT want to check the correct + # additions version when booting these boxes + config.vbguest.auto_update = defaults[:vbguest_auto_update] + end + + # Shell provisioner, to setup minimal conditions for Puppet provisioning + DEFAULT_PROVISIONING_SCRIPTS.each do |script| + config.vm.provision "shell", path: "#{script}", keep_color: true + end + config.vm.synced_folder ".", "/vagrant", type: "virtualbox" + + # network settings + ipaddr = IPAddr.new network[:range] + ip_range = ipaddr.to_range.to_a + + # cosmetics for the post-up message + __table = { + :title => "Puppet Testing infrastructure deployed on Vagrant", + :headings => [ 'Name', 'Hostname', 'OS', 'vCPU/RAM', 'Description', 'IP' ], + :rows => [], + } + #__________________________________ + settings[:vms].each do |name, node| + boxname = 'ulimit-' + defaults[:os].to_s.downcase.gsub(/([^\d]+)(\d+)/, '\\1-\\2') + name = boxname if name == 'default' + hostname = node[:hostname] ? node[:hostname] : name + domain = network[:domain] + fqdn = "#{hostname}.#{domain}" + os = node[:os] ? node[:os].to_sym : defaults[:os].to_sym + ram = node[:ram] ? node[:ram] : defaults[:ram] + vcpus = node[:vcpus] ? node[:vcpus] : defaults[:vcpus] + desc = node[:desc] ? node[:desc] : 'n/a' + + abort "Non-existing box OS '#{os}' for the VM '#{name}'" if settings[:boxes][os.to_sym].nil? + abort "Empty IP address range" if ip_range.empty? + ip = ip_range[ network[:ip_offset].to_i ].to_s + + config.vm.define "#{name}" do |c| + c.vm.box = settings[:boxes][os.to_sym] + c.vm.hostname = "#{fqdn}" + c.vm.network :private_network, :ip => ip + c.vm.provision :hosts, :sync_hosts => true + c.vm.provider "virtualbox" do |v| + v.customize [ 'modifyvm', :id, '--name', hostname, '--memory', ram.to_s ] + v.customize [ 'modifyvm', :id, '--cpus', vcpus.to_s ] if vcpus.to_i > 1 + end + __table[:rows] << [ name, fqdn, os.to_sym, "#{vcpus}/#{ram}", desc, ip] + end + end + + config.trigger.after :up do + puts Terminal::Table.new __table + end +end diff --git a/files/test.conf b/files/test.conf new file mode 100644 index 0000000..12d1731 --- /dev/null +++ b/files/test.conf @@ -0,0 +1,14 @@ +# -*- mode: conf; -*- +################################################################################### +# /!\ DO NOT EDIT THIS FILE: It has been automatically generated by Puppet. +# In particular, any further changes will be overwritten at the next puppet +# invocation +################################################################################### +# Direct source example +# +# +# +* hard memlock unlimited +* soft memlock unlimited +* hard nproc 10240 +* soft nproc 10240 diff --git a/manifests/config.pp b/manifests/config.pp index bd1db7c..c9f96f8 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,5 +1,16 @@ +################################################################################ +# Time-stamp: +# +# File:: config.pp +# Author:: Tom De Vylder, Sebastien Varrette +# Copyright:: Copyright (c) 2015-2017 arioch,Falkor +# License:: Apache-2.0 +# +# ------------------------------------------------------------------------------ # == Class: ulimit::config # +# This PRIVATE class handles the configuration of ulimit +# class ulimit::config { File { group => $::ulimit::config_group, @@ -17,4 +28,3 @@ } } - diff --git a/manifests/init.pp b/manifests/init.pp index 7b3ae96..0985c8e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,20 +1,39 @@ +################################################################################ +# Time-stamp: +# +# File:: init.pp +# Author:: Tom De Vylder, Sebastien Varrette +# Copyright:: Copyright (c) 2015-2017 arioch,Falkor +# License:: Apache-2.0 +# +# ------------------------------------------------------------------------------ # == Class: ulimit # -# === Parameters +# ulimit provides control over the resources available to the shell and to +# processes started by it, on systems that allow such control. +# This class offers the ulimit::rule definition which permits to define soft +# and/or hard limits over various domains. +# - The soft limit is the value that the kernel enforces for the corresponding +# resource. +# - The hard limit acts as a ceiling for the soft limit. # -# [*use_default_ulimits*] -# Boolean. If true, then default ulimit configuration for the OS/release is -# applied (if found) -# Default: true +# @param config_dir [String] Default: '/etc/security/limits.d' +# @param config_group [String] Default: 'root' +# @param config_user [String] Default: 'root' +# @param use_default_ulimits [String] Default: true +# If true, then default ulimit configuration for the OS/release is +# applied (if found) +# @param purge [String] Default: true # class ulimit ( - $config_dir = $ulimit::params::config_dir, - $config_group = $ulimit::params::config_group, - $config_user = $ulimit::params::config_user, - $use_default_ulimits = $ulimit::params::use_default_ulimits, - $purge = $ulimit::params::purge, -) inherits ::ulimit::params { + String $config_dir = $ulimit::params::config_dir, + String $config_group = $ulimit::params::config_group, + String $config_user = $ulimit::params::config_user, + Boolean $use_default_ulimits = $ulimit::params::use_default_ulimits, + Boolean $purge = $ulimit::params::purge, +) +inherits ::ulimit::params +{ $default_ulimits = $ulimit::params::default_ulimits include ::ulimit::config } - diff --git a/manifests/params.pp b/manifests/params.pp index c7a96bf..ad1b024 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,6 +1,26 @@ +################################################################################ +# Time-stamp: +# +# File:: params.pp +# Author:: Tom De Vylder, Sebastien Varrette +# Copyright:: Copyright (c) 2015-2017 arioch,Falkor +# License:: Apache-2.0 +# +# ------------------------------------------------------------------------------ # == Class: ulimit::params # +# In this class are defined as default variables values that are used in all +# other ulimit classes and definitions. +# This class should be included, where necessary, and eventually be enhanced +# with support for more Operating Systems. +# +# class ulimit::params { + + #### MODULE INTERNAL VARIABLES ######### + # (Modify to adapt to unsupported OSes) + ######################################### + $config_dir = '/etc/security/limits.d' $config_group = 'root' $config_user = 'root' @@ -20,14 +40,14 @@ # pam package on EL6 creates 90-nproc.conf $default_ulimits = { 'nproc_user_defaults' => { - 'priority' => '90', + 'priority' => 90, 'ulimit_domain' => '*', 'ulimit_item' => 'nproc', 'ulimit_type' => 'soft', 'ulimit_value' => '1024', }, 'nproc_root_defaults' => { - 'priority' => '90', + 'priority' => 90, 'ulimit_domain' => 'root', 'ulimit_item' => 'nproc', 'ulimit_type' => 'soft', @@ -38,14 +58,14 @@ # pam package on EL7 creates 20-nproc.conf $default_ulimits = { 'nproc_user_defaults' => { - 'priority' => '20', + 'priority' => 20, 'ulimit_domain' => '*', 'ulimit_item' => 'nproc', 'ulimit_type' => 'soft', 'ulimit_value' => '4096', }, 'nproc_root_defaults' => { - 'priority' => '20', + 'priority' => 20, 'ulimit_domain' => 'root', 'ulimit_item' => 'nproc', 'ulimit_type' => 'soft', @@ -61,4 +81,3 @@ } } } - diff --git a/manifests/rule.pp b/manifests/rule.pp index 9ea77ab..5f70acf 100644 --- a/manifests/rule.pp +++ b/manifests/rule.pp @@ -1,9 +1,38 @@ +################################################################################ +# Time-stamp: +# +# File:: rule.pp +# Author:: Tom De Vylder, Sebastien Varrette +# Copyright:: Copyright (c) 2015-2017 arioch,Falkor +# License:: Apache-2.0 +# +# ------------------------------------------------------------------------------ # == Define: ulimit::rule # +# Add a new ulimit rule within /etc/security/limits.d/ +# # === Parameters: # -# $ulimit_domain:: Domain -# can be: +# @param ensure [String] Default: 'present'. +# Ensure the presence (or absence) of the ulimit rule +# @param content [String] +# The desired contents of a file, as a string. This attribute is +# mutually exclusive with source and target. +# See also +# https://docs.puppet.com/puppet/latest/types/file.html#file-attribute-content +# @param priority [Integer] Default: 80 +# Priority of the file, i.e. this rule will create the file +# '/etc/security/limits.d/_