GithubHelp home page GithubHelp logo

matthewrstone / puppet-local_user Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rnelson0/puppet-local_user

0.0 2.0 0.0 43 KB

Puppet module. Manage local users, setting an initial password but letting the user change it as needed afterward.

Ruby 63.71% Puppet 36.29%

puppet-local_user's Introduction

local_user

Build Status Puppet Forge Puppet Forge Downloads Stories in Ready ![Stories In Progress](https://badge.waffle.io/rnelson0/puppet-local_user.svg?label=in progress&title=In Progress)

Table of Contents

  1. Overview
  2. Usage - Configuration options and additional functionality
  3. Caveats and Clarifications

Overview

This module provides a defined type, local_user, that wraps the puppet 'user' resource type with validation. You may also provide a initial password that is set only when the user has no password, as a brand new 'user' resource puppet creates will have. This allows users to maintain their own passwords after creation.

Usage

Resource Definition

Create a local user by providing at a minimum the user name, state, groups, and initial password:

local_user { 'rnelson':
  state            => 'present',
  groups           => ['group1', 'group2'],
  password         => 'encryptedstring',
}

You may also provide the shell, home directory, password max age, the last change date (YYYY-MM-DD or number of days since Jan 1, 1970), and an array of ssh keys. These values default to /bin/bash, /home/, 90 days, 0 days, and null, respectively.

local_user { 'rnelson':
  state            => 'present',
  shell            => '/bin/bash',
  home             => '/home/rnelson0',
  managehome       => true,
  comment          => 'Rob Nelson',
  groups           => ['rnelson0', 'wheel'],
  gid              => 'rnelson0'
  manage_groups    => true,
  last_change      => '2015-01-01',
  password         => 'encryptedstring',
  password_max_age => 1000,
  ssh_authorized_keys => ['ssh-rsa AAAA...123 user@host'],
}

Via Hiera

You can also store your user information in hiera and use the create_resources() function to create the users. The user(s) can be defined in the appropriate level(s) of your hierarchy, for example at the least-specific level, global.yaml:

# global.yaml
---
local_users:
  rnelson0:
    state:            'present'
    home:             '/home/rnelson0'
    managehome:       true
    comment:          'Rob Nelson'
    groups:
      - 'rnelson0'
      - 'wheel'
    gid:              'rnelson0'
    manage_groups:    true
    last_change:      '2015-01-01'
    password:         'encryptedstring'
    password_max_age: '1000'
    ssh_authorized_keys:
      - 'ssh-rsa AAAA...123 user@host'

Add code similar to the following black to a common class, such as profile::base. The result of the hiera lookup for local_users, using your hiera merge strategy, will be discovered and added to the node's manifest.

# profile/manifests/base.pp
class profile::base {
  # Your base profile goes here

  $local_users = hiera('local_users', undef)
  if ($local_users) {
    create_resources('local_user', $local_users)
  }
}

This example is functionally equivalent to the second Resource Definition example.

Caveats and Clarifications

  • When no $comment is provided, the comment field will contain the username.

  • The encrypted string is processed via sed using '/' seperators. You MUST escape any '/' characters.

  • If the specified groups do not exist and or not created elsewhere in your catalog (or ordered incorrectly), you will receive errors preventing the user from being created. Set the parameter manage_groups to true and the groups will be managed and ordered within local_user. The error looks like:

Error: Could not create user rnelson0: Execution of '/usr/sbin/useradd -c Rob Nelson -g rnelson0 -G wheel
-d /home/rnelson0 -s /bin/bash -m rnelson0' returned 6: useradd: group 'rnelson0' does not exist

puppet-local_user's People

Contributors

rnelson0 avatar galp avatar

Watchers

James Cloos avatar Matthew Stone avatar

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.