GithubHelp home page GithubHelp logo

Comments (5)

Doltair avatar Doltair commented on July 28, 2024
 49:   git new_resource.user_prefix do
       50:     repository new_resource.git_url
       51:     reference new_resource.git_ref
       52:     action :checkout if new_resource.update_rbenv == false
       53:     user new_resource.user
       54:     group new_resource.group <=== not working if custom group is specified
       55:     notifies :run, 'ruby_block[Add rbenv to PATH]', :immediately
       56:   end
       57: 

from ruby_rbenv.

damacus avatar damacus commented on July 28, 2024

I've confirmed with inspec that this isn't the case. So I'm a little confused how you're setting the value!

See this test for how I'm setting the group: https://github.com/sous-chefs/ruby_rbenv/pull/245/files#diff-2f1fd653c59c431dfe5f42fd9c8c5fdc

And here for me testing for the correct group: https://github.com/sous-chefs/ruby_rbenv/pull/245/files#diff-817b63b0dbded23627f5495795b18289

from ruby_rbenv.

Doltair avatar Doltair commented on July 28, 2024

Hi @damacus

thank you so much for taking this for a review.

My case was the group of the user is different and they are not alike. E.g vagrant:adminuser not vagrant:vagrant

Here are my concerns: let me know if i am using the resource correctly

But i want is:

ruby_rbenv resource

rbenv_user_install 'appuser' do
  user 'appuser'
  group 'appuserdifferentgroup' <== need to override. Group is not the same as user
end

for what's happening: The output of that resource becomes

rbenv_user_install 'appuser' do
  user 'appuser'
  group 'appuser' <== thinking because of the default value in the custom resources under user_install
end

Im using these resource and needing it to override the group as there are cases that user and group are not the same:

# Keeps the rbenv install upto date
node.default['webhook_api']['app_username'] = node['webhook_api']['special_account']['user'] if node['webhook_api']['special_account_enable'] == true
rbenv_user_install(node['webhook_api']['app_username']).to_s do
  user(node['webhook_api']['app_username']).to_s
  group node['webhook_api']['app_username'] if node['webhook_api']['special_account_enable'] == false
  group node['webhook_api']['special_account']['group'] if node['webhook_api']['special_account_enable'] == true
end

in my case if the service account group is available in the node, it should override the group. if false, it will use the normal user which has the same group as user.

e.g

if service account user set to false, my cookbook will create a new user like webhook_admin:webhook_admin
if service account set to true, it will use a different attribute and use the service account user like serviceaccountuser:serviceaccountgroup which user:group are not alike.

from ruby_rbenv.

Doltair avatar Doltair commented on July 28, 2024

Hi @damacus,

Still not working, the cookbook can't see ldap group even its specified on resource rbenv_user_install. the group that stated in

rbenv_user_install 'apiuser' do
  user 'apiuser'
  group 'apiadmins'
end 

And then throws me an exception below, and it seems the resource still using the user as the the group

  ================================================================================
    Error executing action `sync` on resource 'git[/home/apiuser/.rbenv]'
    ================================================================================
    
    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0, 128], but received '1'
    ---- Begin output of git rev-parse HEAD ----
    STDOUT: 
    STDERR: /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/mixlib-shellout-2.4.0/lib/mixlib/shellout.rb:220:in `getgrnam': can't find group for apiuser (ArgumentError)
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/mixlib-shellout-2.4.0/lib/mixlib/shellout.rb:220:in `gid'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/mixlib-shellout-2.4.0/lib/mixlib/shellout/unix.rb:162:in `set_group'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/mixlib-shellout-2.4.0/lib/mixlib/shellout/unix.rb:333:in `block in fork_subprocess'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/mixlib-shellout-2.4.0/lib/mixlib/shellout/unix.rb:318:in `fork'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/mixlib-shellout-2.4.0/lib/mixlib/shellout/unix.rb:318:in `fork_subprocess'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/mixlib-shellout-2.4.0/lib/mixlib/shellout/unix.rb:95:in `run_command'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/mixlib-shellout-2.4.0/lib/mixlib/shellout.rb:267:in `run_command'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/mixin/shell_out.rb:234:in `shell_out_command'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/mixin/shell_out.rb:200:in `shell_out_compacted!'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/mixin/shell_out.rb:124:in `shell_out!'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/provider/git.rb:338:in `git'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/provider/git.rb:137:in `find_current_revision'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/provider/git.rb:38:in `load_current_resource'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/provider.rb:165:in `run_action'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/resource.rb:578:in `run_action'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/runner.rb:70:in `run_action'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/runner.rb:98:in `block (2 levels) in converge'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/runner.rb:98:in `each'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/runner.rb:98:in `block in converge'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/resource_collection/resource_list.rb:94:in `block in execute_each_resource'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/resource_collection/stepable_iterator.rb:114:in `call_iterator_block'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/resource_collection/stepable_iterator.rb:103:in `iterate'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/resource_collection/resource_list.rb:92:in `execute_each_resource'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/runner.rb:97:in `converge'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/provider.rb:237:in `compile_and_converge_action'
      from (eval):2:in `action_install'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/provider.rb:182:in `run_action'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/resource.rb:578:in `run_action'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/runner.rb:70:in `run_action'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/runner.rb:98:in `block (2 levels) in converge'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/runner.rb:98:in `each'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/runner.rb:98:in `block in converge'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/resource_collection/resource_list.rb:94:in `block in execute_each_resource'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/resource_collection/stepable_iterator.rb:114:in `call_iterator_block'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/resource_collection/stepable_iterator.rb:103:in `iterate'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/resource_collection/resource_list.rb:92:in `execute_each_resource'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/runner.rb:97:in `converge'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/client.rb:720:in `block in converge'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/client.rb:715:in `catch'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/client.rb:715:in `converge'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/client.rb:754:in `converge_and_save'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/client.rb:286:in `run'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/application.rb:321:in `block in fork_chef_client'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/application.rb:309:in `fork'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/application.rb:309:in `fork_chef_client'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/application.rb:274:in `block in run_chef_client'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/local_mode.rb:44:in `with_server_connectivity'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/application.rb:261:in `run_chef_client'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/application/client.rb:475:in `sleep_then_run_chef_client'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/application/client.rb:464:in `block in interval_run_chef_client'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/application/client.rb:463:in `loop'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/application/client.rb:463:in `interval_run_chef_client'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/application/client.rb:447:in `run_application'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/lib/chef/application.rb:66:in `run'
      from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.7.17/bin/chef-client:25:in `<top (required)>'
      from /bin/chef-client:74:in `load'
      from /bin/chef-client:74:in `<main>'
    ---- End output of git rev-parse HEAD ----
    Ran git rev-parse HEAD returned 1
    
    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/ruby_rbenv/resources/user_install.rb
    
     49:   git new_resource.user_prefix do
     50:     repository new_resource.git_url
     51:     reference new_resource.git_ref
     52:     action :checkout if new_resource.update_rbenv == false
     53:     user new_resource.user
     54:     group new_resource.group
     55:     notifies :run, 'ruby_block[Add rbenv to PATH]', :immediately
     56:   end
     57: 
    
    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/ruby_rbenv/resources/user_install.rb:49:in `block in class_from_file'
    
    git("/home/apiuser/.rbenv") do
      action [:sync]
      default_guard_interpreter :default
      declared_type :git
      cookbook_name "does_api_server"
      repository "https://github.com/rbenv/rbenv.git"
      revision "master"
      user "apiuser"
      group "apiuser"
      destination "/home/apiuser/.rbenv"
      additional_remotes {}
    end
    
    System Info:
    ------------
    chef_version=14.7.17
    platform=redhat
    platform_version=7.4
    ruby=ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
    program_name=chef-client worker: ppid=59171;start=08:19:18;
    executable=/opt/chef/bin/chef-client
    
[2019-01-31T08:19:26-06:00] INFO: Running queued delayed notifications before re-raising exception
  
  ================================================================================
  Error executing action `install` on resource 'ruby_rbenv_user_install[apiuser]'
  ================================================================================
  
  Mixlib::ShellOut::ShellCommandFailed
  ------------------------------------
  git[/home/apiuser/.rbenv] (/var/chef/cache/cookbooks/ruby_rbenv/resources/user_install.rb line 49) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0, 128], but received '1'
  ---- Begin output of git rev-parse HEAD ----
  STDOUT: 
  STDERR: /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/mixlib-shellout-2.4.0/lib/mixlib/shellout.rb:220:in `getgrnam': can't find group for apiuser (ArgumentError)
    from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/mixlib-shellout-2.4.0/lib/mixlib/shellout.rb:220:in `gid'
    from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/mixlib-shellout-2.4.0/lib/mixlib/shellout/unix.rb:162:in `set_group'
    from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/mixlib-shellout-2.4.0/lib/mixlib/shellout/unix.rb:333:in `block in fork_subprocess'
    from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/mixlib-shellout-2.4.0/lib/mixlib/shellout/unix.rb:318:in `fork'

Although it works if i remove this:

 default: lazy { user } from
property :group,        String, default: lazy { user }

To become:

property :group,        String

from ruby_rbenv.

lock avatar lock commented on July 28, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from ruby_rbenv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.