diff --git a/cmd/main.go b/cmd/main.go index a118886..e5b55f2 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -121,6 +121,7 @@ func newRootCmd() *cobra.Command { Requires a configuration file (typically bloom.yaml). Use --playbook to specify which playbook to run.`, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { + checkRootPrivileges("ansible") runAnsible(args[0]) }, } @@ -145,6 +146,7 @@ This command performs the equivalent of Bloom v1 cleanup operations: By default, this command requires confirmation before proceeding. Use --force to skip confirmation.`, Run: func(cmd *cobra.Command, args []string) { + checkRootPrivileges("cleanup") // Check if force flag is used to bypass confirmation if !forceCleanup { if !confirmCleanupOperation() { @@ -293,6 +295,25 @@ func confirmCleanupOperation() bool { return true } +// checkRootPrivileges verifies that the current process is running with root privileges +func checkRootPrivileges(commandName string) { + if os.Getuid() != 0 { + fmt.Fprintf(os.Stderr, "❌ Error: %s requires root privileges\n\n", commandName) + fmt.Fprintf(os.Stderr, "Please run this command with root privileges:\n") + fmt.Fprintf(os.Stderr, " sudo bloom %s", commandName) + + // Add the original arguments + if len(os.Args) > 2 { + for _, arg := range os.Args[2:] { + fmt.Fprintf(os.Stderr, " %s", arg) + } + } + fmt.Fprintf(os.Stderr, "\n\n") + + os.Exit(1) + } +} + func runClusterCleanup() { fmt.Println("🧹 Starting Bloom cluster cleanup...") diff --git a/pkg/ansible/runtime/manifests/local-path/local-path-config.yaml b/pkg/ansible/runtime/manifests/local-path/local-path-config.yaml index a6e9c3a..6e8c6d6 100644 --- a/pkg/ansible/runtime/manifests/local-path/local-path-config.yaml +++ b/pkg/ansible/runtime/manifests/local-path/local-path-config.yaml @@ -29,5 +29,5 @@ data: spec: containers: - name: helper-pod - image: busybox + image: ghcr.io/silogen/cluster-busybox:1.37.0 imagePullPolicy: IfNotPresent \ No newline at end of file diff --git a/pkg/ansible/runtime/manifests/local-path/local-path-provisioner.yaml b/pkg/ansible/runtime/manifests/local-path/local-path-provisioner.yaml index 7eaf14b..5017716 100644 --- a/pkg/ansible/runtime/manifests/local-path/local-path-provisioner.yaml +++ b/pkg/ansible/runtime/manifests/local-path/local-path-provisioner.yaml @@ -6,7 +6,7 @@ metadata: labels: app.kubernetes.io/name: local-path-provisioner app.kubernetes.io/instance: local-path-provisioner - app.kubernetes.io/version: v0.0.29 + app.kubernetes.io/version: v0.0.34 spec: replicas: 1 strategy: @@ -26,7 +26,7 @@ spec: serviceAccountName: local-path-provisioner-service-account containers: - name: local-path-provisioner - image: rancher/local-path-provisioner:v0.0.29 + image: ghcr.io/silogen/cluster-lpr:v0.0.34 imagePullPolicy: IfNotPresent command: - local-path-provisioner diff --git a/pkg/ansible/runtime/playbooks/tasks/setup_local_path.yml b/pkg/ansible/runtime/playbooks/tasks/setup_local_path.yml index cf6e3a9..9074857 100644 --- a/pkg/ansible/runtime/playbooks/tasks/setup_local_path.yml +++ b/pkg/ansible/runtime/playbooks/tasks/setup_local_path.yml @@ -100,7 +100,7 @@ spec: containers: - name: test-container - image: busybox + image: ghcr.io/silogen/cluster-busybox:1.37.0 command: - sh - -c