Git Product home page Git Product logo

pupmod-simp-simplib's Introduction

License CII Best Practices Puppet Forge Puppet Forge Downloads Build Status

Table of Contents

This is a SIMP module

This module is a component of the System Integrity Management Platform, a compliance-management framework built on Puppet.

If you find any issues, they can be submitted to our JIRA.

Module Description

simp-simplib provides a standard library of resources commonly used by SIMP modules but generally suited for any Puppet environment.

Setup

What simplib affects

simplib contains data types, custom types and providers, facts, functions, and a class that expands puppetlabs-stdlib stages.

Setup Requirements

Agents will need to enable pluginsync.

Usage

Please see reference for usage.

Reference

Items not covered by puppet strings are provided below.

See REFERENCE.md for all other reference documentation.

Facts

  • acpid_enabled - Return true if ACPI is available on the system
  • boot_dir_uuid - Return the UUID of the partition holding the boot directory
  • cmdline - Returns the contents of /proc/cmdline as a hash
  • cpuinfo - Returns the contents of /proc/cpuinfo as a hash
  • defaultgateway - Return the default gateway of the system
  • defaultgatewayiface - Return the default gw interface of the system
  • fips_ciphers - Returns a list of available OpenSSL ciphers
  • fips_enabled - Determine whether FIPS is enabled on this system
  • fullrun - Determine whether to do an intensive run
  • gdm_version - Return the version of GDM that is installed
  • grub_version - Return the grub version installed on the system
  • init_systems - Return a list of all init systems present on the system
  • ipa - Return a hash containing the IPA domain and server to which a host is connected
  • ipv6_enabled - Return true if IPv6 is enabled and false if not
  • login_defs - Return the contents of /etc/login.defs as a hash with downcased keys
  • prelink - Returns a hash containing prelink status
  • reboot_required - Returns a hash of 'name' => 'reason' entries
  • root_dir_uuid - Return the UUID of the partition holding the / directory
  • runlevel - Return the current system runlevel
  • shmall - Return the value of shmall from sysctl
  • simplib__efi_enabled - Returns true if the system is using EFI
  • simplib__secure_boot_enabled - Returns true if the host is using uEFI Secure Boot
  • simplib__firewalls - Return an array of known firewall commands that are present on the system.
  • simplib__mountpoints - Return a hash of mountpoints of particular interest to SIMP modules.
  • simplib__numa - Return hash of numa values about your system.
  • simplib_sysctl - Return hash of sysctl values that are relevant to SIMP
  • simp_puppet_settings - Returns a hash of all Puppet settings on a node
  • tmp_mounts - DEPRECATED - use simplib__mountpoints This fact provides information about /tmp, /var/tmp, and /dev/shm should they be present on the system
  • uid_min - Return the minimum uid allowed

Run stages

See REFERENCE.md#simplibstages

Puppet extensions

The following methods are Puppet extensions in the PuppetX::SIMP::Simplib namespace:

PuppetX::SIMP::Simplib::hostname?

Determine whether the passed value is a valid hostname, optionally postpended with ':<number>' or '/<number>'.

NOTE: This returns true for an IPv4 address, as it conforms to RFC 1123.

Arguments:

  • obj Input to be assessed

Returns: Boolean false if obj is not comprised of ASCII letters (upper or lower case), digits, hyphens (except at the beginning and end), and dots (except at beginning and end), excluding an optional, trailing ':<number>' or '/<number>'

Examples:

  # Returns true
  PuppetX::SIMP::Simplib.hostname?('hostname.me.com')
  PuppetX::SIMP::Simplib.hostname?('hostname.me.com:5454')

  # Returns false
  PuppetX::SIMP::Simplib.hostname?('-hostname.me.com')

PuppetX::SIMP::Simplib::hostname_only?

Determine whether the passed value is a valid hostname.

NOTE: This returns true for an IPv4 address, as it conforms to RFC 1123.

Arguments:

  • obj Input to be assessed

Returns: Boolean false if obj is not comprised of ASCII letters (upper or lower case), digits, hyphens (except at the beginning and end), and dots (except at beginning and end)

Examples:

  # Returns true
  PuppetX::SIMP::Simplib.hostname_only?('hostname.me.com')

  # Returns false
  PuppetX::SIMP::Simplib.hostname_only?('-hostname.me.com')
  PuppetX::SIMP::Simplib.hostname_only?('hostname.me.com:5454')

PuppetX::SIMP::Simplib::human_sort

Sort a list of values based on usual human sorting semantics.

Arguments:

  • obj Enumerable object to be sorted

Returns: Sorted object

PuppetX::SIMP::Simplib::split_port

Split input string into a [ host, port ] pair

Arguments:

  • host_string String to be split into host and port

Returns: Array[ host, port ] Host and port pair

* Returns ``[ nil, nil ]`` if ``host_string`` is ``nil`` or
  an empty string
* Returns ``[ host_string, nil ]`` if ``host_string`` is
  a CIDR address or contains no port
* Port returned is a string

Examples:

  PuppetX::SIMP::Simplib.split_port('myhost.name:5656')
  # returns ['myhost.name','5656']

  PuppetX::SIMP::Simplib.split_port['192.165.3.9']
  # returns ['192.165.3.9',nil]

  PuppetX::SIMP::Simplib.split_port['192.165.3.9/24']
  # returns ['192.164.3.9/24',nil]

  PuppetX::SIMP::Simplib.split_port('[2001:0db8:85a3:0000:0000:8a2e:0370]:'))
  # returns ['[2001:0db8:85a3:0000:0000:8a2e:0370]',nil]

Development

Please read our Contribution Guide.

If you find any issues, they can be submitted to our JIRA.

pupmod-simp-simplib's People

Contributors

andy-adrian avatar ayohrling avatar benjamin-robertson avatar dforste avatar gitkodak avatar hanej avatar heliocentric avatar jadestorm avatar jcpunk avatar jeannegreulich avatar ke5c2fin avatar kendall-moore avatar klaas- avatar lamawithonel avatar lnemsick-simp avatar logicminds avatar m-morrone avatar michael-riddle avatar op-ct avatar pillarsdotnet avatar ralph-wright avatar raryates avatar rgardner4012 avatar sharkbruhaha avatar silug avatar trevor-vaughan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pupmod-simp-simplib's Issues

assert_optional_dependency should allow for RC versions

Occasionally, users (and tests) will want to work against an upstream Alpha/Beta/RC version of a module.

Currently assert_optional_dependency will fail on these modules creating a worse user (and testing) experience.

The method should be updated to allow for extended versioning.

reboot_notify notify provider craps its pants on EL7 on rpi

Notice: /Stage[main]/Auditd::Config::Grub/Reboot_notify[audit]: Dependency Kernel_parameter[audit] has failures: true
Warning: /Stage[main]/Auditd::Config::Grub/Reboot_notify[audit]: Skipping because of failed dependencies
Error: Could not find a suitable provider for kernel_parameter
Error: post_resource_eval failed for provider Puppet::Type::Reboot_notify::ProviderNotify
# cat /etc/redhat-release 
CentOS Linux release 7.9.2009 (AltArch)

`puppet lookup --compile` changed passgen file ownership

SIMP 6.5.0-2, recurrence of SIMP-7228, caused by #205

puppet lookup --node xxx.yyy.zzz --environment development --explain --compile

Under /opt/puppetlabs/server/data/puppetserver/simp/environments/development/simp_autofiles/gen_passwd, the fil e apache_rsync_development_centos changed ownership to root:puppet and failed.

Code snippet:

password => simplib::passgen("apache_rsync_${::environment}_${_downcase_os_name}")

networkmanager returns null keys for some connections.

There are some cases where a connection is returned without a device attached.
Eg.

# nmcli -t connection show
System ens160:ea74cf24-c2a2-ecee-3747-a2d76d46f93b:802-3-ethernet:ens160
lo:04577901-581b-4cac-bb04-f015fe36274d:loopback:lo
ens160:5780e094-7abe-419a-9c3e-de716150898d:802-3-ethernet:

In this case the key is empty string. I suggest using the name as the ID and creating a device below it.

The current behavior:

# facter -p simplib__networkmanager.connection
{
     => {
      name => "ens160",
      type => "802-3-ethernet",
      uuid => "5780e094-7abe-419a-9c3e-de716150898d"
    },
    ens160 => {
      name => "System ens160",
      type => "802-3-ethernet",
      uuid => "ea74cf24-c2a2-ecee-3747-a2d76d46f93b"
    },
    lo => {
      name => "lo",
      type => "loopback",
      uuid => "04577901-581b-4cac-bb04-f015fe36274d"
    }
}

Proposed behavior:

# facter -p simplib__networkmanager.connection
{
    ens160 => {
      device => "",
      name => "ens160",
      type => "802-3-ethernet",
      uuid => "5780e094-7abe-419a-9c3e-de716150898d"
    },
    System ens160 => {
      device => "ens160",
      name => "System ens160",
      type => "802-3-ethernet",
      uuid => "ea74cf24-c2a2-ecee-3747-a2d76d46f93b"
    },
    lo => {
      device => "lo",
      name => "lo",
      type => "loopback",
      uuid => "04577901-581b-4cac-bb04-f015fe36274d"
    }
}

Spec tests are failing due to facter version

An error occurred while loading ./spec/functions/simplib/simp_version_spec.rb.
Failure/Error:
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts){ os_facts }

    let(:simp_version_path) {
      if os_facts[:kernel].casecmp?('windows')
        'C:\ProgramData\SIMP\simp.version'
      else
        '/etc/simp/simp.version'
      end

RuntimeError:
Can't find SIMP facts for Facter 4.3, skipping...

HINT: If this version of Facter has been released recently, try running

  `FACTER_GEM_VERSION='~> X.Y.0' bundler update facter

Where 'X.Y' is the version of the last facter that worked

./spec/functions/simplib/simp_version_spec.rb:5:in `block in <top (required)>'

./spec/functions/simplib/simp_version_spec.rb:4:in `<top (required)>'

1 deprecation warning total

Finished in 0.00006 seconds (files took 1.61 seconds to load)
0 examples, 0 failures, 3 errors occurred outside of examples

/opt/hostedtoolcache/Ruby/2.7.7/x64/bin/ruby -I/home/runner/work/pupmod-simp-simplib/pupmod-simp-simplib/vendor/bundle/ruby/2.7.0/gems/rspec-core-3.12.1/lib:/home/runner/work/pupmod-simp-simplib/pupmod-simp-simplib/vendor/bundle/ruby/2.7.0/gems/rspec-support-3.12.0/lib /home/runner/work/pupmod-simp-simplib/pupmod-simp-simplib/vendor/bundle/ruby/2.7.0/gems/rspec-core-3.12.1/exe/rspec --pattern spec/{aliases,classes,defines,functions,hosts,integration,plans,tasks,type_aliases,types,unit}/**/*_spec.rb failed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.