Giter Site home page Giter Site logo

puppet-sudo's Introduction

-- mode: markdown; mode: visual-line; --

Sudo Puppet Module

Puppet Forge License Supported Platforms Documentation Status

Configure and manage sudo and sudoers files

  Copyright (c) 2020 UL HPC Team <[email protected]>

| Project Page | Sources | Documentation | Issues |

Synopsis

Manage sudo configuration via Puppet.

This module implements the following elements:

  • Puppet classes:

    • sudo
    • sudo::common
    • sudo::common::debian
    • sudo::common::redhat
    • sudo::params
  • Puppet definitions:

    • sudo::alias::command
    • sudo::alias::host
    • sudo::alias::user
    • sudo::conf
    • sudo::defaults::spec
    • sudo::directive

All these components are configured through a set of variables you will find in manifests/params.pp.

Note: the various operations that can be conducted from this repository are piloted from a Rakefile and assumes you have a running Ruby installation. See docs/contributing.md for more details on the steps you shall follow to have this Rakefile working properly.

Dependencies

See metadata.json. In particular, this module depends on

Overview and Usage

Class sudo

This is the main class defined in this module. Use it as follows:

 include ' sudo'

See also tests/init.pp

Definition sudo::directive

The definition sudo::directive provides a simple way to write sudo configurations parts. If you use a sudo version >= 1.7.2, the sudo directive part is validated via visudo and removed if syntax is not correct. This definition accepts the following parameters:

  • $ensure: default to 'present', can be 'absent' (BEWARE: it will remove the associated file)
  • $content: specify the contents of the directive as a string
  • $source: copy a file as the content of the directive.

Example:

  sudo::directive {'admin_users':
       content => "%admin ALL=(ALL) ALL\n",
  }

  sudo::directive {'vagrant':
    content => "%vagrant ALL=(ALL) NOPASSWD: ALL\n"
  }

On recent version of sudo, this will typically create a new file /etc/sudoers.d/admin_users (or /etc/sudoers.d/vagrant).

See also tests/directive.pp

Definition sudo::alias::command

Permits to define a command alias in the sudoers files (directive Cmnd_Alias) These are groups of related commands...

This definition accepts the following parameters:

  • $ensure: default to 'present', can be 'absent'
  • $commandlist: List of commands to add in the definition of the alias

Example:

 sudo::alias::command{ 'NETWORK':
      cmdlist => [ '/sbin/route', '/sbin/ifconfig', '/bin/ping', '/sbin/dhclient', '/sbin/iptables' ]
 }

This will create the following entry in the sudoers files:

 ## Networking
 Cmnd_Alias NETWORK = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /sbin/iptables

See also tests/alias/command.pp

Definition sudo::alias::user

Permits to define a user alias in the sudoers files (directive User_Alias) These aren't often necessary, as you can use regular groups (ie, from files, LDAP, NIS, etc) in this file - just use %groupname rather than USERALIAS

This definition accepts the following parameters:

  • $ensure: default to 'present', can be 'absent'
  • $commandlist: list of users to add in the definition of the alias

Example:

  sudo::alias::user{ 'ADMINS':
      userlist => [ 'jsmith', 'mikem' ]
  }

This will create the following entry in the sudoers files:

  User_Alias ADMINS = jsmith, mikem

See also tests/alias/user.pp

Definition sudo::defaults::spec

Permits to define a default specifications This definition accepts the following parameters:

  • $ensure: default to 'present', can be 'absent'
  • $content: specify the contents of the directive as a string
  • $source: copy a file as the content of the directive.

Examples

 sudo::defaults::spec { 'env_keep':
       content => "
  Defaults    env_reset
  Defaults    env_keep =  \"COLORS DISPLAY HOSTNAME LS_COLORS\"
  Defaults    env_keep += \"MAIL PS1 PS2 USERNAME LANG LC_ADDRESS LC_CTYPE\"
  Defaults    env_keep += \"LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES\"
  Defaults    env_keep += \"LC_TIME LC_ALL LANGUAGE\"\n",
  }

This will create the following entry in the sudoers files:

Defaults    env_reset
Defaults    env_keep =  "COLORS DISPLAY HOSTNAME LS_COLORS"
Defaults    env_keep += "MAIL PS1 PS2 USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults    env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults    env_keep += "LC_TIME LC_ALL LANGUAGE"

See also tests/defaults/spec.pp

Librarian-Puppet / R10K Setup

You can of course configure the sudo module in your Puppetfile to make it available with Librarian puppet or r10k by adding the following entry:

 # Modules from the Puppet Forge
 mod "ULHPC-sudo"

or, if you prefer to work on the git version:

 mod "ULHPC-sudo",
     :git => 'https://github.com/ULHPC/puppet-sudo',
     :ref => 'production'

Issues / Feature request

You can submit bug / issues / feature request using the ULHPC-sudo Puppet Module Tracker.

Developments / Contributing to the code

If you want to contribute to the code, you shall be aware of the way this module is organized. These elements are detailed on docs/contributing.md.

You are more than welcome to contribute to its development by sending a pull request.

Puppet modules tests within a Vagrant box

The best way to test this module in a non-intrusive way is to rely on Vagrant. The Vagrantfile at the root of the repository pilot the provisioning various vagrant boxes available on Vagrant cloud you can use to test this module.

See docs/vagrant.md for more details.

Online Documentation

Read the Docs aka RTFD hosts documentation for the open source community and the ULHPC-sudo puppet module has its documentation (see the docs/ directly) hosted on readthedocs.

See docs/rtfd.md for more details.

Licence

This project and the sources proposed within this repository are released under the terms of the GPL-3.0 licence.

Licence

puppet-sudo's People

Contributors

bmjen avatar crispygoth avatar dependabot[bot] avatar hcartiaux avatar ksraju007 avatar triforce avatar zoide avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

puppet-sudo's Issues

Module doesn't work on Puppet 4 when sudo is not installed

I just tried to run puppet on a new server which did not have "sudo" installed, and got the following error from this module:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Function Call, 'versioncmp' parameter 'a' expects a String value, got Undef at /etc/puppetlabs/code/environments/dev_chrisb/modules/sudo/manifests/common.pp:97:12 on node oxo-drbl.zedcore.com

My manifest for sudo is pretty simple (excluding the command defs, obviously):

 class { '::sudo':
    ensure              => 'present'
  }

Not sure if it's relevant, but the server version is 4.5.2 and the client is currently 3.7.2 (Puppet's first task is to upgrade itself...)

Warning: Unknown variable: 'real_source'.

Puppet aply (version 4) raises the following warning:

Warning: Unknown variable: 'real_source'. at /etc/puppetlabs/code/environments/svarrette/modules/sudo/manifests/directive.pp:110:24

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.