Puppet Class: powerman

Defined in:
manifests/init.pp

Summary

Manage powerman

Overview

Examples:

include powerman

Parameters:

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

    Module ensure property

  • manage_epel (Boolean) (defaults to: true)

    Boolean that determines if EPEL repo should be managed

  • server (Boolean) (defaults to: true)

    Boolean that sets host to act as powerman server

  • listen (Stdlib::IP::Address) (defaults to: '127.0.0.1')

    Address to listen on

  • powerman_server (Stdlib::Host) (defaults to: $facts['networking']['fqdn'])

    Hostname of powerman server

  • powerman_port (Stdlib::Port) (defaults to: 10101)

    The port of powerman server

  • tcpwrappers (Optional[Boolean]) (defaults to: undef)

    Enable tcpwrappers support

  • cfgfile (Stdlib::Absolutepath) (defaults to: '/etc/powerman/powerman.conf')

    Path to powerman.conf

  • driver_dir (Stdlib::Absolutepath) (defaults to: '/etc/powerman')

    Driver directory

  • driver_list (Array) (defaults to: ['powerman','ipmipower'])

    List of drivers to load

  • aliases (Hash) (defaults to: {})

    Hash of aliases to pass to powerman::alias

  • devices (Hash) (defaults to: {})

    Hash of devices to pass to powerman::device

  • nodes (Hash) (defaults to: {})

    Hash of nodes to pass to powerman::node

  • pid_dir (Stdlib::Absolutepath) (defaults to: '/var/run/powerman')

    Directory for PID file

  • user (String) (defaults to: 'daemon')

    User running powerman service

  • group (String) (defaults to: 'daemon')

    Group running powerman service



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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'manifests/init.pp', line 38

class powerman (
  Enum['present', 'absent'] $ensure = 'present',
  Boolean $manage_epel = true,
  Boolean $server = true,
  Stdlib::IP::Address $listen = '127.0.0.1',
  Stdlib::Host $powerman_server = $facts['networking']['fqdn'],
  Stdlib::Port $powerman_port = 10101,
  Optional[Boolean] $tcpwrappers = undef,
  Stdlib::Absolutepath $cfgfile = '/etc/powerman/powerman.conf',
  Stdlib::Absolutepath $driver_dir = '/etc/powerman',
  Array $driver_list = ['powerman','ipmipower'],
  Hash $aliases  = {},
  Hash $devices  = {},
  Hash $nodes    = {},
  Stdlib::Absolutepath $pid_dir = '/var/run/powerman',
  String $user = 'daemon',
  String $group = 'daemon',
) {

  if $ensure == 'present' {
    $package_ensure = 'present'
    $cfg_ensure     = 'present'
    if $server {
      $env_ensure     = 'absent'
      $service_ensure = 'running'
      $service_enable = true
    } else {
      $env_ensure     = 'file'
      $service_ensure = 'stopped'
      $service_enable = false
    }
  } else {
    $package_ensure = 'absent'
    $cfg_ensure     = 'absent'
    $env_ensure     = 'absent'
    $service_ensure = 'stopped'
    $service_enable = false
  }

  if dig($facts, 'os', 'family') == 'RedHat' {
    if $manage_epel {
      include epel
      Yumrepo['epel'] -> Package['powerman']
    }
  }

  package { 'powerman':
    ensure => $package_ensure,
  }

  if $server and $ensure == 'present' {
    file { $driver_dir:
      ensure  => 'directory',
      owner   => 'root',
      group   => 'root',
      mode    => '0755',
      require => Package['powerman'],
    }
  }

  if $server or $ensure == 'absent' {
    concat { $cfgfile:
      ensure    => $cfg_ensure,
      owner     => $user,
      group     => 'root',
      mode      => '0640',
      show_diff => false,
      require   => Package['powerman'],
      notify    => Service['powerman'],
    }
  }

  if $server and $ensure == 'present' {
    concat::fragment { 'powerman.conf.header':
      target  => $cfgfile,
      content => template('powerman/etc/powerman/powerman.conf.header.erb'),
      order   => '01',
    }
    $aliases.each |$name, $alias| {
      powerman::alias { $name: * => $alias }
    }
    $devices.each |$name, $device| {
      powerman::device { $name: * => $device }
    }
    $nodes.each |$name, $node| {
      powerman::node { $name: * => $node }
    }

    file { $pid_dir:
      ensure  => 'directory',
      owner   => $user,
      group   => $group,
      mode    => '0755',
      require => Package['powerman'],
      before  => Service['powerman'],
    }
  }

  service { 'powerman':
    ensure     => $service_ensure,
    enable     => $service_enable,
    hasstatus  => true,
    hasrestart => true,
    require    => Package['powerman'],
  }

  file { '/etc/profile.d/powerman.sh':
    ensure  => $env_ensure,
    content => template('powerman/etc/profile.d/powerman.sh.erb'),
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
  }
  file { '/etc/profile.d/powerman.csh':
    ensure  => $env_ensure,
    content => template('powerman/etc/profile.d/powerman.csh.erb'),
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
  }

}