Puppet Function: getMySQLPackageName

Defined in:
lib/puppet/parser/functions/getMySQLPackageName.rb
Function type:
Ruby 3.x API

Overview

getMySQLPackageName()Any

Returns:

  • (Any)


16
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
# File 'lib/puppet/parser/functions/getMySQLPackageName.rb', line 16

newfunction(:getMySQLPackageName, :type => :rvalue) do |args|
  packageType   = args[0]
  build         = args[1]
  version       = args[2]
  os            = lookupvar('operatingsystem')
  osversion     = lookupvar('operatingsystemmajrelease')
  osreleasename = lookupvar('lsbdistcodename')
  packageServer = nil
  packageClient = nil


  if (os !~ /(?i:centos|redhat|oel|OracleLinux|amazon|ubuntu|debian)/)
    raise Puppet::ParseError, "Unsupported Operating System - #{os} "
  end

  if build == 'percona'
    if (os =~ /(?i:centos|redhat|oel|OracleLinux|amazon)/)
      if (version !~ /(?i:5.1|5.5|5.6)/)
        raise Puppet::ParseError, "Unsupported Version (#{version})  for the Percona Repo on #{os}"
      end
      version=version.gsub(".", "")
      packageServer="Percona-Server-server-#{version}"
      packageClient="Percona-Server-client-#{version}"
    else
      if (version !~ /(?i:5.6)/)
        raise Puppet::ParseError, "Unsupported Version (#{version}) for the Percona Repo on #{os}"
      end
      packageServer="percona-server-server-#{version}"
      packageClient="percona-server-client-#{version}"
    end
  end

  if build == 'mariadb'
    if (version !~ /(?i:5.5|10.0)/)
      raise Puppet::ParseError, "Unsupported Version (#{version}) for the Mariadb Repo on #{os}"
    end

    if (os =~ /(?i:centos|redhat|oel|OracleLinux|amazon)/)
      packageServer="MariaDB-server"
      packageClient="MariaDB-client"
    else
      packageServer="mariadb-server"
      packageClient="mariadb-client"
    end
  end

  #5.7. is not supported my the puppetlab module as it regnerates old variables
  if build == 'mysql'
    if (version !~ /(?i:5.5|5.6)/)
      raise Puppet::ParseError, "Unsupported Version (#{version}) for the MySQL Repo on #{os}"
    end

    if (os =~ /(?i:centos|redhat|oel|OracleLinux|amazon)/) and  osversion == '5'
      raise Puppet::ParseError, "MySQL repo is Unsupported on Centos5"
    end

    if (os =~ /(?i:ubuntu|debian)/) and  (version !~ /(?i:5.6)/)
      raise Puppet::ParseError, "Unsupported Version (#{version}) for the MySQL Repo on #{os}"
    end
    if (os =~ /(?i:debian)/)
      raise Puppet::ParseError, "MySQL repo is Unsupported on Debian"
    end
    if (os =~ /(?i:ubuntu)/)  and  (osreleasename =~ /(?i:lucid)/)
      raise Puppet::ParseError, "MySQL repo is Unsupported  on Lucid"
    end
    packageServer="mysql-community-server"
    packageClient="mysql-community-client"
  end

  if packageType=='server'
    return packageServer
  else
    return packageClient
  end

end