Puppet Class: pscobol::peoplesoft::compile

Defined in:
manifests/peoplesoft/compile.pp

Summary

Private class for Peoplesoft cobol compile

Overview

Examples:

include pscobol::peoplesoft::compile

Parameters:

  • ensure (Any) (defaults to: undef)
  • installdir (Any) (defaults to: undef)
  • ps_home (Any) (defaults to: undef)
  • ps_app_home (Any) (defaults to: undef)
  • ps_cust_home (Any) (defaults to: undef)
  • targets (Any) (defaults to: undef)


6
7
8
9
10
11
12
13
14
15
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
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
# File 'manifests/peoplesoft/compile.pp', line 6

class pscobol::peoplesoft::compile (
  $ensure            =  undef,
  $installdir        =  undef,
  $ps_home           =  undef,
  $ps_app_home       =  undef,
  $ps_cust_home      =  undef,
  $targets           =  undef,
) {

  debug ("Ensure 'pscobol::peoplesoft::compile' to be '${ensure}' using '${installdir}' on '${targets}'")

  if ($facts['operatingsystem'] == 'windows') {
    if (!empty($targets) and ($ensure == 'present')) {

      exec { 'Verify PS_HOME/setup Path' :
        command   => Sensitive(@("EOT")),
          If ('${ps_home}' -ne '') {
            If (-not (Test-Path -Path ${regsubst("\'${ps_home}/setup\'", '(/|\\\\)', '\\', 'G')} -ErrorAction Stop)) {
              Throw "Path for ${regsubst("\'${ps_home}/setup\'", '(/|\\\\)', '\\', 'G')} is invalid"
            }
          } Else {
            If (-not (Test-Path -Path "$([System.Environment]::GetEnvironmentVariable('PS_HOME'))\\setup")) {
              Throw "Path for '$([System.Environment]::GetEnvironmentVariable('PS_HOME'))/setup' is invalid"
            }
          }
          |- EOT
        provider  => powershell,
        logoutput => true,
      }

      $targets.each | String $target | {

        debug ("Compiling '${target}' cobol using '${installdir}'")

        exec { "Verify ${target} Environment Variable" :
          command   => Sensitive(@("EOT")),
            If (-not ([System.Environment]::GetEnvironmentVariable('${target}'))) {
              Throw 'The Environment variable ${target} must be declared'
            }
            |- EOT
          provider  => powershell,
          logoutput => true,
          require   => Exec['Verify PS_HOME/setup Path'],
          onlyif    => Sensitive(@("EOT")),
            If (('${target}' -eq 'PS_APP_HOME') -and ('${ps_app_home}' -eq '')) {
              Exit 0
            } ElseIf (('${target}' -eq 'PS_CUST_HOME') -and ('${ps_cust_home}' -eq '')) {
              Exit 0
            } ElseIf (('${target}' -eq 'PS_HOME') -and ('${ps_home}' -eq '')) {
              Exit 0
            }
            Exit 1
            |- EOT
        }

        exec { "Verify ${target}/src/cbl Path" :
          command   => Sensitive(@("EOT")),
            If ('${target}' -eq 'PS_APP_HOME') {
              If ('${ps_app_home}' -ne '') {
                If (-not (Test-Path -Path ${regsubst("\'${ps_app_home}/src/cbl\'", '(/|\\\\)', '\\', 'G')} -ErrorAction Stop)) {
                  Throw "Path for ${regsubst("\'${ps_app_home}/src/cbl\'", '(/|\\\\)', '\\', 'G')} is invalid"
                }
              } Else {
                If (-not (Test-Path -Path "$([System.Environment]::GetEnvironmentVariable('PS_APP_HOME'))\\src\\cbl")) {
                  Throw "Path for '$([System.Environment]::GetEnvironmentVariable('PS_APP_HOME'))/src/cbl' is invalid"
                }
              }
            } ElseIf ('${target}' -eq 'PS_CUST_HOME') {
              If ('${ps_cust_home}' -ne '') {
                If (-not (Test-Path -Path ${regsubst("\'${ps_cust_home}/src/cbl\'", '(/|\\\\)', '\\', 'G')} -ErrorAction Stop)) {
                  Throw "Path for ${regsubst("\'${ps_cust_home}/src/cbl\'", '(/|\\\\)', '\\', 'G')} is invalid"
                }
              } Else {
                If (-not (Test-Path -Path "$([System.Environment]::GetEnvironmentVariable('PS_CUST_HOME'))\\src\\cbl")) {
                  Throw "Path for '$([System.Environment]::GetEnvironmentVariable('PS_CUST_HOME'))/src/cbl' is invalid"
                }
              }
            } ElseIf ('${target}' -eq 'PS_HOME') {
              If ('${ps_home}' -ne '') {
                If (-not (Test-Path -Path ${regsubst("\'${ps_home}/src/cbl\'", '(/|\\\\)', '\\', 'G')} -ErrorAction Stop)) {
                  Throw "Path for ${regsubst("\'${ps_home}/src/cbl\'", '(/|\\\\)', '\\', 'G')} is invalid"
                }
              } Else {
                If (-not (Test-Path -Path "$([System.Environment]::GetEnvironmentVariable('PS_HOME'))\\src\\cbl")) {
                  Throw "Path for '$([System.Environment]::GetEnvironmentVariable('PS_HOME'))/src/cbl' is invalid"
                }
              }
            }
            |- EOT
          provider  => powershell,
          logoutput => true,
          require   => Exec['Verify PS_HOME/setup Path', "Verify ${target} Environment Variable"],
        }

        exec { "Compile ${target} cobol" :
          command   => Sensitive("
            ${file('pscobol/pscobol.psm1')}
            Invoke-CobolCompile `
              -ps_home ${regsubst("\'${ps_home}\'", '(/|\\\\)', '\\', 'G')} `
              -ps_app_home ${regsubst("\'${ps_app_home}\'", '(/|\\\\)', '\\', 'G')} `
              -ps_cust_home ${regsubst("\'${ps_cust_home}\'", '(/|\\\\)', '\\', 'G')} `
              -cobroot ${regsubst("\'${installdir}\'", '(/|\\\\)', '\\', 'G')} `
              -Target ${target}
          "),
          provider  => powershell,
          logoutput => true,
          require   => Exec['Verify PS_HOME/setup Path', "Verify ${target}/src/cbl Path"],
          onlyif    => Sensitive(@("EOT")),
            Try {
              If ('${target}' -ne '') {
                If (Test-Path -Path ${regsubst("\'${installdir}/bin/cobol.exe\'", '(/|\\\\)', '\\', 'G')}) {
                  Exit 0
                }
              }
              Exit 1
            } Catch {
              Exit 1
            }
            |-EOT
        }
      }
    }

  } else {
    fail("Unsupported Platform - ${$facts['operatingsystem']}")
  }
}