iwasakims commented on code in PR #1263:
URL: https://github.com/apache/bigtop/pull/1263#discussion_r1607500668


##########
bigtop-deploy/puppet/manifests/python.pp:
##########
@@ -14,16 +14,70 @@
 # limitations under the License.
 
 class python {
-    if (($operatingsystem == 'Ubuntu' and 0 <= 
versioncmp($operatingsystemmajrelease, '22.04'))) {
-        file { '/usr/bin/python':
-          ensure => 'link',
-          target => '/usr/bin/python2',
+
+    define set_python_alternatives($command) {
+        exec { $name:
+          command => $command,
+          unless  => "/usr/sbin/update-alternatives --display python | grep 
'/usr/bin/python3'",
+          path    => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
         }
     }
-    
-    if ($operatingsystem == 'openEuler') {
-        package { 'python3-unversioned-command':
-          ensure => 'present'
+
+    define change_python_interpreter($file, $interpreter) {
+        file_line { "change_interpreter_in_${name}":
+          path  => $file,
+          line  => "#!${interpreter}",
+          match => '^#!.*python.*$',
+        }
+    }
+
+    case $operatingsystem {
+        /(?i:(centos|fedora|redhat|rocky))/: {
+            if ($operatingsystem != 'Fedora') {
+                case $operatingsystemmajrelease {
+                    '9': {
+                        package { 'python-unversioned-command':
+                          ensure => 'present',
+                        }
+                    }
+                    '8': {
+                        set_python_alternatives { 'set-python3':
+                          command => '/usr/sbin/update-alternatives --set 
python /usr/bin/python3',
+                        }
+                    }
+                    '7': {
+                        change_python_interpreter { 'yum':
+                          file        => '/usr/bin/yum',
+                          interpreter => '/usr/bin/python2.7',
+                        }
+                        change_python_interpreter { 'urlgrabber-ext-down':
+                          file        => '/usr/libexec/urlgrabber-ext-down',
+                          interpreter => '/usr/bin/python2.7',
+                        }
+
+                        set_python_alternatives { 'install-python3':
+                          command => '/usr/sbin/update-alternatives --install 
/usr/bin/python python /usr/bin/python3 1',
+                        }

Review Comment:
   python3 must be installed before this (by package resource) in order to make 
this functional in the bigtop/puppet image.
   
   ```
   Notice: Roles to deploy: [bigtop-utils]
   Notice: Compiled catalog for 670e444169cb.bigtop.apache.org in environment 
production in 0.85 seconds
   Notice: /Stage[main]/Hadoop_cluster_node/User[testuser]/ensure: created
   Notice: /Stage[main]/Hadoop_cluster_node/User[jenkins]/ensure: created
   Notice: /Stage[main]/Bigtop_repo/Yumrepo[Bigtop_0]/ensure: created
   Notice: 
/Stage[main]/Python/Python::Set_python_alternatives[install-python3]/Exec[install-python3]/returns:
 executed successfully
   Notice: 
/Stage[main]/Python/Python::Change_python_interpreter[urlgrabber-ext-down]/File_line[change_interpreter_in_urlgrabber-ext-down]/ensure:
 created
   Notice: 
/Stage[main]/Python/Python::Change_python_interpreter[yum]/File_line[change_interpreter_in_yum]/ensure:
 created
   Notice: Baseurl: file:///bigtop-home/output
   Notice: /Stage[main]/Bigtop_repo/Notify[Baseurl: 
file:///bigtop-home/output]/message: defined 'message' as 'Baseurl: 
file:///bigtop-home/output'
   Notice: /Stage[main]/Hadoop_cluster_node/User[hudson]/ensure: created
   Error: /Stage[main]/Bigtop_utils::Client/Package[bigtop-utils]: Provider yum 
is not functional on this host
   Error: /Stage[main]/Jdk/Package[jdk]: Provider yum is not functional on this 
host
   
   ```



-- 
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]

Reply via email to