Puppet Class: ora_install::prepareautostart

Defined in:
manifests/prepareautostart.pp

Summary

Prepare autostart of the database for linux.

Overview

ora_install::prepareautostart

This class creates the script needed to start the database after a system reboot. It supports both ‘systemd` and the older startup scripts.

Here is an example on how to use it:

“‘puppet

class { 'class ora_install::prepareautostart':
  oracle_home  => '/oracle/db1',
  user         => 'oracle',
  service_name => 'start_db1',
}

“‘ This class is a conveneance class around the defined type `prepareautostart_for`.

See the file “LICENSE” for the full license governing this code.

Parameters:

  • oracle_home (Stdlib::Absolutepath) (defaults to: undef)

    A directory to be used as Oracle home directory for this software.

  • user (String[1]) (defaults to: 'oracle')

    The user used for the specified installation. The install class will not create the user for you. You must do that yourself. The default value is: ‘oracle`

  • service_name (String[1]) (defaults to: 'dbora')

    The name of the init service to use. The default value is: ‘dbora`

  • logoutput (Variant[Boolean,Enum['on_failure']]) (defaults to: lookup({ name => 'logoutput', default_value => 'on_failure' }))

    log the outputs of Puppet exec or not. When you specify ‘true` Puppet will log all output of `exec` types. Valid values are:

    • ‘true`

    • ‘false`

    • ‘on_failure`



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
# File 'manifests/prepareautostart.pp', line 41

class ora_install::prepareautostart (
  Variant[Boolean,Enum['on_failure']] $logoutput    = lookup({ name => 'logoutput', default_value => 'on_failure' }),
  Stdlib::Absolutepath                $oracle_home  = undef,
  String[1]                           $service_name = 'dbora',
  String[1]                           $user         = 'oracle',
) {
  $exec_path = '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:'

  case $facts['kernel'] {
    'Linux': {
      $dbora_location = '/etc/init.d'
    }
    'Windows': {
      notice 'TODO:'
      $dbora_location = '/etc/init.d'
    }
    'SunOS': {
      $dbora_location = '/etc'
    }
    default: {
      fail('Unrecognized kernel, please use it on a Linux or SunOS host')
    }
  }

  easy_type::debug_evaluation() # Show local variable on extended debug

  file { "${dbora_location}/${service_name}" :
    ensure  => file,
    mode    => '0755',
    owner   => 'root',
    content => regsubst(epp("ora_install/dbora_${facts['kernel']}.epp", {
          oracle_home  => $oracle_home,
          user         => $user,
          service_name => $service_name,
    }), '\r\n', "\n", 'EMG'),
  }

  case $facts['os']['name'] {
    'Windows': {
      notice 'TODO:'
    }
    'CentOS', 'RedHat', 'OracleLinux', 'SLES', 'AlmaLinux', 'Rocky': {
      exec { "enable service ${service_name}":
        command   => "chkconfig --add ${service_name}",
        require   => File["/etc/init.d/${service_name}"],
        user      => 'root',
        unless    => "chkconfig --list | /bin/grep \'${service_name}\'",
        path      => $exec_path,
        logoutput => $logoutput,
      }
    }
    'Ubuntu', 'Debian':{
      exec { "enable service ${service_name}":
        command   => "update-rc.d ${service_name} defaults",
        require   => File["/etc/init.d/${service_name}"],
        user      => 'root',
        unless    => "ls /etc/rc3.d/*${service_name} | /bin/grep \'${service_name}\'",
        path      => $exec_path,
        logoutput => $logoutput,
      }
    }
    'Solaris': {
      file { '/tmp/oradb_smf.xml' :
        ensure  => file,
        mode    => '0755',
        owner   => 'root',
        content => epp('ora_install/oradb_smf.xml.epp', {
            'dbora_location' => $dbora_location,
            'service_name'   => $service_name,
        }),
      }
      exec { "enable service ${service_name}":
        command   => 'svccfg -v import /tmp/oradb_smf.xml',
        require   => File['/tmp/oradb_smf.xml',"${dbora_location}/${service_name}"],
        user      => 'root',
        unless    => 'svccfg list | grep oracledatabase',
        path      => $exec_path,
        logoutput => $logoutput,
      }
    }
    default: {
      fail('Unrecognized operating system, please use it on a Linux or SunOS host')
    }
  }
}