|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 2 | +# contributor license agreements. See the NOTICE file distributed with |
| 3 | +# this work for additional information regarding copyright ownership. |
| 4 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 5 | +# (the "License"); you may not use this file except in compliance with |
| 6 | +# the License. You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +class ranger { |
| 17 | + |
| 18 | + class deploy($roles) { |
| 19 | + if ('ranger-server' in $roles) { |
| 20 | + include ranger::prerequisites |
| 21 | + include ranger::admin |
| 22 | + } |
| 23 | + } |
| 24 | + |
| 25 | + class prerequisites { |
| 26 | + # Before Facter 3.14.17, Rocky Linux 8 is detected as 'RedHat'. |
| 27 | + # At the time of writing, Facter 3.14.2 is installed on Rocky Linux 8 by default. |
| 28 | + # https://puppet.com/docs/pe/2019.8/osp/release_notes_facter.html#enhancements-3-14-17 |
| 29 | + if ($operatingsystem == 'RedHat' and 0 <= versioncmp($operatingsystemmajrelease, '8')) { |
| 30 | + # For some reason, 'python3' doesn't seem to work on Rocky Linux 8. |
| 31 | + $python = 'python36' |
| 32 | + } else { |
| 33 | + $python = 'python3' |
| 34 | + } |
| 35 | + |
| 36 | + package { ['postgresql-jdbc', 'postgresql-server', $python]: |
| 37 | + ensure => latest, |
| 38 | + } |
| 39 | + |
| 40 | + exec { 'initdb': |
| 41 | + command => '/usr/bin/pg_ctl initdb -D /var/lib/pgsql/data', |
| 42 | + user => 'postgres', |
| 43 | + require => Package['postgresql-jdbc', 'postgresql-server', $python], |
| 44 | + } |
| 45 | + |
| 46 | + service { 'postgresql': |
| 47 | + ensure => running, |
| 48 | + require => Exec['initdb'], |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + class admin($admin_password) { |
| 53 | + package { 'ranger-admin': |
| 54 | + ensure => latest, |
| 55 | + require => Class['ranger::prerequisites'], |
| 56 | + } |
| 57 | + |
| 58 | + file { '/usr/lib/ranger-admin/install.properties': |
| 59 | + content => template('ranger/ranger-admin/install.properties'), |
| 60 | + require => Package['ranger-admin'], |
| 61 | + } |
| 62 | + |
| 63 | + exec { '/usr/lib/ranger-admin/setup.sh': |
| 64 | + cwd => '/usr/lib/ranger-admin', |
| 65 | + environment => 'JAVA_HOME=/usr/lib/jvm/java-1.8.0', |
| 66 | + require => File['/usr/lib/ranger-admin/install.properties'], |
| 67 | + } |
| 68 | + |
| 69 | + exec { '/usr/lib/ranger-admin/set_globals.sh': |
| 70 | + cwd => '/usr/lib/ranger-admin', |
| 71 | + environment => 'JAVA_HOME=/usr/lib/jvm/java-1.8.0', |
| 72 | + require => Exec['/usr/lib/ranger-admin/setup.sh'], |
| 73 | + } |
| 74 | + |
| 75 | + exec { 'systemctl daemon-reload': |
| 76 | + path => ["/bin", "/usr/bin"], |
| 77 | + require => Exec['/usr/lib/ranger-admin/set_globals.sh'], |
| 78 | + } |
| 79 | + |
| 80 | + service { 'ranger-admin': |
| 81 | + ensure => running, |
| 82 | + require => Exec['systemctl daemon-reload'], |
| 83 | + } |
| 84 | + } |
| 85 | +} |
0 commit comments