Puppet Class: mofed::srp

Defined in:
manifests/srp.pp

Summary

Manage SRP

Overview

Examples:

Manage SRP for specific ports

class { 'mofed::srp':
 ports => ['mlx4_1 1', 'mlx4_1 2'],
}

Parameters:

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

    State of srp. present will run opensm. disabled will install and configure opensm but disable services. absent will remove opensm.

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

    Ports used by srp daemon.

  • srp_daemon_config (Optional[Variant[String, Array]]) (defaults to: undef)

    Define lines in srp_daemon.conf

  • ib_srp_options (Optional[Hash[String, Variant[String,Integer], 1]]) (defaults to: undef)

    Options passed to ib_srp kernel module



19
20
21
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
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
160
161
162
163
164
165
166
167
# File 'manifests/srp.pp', line 19

class mofed::srp (
  Enum['present', 'absent', 'disabled'] $ensure = 'present',
  Array $ports = [],
  Optional[Variant[String, Array]] $srp_daemon_config = undef,
  Optional[Hash[String, Variant[String,Integer], 1]] $ib_srp_options = undef,
) {

  include mofed

  case $ensure {
    'present': {
      $package_ensure = 'present'
      $file_ensure    = 'file'
      $srp_load       = 'yes'
      $service_ensure = 'running'
      $service_enable = true
    }
    'absent': {
      $package_ensure = 'absent'
      $file_ensure    = 'absent'
      $srp_load       = 'no'
      $service_ensure = 'stopped'
      $service_enable = false
    }
    'disabled': {
      $package_ensure = 'present'
      $file_ensure    = 'file'
      $srp_load       = 'yes'
      $service_ensure = 'stopped'
      $service_enable = false
    }
    default: {
      # Do nothing
    }
  }

  package { 'srptools':
    ensure  => $package_ensure,
    require => Class['mofed::repo'],
  }

  if $mofed::manage_config {
    shellvar { 'SRP_LOAD':
      ensure  => 'present',
      target  => $mofed::openib_config_path,
      value   => $srp_load,
      notify  => $mofed::openib_shellvar_notify,
      require => Class['::mofed::install'],
    }
  }

  file { '/etc/rsyslog.d/srp_daemon.conf':
    ensure  => 'absent',
    require => Package['srptools'],
  }

  rsyslog::snippet { '60_srp_daemon.conf':
    ensure  => $file_ensure,
    content => template('mofed/srp/srp_daemon.rsyslog.conf.erb'),
    require => Package['srptools'],
  }

  # Template uses:
  # - $srp_daemon_config
  file { '/etc/srp_daemon.conf':
    ensure  => $file_ensure,
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
    content => template('mofed/srp/srp_daemon.conf.erb'),
    require => Package['srptools'],
  }

  # Template uses:
  # - $ports
  file { '/etc/sysconfig/srpd':
    ensure  => $file_ensure,
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
    content => template('mofed/srp/srpd.sysconfig.erb'),
    require => Package['srptools'],
  }

  # Template uses:
  # - $ib_srp_options
  if $ib_srp_options {
    file { '/etc/modprobe.d/ib_srp.conf':
      ensure  => $file_ensure,
      owner   => 'root',
      group   => 'root',
      mode    => '0644',
      content => template('mofed/srp/ib_srp.conf.erb'),
      require => Package['srptools'],
    }
  } else {
    file { '/etc/modprobe.d/ib_srp.conf':
      ensure  => 'absent',
      require => Package['srptools'],
    }
  }

  # opensmd can not be limited to specific ports
  # so only run if ports are not defined
  if empty($ports) {
    service { 'srpd':
      ensure     => $service_ensure,
      enable     => $service_enable,
      hasstatus  => true,
      hasrestart => true,
      #subscribe  => File[$mofed::openib_config_path],
      require    => Package['srptools'],
    }
  } else {
    service { 'srpd':
      ensure     => 'stopped',
      enable     => false,
      hasstatus  => true,
      hasrestart => true,
      require    => Package['srptools'],
    }

    if versioncmp($::operatingsystemrelease, '7.0') >= 0 {
      systemd::unit_file { 'srpd@.service':
        ensure => $file_ensure,
        source => 'puppet:///modules/mofed/srp/srpd@.service',
      }

      $ports.each |Integer $index, String $port| {
        $i = $index + 1
        service { "srpd@${i}":
          ensure     => $service_ensure,
          enable     => $service_enable,
          hasstatus  => true,
          hasrestart => true,
          require    => [
            File['/etc/modprobe.d/ib_srp.conf'],
          ],
          subscribe  => [
            File['/etc/sysconfig/srpd'],
            File['/etc/srp_daemon.conf'],
            Systemd::Unit_file['srpd@.service'],
          ]
        }
      }
    }
  }

}