Puppet Class: archlinux_workstation

Defined in:
manifests/init.pp

Overview

Main class for archlinux_workstation.

See README.markdown for advanced usage.

This class sets up your user and group and provides variables for other classes in the module.

Parameters:

  • username (String) (defaults to: undef)

    Your login username. Used to create your account, add you to certain groups, etc.

  • realname (Variant[String, Undef]) (defaults to: undef)

    The user's real name, to be used in the passwd comment/GECOS field. Defaults to $username if not specified.

  • user_home (Variant[String, Undef]) (defaults to: undef)

    Path to $username's home directory. Used for classes that put files in the user's home directory. Default: /home/${username}.

  • shell (String) (defaults to: '/bin/bash')

    the user's login shell.

  • user_groups (Array[String]) (defaults to: ['sys'])

    list of supplementary groups that this user should be a member of.

  • makepkg_packager (Variant[String, Undef]) (defaults to: undef)

    String to set as PACKAGER in makepkg.conf (see wiki.archlinux.org/index.php/Makepkg#Packager_information); if left blank, PACKAGER will be omitted and built packages will default to “Unknown Packager”.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'manifests/init.pp', line 22

class archlinux_workstation (
  String $username                         = undef,
  Variant[String, Undef] $realname         = undef,
  Variant[String, Undef] $user_home        = undef,
  String $shell                            = '/bin/bash',
  Array[String] $user_groups               = ['sys'],
  Variant[String, Undef] $makepkg_packager = undef,
) {

  # make sure we're on arch, otherwise fail
  if $::osfamily != 'Archlinux' {
    fail("${::operatingsystem} not supported")
  }

  # user_home - default uses another param
  if ! $user_home {
    $real_user_home = "/home/${username}"
  } else {
    $real_user_home = $user_home
  }

  # realname - default uses another param
  if $realname {
    $real_name = $realname
  } else {
    $real_name = $username
  }

  validate_re($username, '^.+$', 'Parameter username must be a string for class archlinux_workstation')
  validate_absolute_path($real_user_home)

  # we make the user a virtual resource and then realize it so that other
  # classes can append to the 'groups' attribute using plusignment
  @user { $username:
    ensure     => present,
    name       => $username,
    comment    => $real_name,
    gid        => $username,
    home       => $real_user_home,
    managehome => true,
    shell      => $shell,
    groups     => $user_groups,
    require    => [ Group[$username] ],
  }

  User <| title == $username |>

  group { $username:
    ensure => present,
    name   => $username,
    system => false,
  }

}