sekikn commented on code in PR #1199:
URL: https://github.com/apache/bigtop/pull/1199#discussion_r1375673834
##########
bigtop-deploy/puppet/modules/ranger/manifests/init.pp:
##########
@@ -17,57 +17,77 @@
class deploy($roles) {
if ('ranger-server' in $roles) {
- include ranger::prerequisites
include ranger::admin
}
}
- class prerequisites {
+
+ class admin($admin_password) {
# Before Facter 3.14.17, Rocky Linux 8 is detected as 'RedHat'.
#
https://puppet.com/docs/pe/2019.8/osp/release_notes_facter.html#enhancements-3-14-17
- if (($operatingsystem == 'RedHat' or $operatingsystem == 'Rocky') and 0 <=
versioncmp($operatingsystemmajrelease, '8')) {
- # For some reason, 'python3' doesn't seem to work on Rocky Linux 8.
- $python = 'python36'
- } else {
- $python = 'python3'
+ case $operatingsystem {
+ /(?i:(ubuntu|debian))/: {
+ $postgres_packages = ['postgresql']
+ $python = 'python3'
+ $java_home_env = 'JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64'
+ }
+ default: {
+ $postgres_packages = ['postgresql-jdbc', 'postgresql-server']
+ $python = 'python36'
+ $java_home_env = 'JAVA_HOME=/usr/lib/jvm/java-1.8.0'
+ }
}
- package { ['postgresql-jdbc', 'postgresql-server', $python]:
- ensure => latest,
+ package { ['ranger-admin', $python]:
+ ensure => latest,
}
- exec { 'initdb':
- command => '/usr/bin/pg_ctl initdb -D /var/lib/pgsql/data',
- user => 'postgres',
- require => Package['postgresql-jdbc', 'postgresql-server', $python],
- }
+ if ($operatingsystem =~ /^(?i:(ubuntu|debian))$/) {
+ notice("Matched ubuntu or debian")
+ service { 'postgresql':
+ ensure => running,
+ require => Package[$python, 'ranger-admin'],
+ }
+
+ file { '/usr/share/java/postgresql-jdbc.jar':
+ ensure => link,
+ target => '/usr/share/java/postgresql.jar',
+ require => Package[$python, 'ranger-admin'],
+ }
+ } else {
+ notice("Did not match ubuntu or debian")
+ exec { 'initdb':
+ command => '/usr/bin/pg_ctl initdb -D /var/lib/pgsql/data',
+ user => 'postgres',
+ require => Package[$python, 'ranger-admin'],
+ }
- service { 'postgresql':
- ensure => running,
- require => Exec['initdb'],
+ service { 'postgresql':
+ ensure => running,
+ require => Exec['initdb'],
+ }
}
- }
- class admin($admin_password) {
- package { 'ranger-admin':
- ensure => latest,
- require => Class['ranger::prerequisites'],
+ exec { 'change_postgres_password':
+ command => "/bin/sudo -u postgres /usr/bin/psql -c \"ALTER USER postgres
WITH PASSWORD 'admin';\"",
Review Comment:
In my environment, sudo seems to be located only in /usr/bin on Debian 11.
Would you add it to PATH?
```
$ ./docker-hadoop.sh -d -dcp -C config_debian-11.yaml -F
docker-compose-cgroupv2.yml -G -L -k hdfs,hbase,ranger -s ranger -c 1
...
Error: Could not find command '/bin/sudo'
Error: /Stage[main]/Ranger::Admin/Exec[change_postgres_password]/returns:
change from 'notrun' to ['0'] failed: Could not find command '/bin/sudo'
Notice:
/Stage[main]/Ranger::Admin/File[/usr/lib/ranger-admin/install.properties]:
Dependency Exec[change_postgres_password] has failures: true
Warning:
/Stage[main]/Ranger::Admin/File[/usr/lib/ranger-admin/install.properties]:
Skipping because of failed dependencies
Warning: /Stage[main]/Ranger::Admin/Exec[/usr/lib/ranger-admin/setup.sh]:
Skipping because of failed dependencies
Warning:
/Stage[main]/Ranger::Admin/Exec[/usr/lib/ranger-admin/set_globals.sh]: Skipping
because of failed dependencies
Warning: /Stage[main]/Ranger::Admin/Exec[systemctl daemon-reload]: Skipping
because of failed dependencies
Warning: /Stage[main]/Ranger::Admin/Service[ranger-admin]: Skipping because
of failed dependencies
```
##########
bigtop-deploy/puppet/modules/ranger/manifests/init.pp:
##########
@@ -17,57 +17,77 @@
class deploy($roles) {
if ('ranger-server' in $roles) {
- include ranger::prerequisites
include ranger::admin
}
}
- class prerequisites {
+
+ class admin($admin_password) {
# Before Facter 3.14.17, Rocky Linux 8 is detected as 'RedHat'.
#
https://puppet.com/docs/pe/2019.8/osp/release_notes_facter.html#enhancements-3-14-17
- if (($operatingsystem == 'RedHat' or $operatingsystem == 'Rocky') and 0 <=
versioncmp($operatingsystemmajrelease, '8')) {
- # For some reason, 'python3' doesn't seem to work on Rocky Linux 8.
- $python = 'python36'
- } else {
- $python = 'python3'
+ case $operatingsystem {
+ /(?i:(ubuntu|debian))/: {
+ $postgres_packages = ['postgresql']
+ $python = 'python3'
+ $java_home_env = 'JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64'
+ }
+ default: {
+ $postgres_packages = ['postgresql-jdbc', 'postgresql-server']
+ $python = 'python36'
+ $java_home_env = 'JAVA_HOME=/usr/lib/jvm/java-1.8.0'
+ }
}
- package { ['postgresql-jdbc', 'postgresql-server', $python]:
- ensure => latest,
+ package { ['ranger-admin', $python]:
+ ensure => latest,
}
- exec { 'initdb':
- command => '/usr/bin/pg_ctl initdb -D /var/lib/pgsql/data',
- user => 'postgres',
- require => Package['postgresql-jdbc', 'postgresql-server', $python],
- }
+ if ($operatingsystem =~ /^(?i:(ubuntu|debian))$/) {
+ notice("Matched ubuntu or debian")
+ service { 'postgresql':
+ ensure => running,
+ require => Package[$python, 'ranger-admin'],
+ }
+
+ file { '/usr/share/java/postgresql-jdbc.jar':
+ ensure => link,
+ target => '/usr/share/java/postgresql.jar',
+ require => Package[$python, 'ranger-admin'],
+ }
+ } else {
+ notice("Did not match ubuntu or debian")
+ exec { 'initdb':
+ command => '/usr/bin/pg_ctl initdb -D /var/lib/pgsql/data',
+ user => 'postgres',
+ require => Package[$python, 'ranger-admin'],
+ }
- service { 'postgresql':
- ensure => running,
- require => Exec['initdb'],
+ service { 'postgresql':
+ ensure => running,
+ require => Exec['initdb'],
+ }
}
- }
- class admin($admin_password) {
- package { 'ranger-admin':
- ensure => latest,
- require => Class['ranger::prerequisites'],
+ exec { 'change_postgres_password':
+ command => "/bin/sudo -u postgres /usr/bin/psql -c \"ALTER USER postgres
WITH PASSWORD 'admin';\"",
+ require => Service['postgresql'],
}
+ notice("Before defining file resource")
file { '/usr/lib/ranger-admin/install.properties':
content => template('ranger/ranger-admin/install.properties'),
- require => Package['ranger-admin'],
+ require => [Package['ranger-admin'], Exec['change_postgres_password']]
}
exec { '/usr/lib/ranger-admin/setup.sh':
cwd => '/usr/lib/ranger-admin',
- environment => 'JAVA_HOME=/usr/lib/jvm/java-1.8.0',
+ environment => $java_home_env,
Review Comment:
I understand the original manifest used hard-coded JAVA_HOME, but basically
we should use bigtop-detect-javahome provided by bigtop-utils to locate
JAVA_HOME whenever we can, so that we don't need to have duplicated logic. For
example, running setup.sh and set_globals.sh with JAVA_HOME here can be
rewrited as follows. (That being said, the following implementation is ugly...
If you find other solution, feel free to adopt it)
```
exec { 'setup.sh':
command => '/bin/bash -c "source
/usr/lib/bigtop-utils/bigtop-detect-javahome &&
/usr/lib/ranger-admin/setup.sh"',
cwd => '/usr/lib/ranger-admin',
require => File['/usr/lib/ranger-admin/install.properties'],
}
exec { 'set_globals.sh':
command => '/bin/bash -c "source
/usr/lib/bigtop-utils/bigtop-detect-javahome &&
/usr/lib/ranger-admin/set_globals.sh"',
cwd => '/usr/lib/ranger-admin',
require => Exec['setup.sh'],
}
exec { 'systemctl daemon-reload':
path => ["/bin", "/usr/bin"],
require => Exec['set_globals.sh'],
}
```
##########
bigtop-deploy/puppet/modules/ranger/manifests/init.pp:
##########
@@ -17,57 +17,77 @@
class deploy($roles) {
if ('ranger-server' in $roles) {
- include ranger::prerequisites
include ranger::admin
}
}
- class prerequisites {
+
+ class admin($admin_password) {
# Before Facter 3.14.17, Rocky Linux 8 is detected as 'RedHat'.
#
https://puppet.com/docs/pe/2019.8/osp/release_notes_facter.html#enhancements-3-14-17
- if (($operatingsystem == 'RedHat' or $operatingsystem == 'Rocky') and 0 <=
versioncmp($operatingsystemmajrelease, '8')) {
- # For some reason, 'python3' doesn't seem to work on Rocky Linux 8.
- $python = 'python36'
- } else {
- $python = 'python3'
+ case $operatingsystem {
+ /(?i:(ubuntu|debian))/: {
+ $postgres_packages = ['postgresql']
+ $python = 'python3'
+ $java_home_env = 'JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64'
+ }
+ default: {
+ $postgres_packages = ['postgresql-jdbc', 'postgresql-server']
+ $python = 'python36'
Review Comment:
After applying this PR and #1201, running smoke test on CentOS 7 fails as
follows. Looks like `python36` doesn't work on CentOS 7 and we have to use
`python3` as a package name. Would you fix it?
```
$ ./docker-hadoop.sh -d -dcp -C config_centos-7.yaml -G -L -k
hdfs,hbase,ranger -s ranger -c 1
...
Error: Could not update: Execution of '/usr/bin/yum -d 0 -e 0 -y list
python36' returned 1: Error: No matching Packages to list
Wrapped exception:
Execution of '/usr/bin/yum -d 0 -e 0 -y list python36' returned 1: Error: No
matching Packages to list
Error: /Stage[main]/Ranger::Admin/Package[python36]/ensure: change from
absent to latest failed: Could not update: Execution of '/usr/bin/yum -d 0 -e 0
-y list python36' returned 1: Error: N
o matching Packages to list
Notice: /Stage[main]/Ranger::Admin/Package[ranger-admin]/ensure: created
Notice: /Stage[main]/Ranger::Admin/Exec[initdb]: Dependency
Package[python36] has failures: true
Warning: /Stage[main]/Ranger::Admin/Exec[initdb]: Skipping because of failed
dependencies
Notice: /Stage[main]/Ranger::Admin/Service[postgresql]: Dependency
Package[python36] has failures: true
Warning: /Stage[main]/Ranger::Admin/Service[postgresql]: Skipping because of
failed dependencies
Notice: /Stage[main]/Ranger::Admin/Exec[change_postgres_password]:
Dependency Package[python36] has failures: true
Warning: /Stage[main]/Ranger::Admin/Exec[change_postgres_password]: Skipping
because of failed dependencies
Notice:
/Stage[main]/Ranger::Admin/File[/usr/lib/ranger-admin/install.properties]:
Dependency Package[python36] has failures: true
Warning:
/Stage[main]/Ranger::Admin/File[/usr/lib/ranger-admin/install.properties]:
Skipping because of failed dependencies
Notice: /Stage[main]/Ranger::Admin/Exec[/usr/lib/ranger-admin/setup.sh]:
Dependency Package[python36] has failures: true
Warning: /Stage[main]/Ranger::Admin/Exec[/usr/lib/ranger-admin/setup.sh]:
Skipping because of failed dependencies
Notice:
/Stage[main]/Ranger::Admin/Exec[/usr/lib/ranger-admin/set_globals.sh]:
Dependency Package[python36] has failures: true
Warning:
/Stage[main]/Ranger::Admin/Exec[/usr/lib/ranger-admin/set_globals.sh]: Skipping
because of failed dependencies
Notice: /Stage[main]/Ranger::Admin/Exec[systemctl daemon-reload]: Dependency
Package[python36] has failures: true
Warning: /Stage[main]/Ranger::Admin/Exec[systemctl daemon-reload]: Skipping
because of failed dependencies
Notice: /Stage[main]/Ranger::Admin/Service[ranger-admin]: Dependency
Package[python36] has failures: true
Warning: /Stage[main]/Ranger::Admin/Service[ranger-admin]: Skipping because
of failed dependencies
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]