puppet-rbenv icon indicating copy to clipboard operation
puppet-rbenv copied to clipboard

rbenv::build fails when $rbenv::owner is not root

Open ashleygould opened this issue 11 months ago • 0 comments

When building a ruby version as non-root user I get the following error:

Notice: /Stage[main]/Uc3_rbenv/Uc3_rbenv::Config[3.2.3]/Rbenv::Build[3.2.3]/Exec[git-pull-rubybuild-3.2.3]/returns: fatal: detected dubious ownership in repository at '/apps/dmp/.rbenv/plugins/ruby-build'
Notice: /Stage[main]/Uc3_rbenv/Uc3_rbenv::Config[3.2.3]/Rbenv::Build[3.2.3]/Exec[git-pull-rubybuild-3.2.3]/returns: To add an exception for this directory, call:
Notice: /Stage[main]/Uc3_rbenv/Uc3_rbenv::Config[3.2.3]/Rbenv::Build[3.2.3]/Exec[git-pull-rubybuild-3.2.3]/returns:  
Notice: /Stage[main]/Uc3_rbenv/Uc3_rbenv::Config[3.2.3]/Rbenv::Build[3.2.3]/Exec[git-pull-rubybuild-3.2.3]/returns:     git config --global --add safe.directory /apps/dmp/.rbenv/plugins/ruby-build
Error: 'git reset --hard HEAD && git pull' returned 128 instead of one of [0]
Error: /Stage[main]/Uc3_rbenv/Uc3_rbenv::Config[3.2.3]/Rbenv::Build[3.2.3]/Exec[git-pull-rubybuild-3.2.3]/returns: change from 'notrun' to ['0'] failed: 'git reset --hard HEAD && git pull' returned 128 instead of one of [0]

I believe this is because the initial ruby-build plugin is cloned by the non-root user, and subsequent calls to git pull by the root user into the working tree trigger the "dubious ownership" git error.

Below is the manifest I am using:

define uc3_rbenv::config (
    $ruby_version      = $title,
    $app_user          = lookup('app_user'),
    $app_group         = lookup('app_group'),
    $app_home          = lookup('app_home'),
    $install_dir       = "${app_home}/.rbenv",
    $bundler_version   = '>=0',
    $global            = true,
) {

    file { "${app_home}/.profile.d/rbenv.sh":
       ensure        => file,
       owner         => $app_user,
       group         => $app_group,
       mode          => '0644',
       content       => template("rbenv/rbenv.sh"),
       require       => File["${app_home}/.profile.d"],
    }

    class { 'rbenv':
        owner            => $app_user,
        group            => $app_group,
        install_dir      => $install_dir,
        latest           => true,
        manage_profile   => false,
    }

    rbenv::plugin { 'rbenv/ruby-build':
        latest           => true,
    }

    rbenv::build { $ruby_version:
        global           => $global,
        bundler_version  => $bundler_version,
    }

}

Platform

agould@uc3-dmptool01x2-dev:~> facter os
{
  architecture => "x86_64",
  distro => {
    codename => "Karoo",
    description => "Amazon Linux release 2 (Karoo)",
    id => "Amazon",
    release => {
      full => "2",
      major => "2"
    }
  },
  family => "RedHat",
  hardware => "x86_64",
  name => "Amazon",
  release => {
    full => "2",
    major => "2"
  },
  selinux => {
    enabled => false
  }
}
agould@uc3-dmptool01x2-dev:~> git --version
git version 2.40.1

ashleygould avatar Mar 22 '24 20:03 ashleygould