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

visudo not found in PATH after new sudoers is generated. #136

Open
r2oro opened this issue Feb 21, 2019 · 2 comments
Open

visudo not found in PATH after new sudoers is generated. #136

r2oro opened this issue Feb 21, 2019 · 2 comments

Comments

@r2oro
Copy link

r2oro commented Feb 21, 2019

Cookbook version

3.5.3

Chef-client version

13.9.1

Platform Details

Vagrant boxes:
bento/centos-6.9
bento/centos-7.4
oel66

Scenario:

On second kitchen converge in row following recipe fails:

           sudo("users_cloud_admin") do
             action [:install]
             default_guard_interpreter :default
             declared_type :sudo
             cookbook_name "hc_base_user"
             recipe_name "linux"
             user "+users_cloud_admin"
           end

Steps to Reproduce:

Just declare:

  sudo netgroup do
    user "+#{netgroup}"
  end

Expected Result:

sudo entry created for netgroup and successful converge

Actual Result:

Exception thrown. Converger interrupted.

       Recipe: hc_base_user::linux
         * sudo[users_cloud_admin] action install

           ================================================================================
           Error executing action `install` on resource 'sudo[users_cloud_admin]'
           ================================================================================

           Errno::ENOENT
           -------------
           No such file or directory - visudo

           Cookbook Trace:
           ---------------
           /tmp/kitchen/cache/cookbooks/sudo/providers/default.rb:49:in `validate_fragment!'
           /tmp/kitchen/cache/cookbooks/sudo/providers/default.rb:104:in `render_sudoer'
           /tmp/kitchen/cache/cookbooks/sudo/providers/default.rb:126:in `block in class_from_file'

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/hc_base_user/recipes/linux.rb

            75:   sudo netgroup do
            76:     user "+#{netgroup}"
            77:   end
            78: end

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/hc_base_user/recipes/linux.rb:75:in `block in from_file'

           sudo("users_cloud_admin") do
             action [:install]
             default_guard_interpreter :default
             declared_type :sudo
             cookbook_name "hc_base_user"
             recipe_name "linux"
             user "+users_cloud_admin"
           end

           System Info:
           ------------
           chef_version=13.9.1
           platform=oracle
           platform_version=6.6
           ruby=ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux]
           program_name=chef-client worker: ppid=6016;start=18:30:28;
           executable=/opt/chef/bin/chef-client

STACK TRACE:

Errno::ENOENT: sudo[users_cloud_admin] (hc_base_user::linux line 75) had an error: Errno::ENOENT: No such file or directory - visudo
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/mixlib-shellout-2.3.2/lib/mixlib/shellout/unix.rb:340:in `exec'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/mixlib-shellout-2.3.2/lib/mixlib/shellout/unix.rb:340:in `block in fork_subprocess'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/mixlib-shellout-2.3.2/lib/mixlib/shellout/unix.rb:318:in `fork'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/mixlib-shellout-2.3.2/lib/mixlib/shellout/unix.rb:318:in `fork_subprocess'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/mixlib-shellout-2.3.2/lib/mixlib/shellout/unix.rb:95:in `run_command'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/mixlib-shellout-2.3.2/lib/mixlib/shellout.rb:263:in `run_command'
/tmp/kitchen/cache/cookbooks/sudo/providers/default.rb:49:in `validate_fragment!'
/tmp/kitchen/cache/cookbooks/sudo/providers/default.rb:104:in `render_sudoer'
/tmp/kitchen/cache/cookbooks/sudo/providers/default.rb:126:in `block in class_from_file'
(eval):2:in `block in action_install'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.9.1/lib/chef/provider.rb:225:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.9.1/lib/chef/provider.rb:225:in `compile_and_converge_action'
(eval):2:in `action_install'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.9.1/lib/chef/provider.rb:171:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.9.1/lib/chef/resource.rb:592:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.9.1/lib/chef/runner.rb:70:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.9.1/lib/chef/runner.rb:98:in `block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.9.1/lib/chef/runner.rb:98:in `each'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.9.1/lib/chef/runner.rb:98:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.9.1/lib/chef/resource_collection/resource_list.rb:94:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.9.1/lib/chef/resource_collection/stepable_iterator.rb:114:in `call_iterator_block'

Actually visudo is installed in /usr/sbin/visudo. However during second converge /usr/sbin is not found by chef (!). Despite 'sudo bash' showing correct path. It's something to do with 'secure_path' setting which disappears from newly generated sudoers. As w workaround I'm explicitly adding secure_path = /sbin:/bin:/usr/sbin:/usr/bin as sudoers_defaults attribute. But this is not very clean, is it? Cookbooks chops off the branch it is sitting on...

@welcomebot
Copy link

Hey There
It looks like this is the first issue you've filed against the chef-cookbooks project. I'm here to offer you a bit of extra help to make sure we can quickly get back to you.
Make sure you've filled out all the fields in our issue template. Make sure you've provided us with the version of chef-client you're running, your operating system and the version of the cookbook. If you're not using the most up to date version of the cookbook then please make sure to update first. Lots of things change between versions even if you're issue isn't listed in the changelog. Finally please give us a detailed description of the issue you're having. The more we know about what you're trying to do, what actually happens, and how you can reproduce the problem, the better.

If you're looking for more immediate troubleshooting help make sure to check out #general on the Chef Community Slack. There's plenty of folks there willing to lend a helping hand. Thanks for the first issue. We hope we can get back to you soon with a solution.

@Raghureddy4545
Copy link

Same issue here..

chef-client version
13.10.0
platfrom
suse 11

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

3 participants