Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] sudo resource sudo package installation #103

Closed
ghost opened this issue May 23, 2017 · 2 comments
Closed

[BUG] sudo resource sudo package installation #103

ghost opened this issue May 23, 2017 · 2 comments

Comments

@ghost
Copy link

ghost commented May 23, 2017

Cookbook version

3.5.0

Chef-client version

13.x

Platform Details

All

Scenario:

#101 and #102 appears to have introduced a bug in the sudo resource. The intent was that if you were not using the sudo default recipe, you could just use the sudo resource to configure sudo users. So in adding the sudo package install to the sudo resource, it looks like a bug was introduced whereby the sudo package resource is happening during converge time and the sudo user configuration is occurring during compile phase:

  package 'sudo' do
    not_if 'which sudo'
  end

  unless ::File.exist?(target)
    sudoers_dir = directory target
    sudoers_dir.run_action(:create)
  end

Steps to Reproduce:

Use the sudo resource in an environment where sudo is not installed and the resource fails.

Expected Result:

I would expect for sudo resource not to fail as a result of not having sudo installed in your environment as the resource would install sudo and then configure the sudo user.

Actual Result:

    ================================================================================
    Error executing action `install` on resource 'sudo[made-up-user]'
    ================================================================================
    
    Errno::ENOENT
    -------------
    No such file or directory - visudo
    
    Cookbook Trace:
    ---------------
    /opt/kitchen/cache/cookbooks/sudo/providers/default.rb:49:in `validate_fragment!'
    /opt/kitchen/cache/cookbooks/sudo/providers/default.rb:104:in `render_sudoer'
    /opt/kitchen/cache/cookbooks/sudo/providers/default.rb:126:in `block in class_from_file'
    
    Resource Declaration:
    ---------------------
    # In /opt/kitchen/cache/cookbooks/chassis-users/recipes/default.rb
    
     23:     sudo user do
     24:       user user
     25:       nopasswd true
     26:     end
     27: 
    
    Compiled Resource:
    ------------------
    # Declared in /opt/kitchen/cache/cookbooks/chassis-users/recipes/default.rb:23:in `block in from_file'
    
    sudo("made-up-user") do
      action :install
      updated true
      updated_by_last_action true
      default_guard_interpreter :default
      supports {:report=>true, :exception=>true}
      declared_type :sudo
      cookbook_name "chassis-users"
      recipe_name "default"
      user "made-up-user"
      nopasswd true
    end
    
    System Info:
    ------------
    chef_version=13.0.118
    platform=ubuntu
    platform_version=16.04
    ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
    program_name=chef-client worker: ppid=9;start=02:48:29;
    executable=/opt/chef/embedded/bin/chef-client
@ghost
Copy link
Author

ghost commented May 23, 2017

The easiest way to test this would probably be using dokken in a docker container where sudo does not initially exist ....

@tas50
Copy link
Contributor

tas50 commented Mar 12, 2018

This functionality has been removed on master unless running on docker where sudo does need to be installed. This should resolve things.

@tas50 tas50 closed this as completed Mar 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant