Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm configuring sudo module in puppet according to this code

class sudo {
 package { sudo:
   ensure => present,
 if $operatingsystem == "Ubuntu" {
   package { "sudo-ldap":
     ensure => present,
     require => Package["sudo"],
 file { "/etc/sudoers":
    owner => "root",
    group => "root",
    mode => 0440,
    source => "puppet://$puppetserver/modules/sudo/etc/sudoers",
    replace => true,
    require => Package["sudo"],

and got the following error :

If you have arranged other means to access the root account, and you are sure this is what you want, you may bypass this check by setting an environment variable (export SUDO_FORCE_REMOVE=yes).

What parameter and where should I put it into the code in order to make sudo command satisfies only the ssh-key without asking password.

Any suggestion would be appreciated.

share|improve this question

The error message you're getting indicates that by installing sudo-ldap that dpkg is removing sudo and the remove script is trying to warn you that this might leave you in a state without root access.

You can't set an environment variable from Puppet for dpkg, so you would need to launch the Puppet agent with the environment already set up (perhaps export from /etc/default/puppet or something similar such as an init script).

The question you're asking below though is something to do with sudo itself and is probably satisfied by using the NOPASSWD option in your /etc/sudoers file:


This allows "username" to sudo to any user, run any command without a password at all. No checking of SSH keys is done at this stage (it doesn't make sense), but the user could have connected to the system with an SSH key.

share|improve this answer

This won't work, it means that every puppet run, puppet will remove sudo-ldap and tries to install sudo, followed by installing sudo-ldap again.

The 'export SUDO_FORCE_REMOVE=yes' part was fixed by creating an executable file with the export statement and run it with an exec:

> ... 
>     if $ldap {
>     file {
>       '/tmp/':
>         ensure  => present,
>         mode    => '0700',
>         content => 'export SUDO_FORCE_REMOVE=yes';
>     } ->
>     exec { '/tmp/':
>       logoutput => on_failure;
>     } 
>     ...
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.