Puppet Class: mock

Inherits:
mock::params
Defined in:
manifests/init.pp

Summary

Manage mock

Overview

Examples:

Manage mock and define group members

class { 'mock':
  group_members => ['user1', 'user2'],
}

Parameters:

  • ensure (Enum['present', 'absent']) (defaults to: 'present')

    Sets the ensure parameter for the class' managed resources (defaults to present).

  • manage_group (Boolean) (defaults to: true)

    Boolean that determines if the group resource is managed by this module (defaults to true).

  • manage_epel (Boolean) (defaults to: true)

    Boolean that determines if the epel module is included by this module (defaults to true).

  • group_gid (Integer) (defaults to: 135)

    Sets the mock group's GID (defaults to 135).

  • group_name (String) (defaults to: $mock::params::group_name)

    Name of the mock group (defaults to mock).

  • group_members (Array) (defaults to: [])

    Array of users who should be added to mock group (defaults to empty array)

  • package_name (String) (defaults to: $mock::params::package_name)

    Name of the mock package (defaults to mock).



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
# File 'manifests/init.pp', line 23

class mock (
  Enum['present', 'absent'] $ensure = 'present',
  Boolean $manage_group = true,
  Boolean $manage_epel = true,
  Integer $group_gid = 135,
  Array $group_members = [],
  String $group_name = $mock::params::group_name,
  String $package_name = $mock::params::package_name,
) inherits mock::params {

  if $manage_epel {
    include epel
    Class['epel'] -> Package['mock']
  }

  if $manage_group {
    group { 'mock':
      ensure     => $ensure,
      name       => $group_name,
      gid        => $group_gid,
      forcelocal => true,
      before     => Package['mock'],
    }
    $group_member_require = Group['mock']
  } else {
    $group_member_require = undef
  }

  $_group_members = join(sort($group_members), ',')
  exec { 'manage-mock-group-members':
    path    => '/usr/bin:/bin:/usr/sbin:/sbin',
    command => "lgroupmod -m `egrep '^mock:' /etc/group | cut -d: -f4` ${group_name} ; lgroupmod -M ${_group_members} ${group_name}",
    unless  => "egrep '^${group_name}:' /etc/group | cut -d: -f4 | tr ',' '\\n' | sort | paste -sd, | egrep '^${_group_members}$'",
    require => $group_member_require,
  }

  package { 'mock':
    ensure => $ensure,
    name   => $package_name,
  }

}