Puppet Class: mofed::opensm

Defined in:
manifests/opensm.pp

Summary

Manage OpenSM

Overview

Examples:

Manage OpenSM on two specific ports

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

Parameters:

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

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

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

    Ports used by opensm

  • sweep (Integer) (defaults to: 10)

    Value passsed to opensm -s argument.



17
18
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
# File 'manifests/opensm.pp', line 17

class mofed::opensm (
  Enum['present', 'absent', 'disabled'] $ensure = 'present',
  Array $ports = [],
  Integer $sweep = 10,
) {

  include mofed

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

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

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

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

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

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

}