3

I've tried the following Puppet configuration to disable the root password:

class users {
  user { 'root':
    password => '*',
  }
}

But after applying it with no warnings or error messages I could still su - with the old password. Only after inspecting the debug output did it become clear why:

# puppet apply --debug --modulepath modules manifests/host.pp
[...]
Debug: Failed to load library 'shadow' for feature 'libshadow'
[...]

Wat. I know how to fix this (sudo pacman --sync --needed --refresh ruby-shadow), but that's not the point. How do I force Puppet to crash and burn when it can't apply my configuration, at the very least by giving a non-zero exit code? --detailed-exitcodes doesn't help.

Workaround: The following only works if run twice - on the first run it ignores the user entry when compiling the catalogue.

class users {
  package { 'ruby-shadow':
    ensure => present,
  }

  user { 'root':
    password => '*',
    require => Package['ruby-shadow'],
  }
}
-2

You can use puppet apply --help to see all the available options. This is the one you're interested in:

* --detailed-exitcodes:
  Provide transaction information via exit codes. If this is enabled, an exit
  code of '2' means there were changes, an exit code of '4' means there were
  failures during the transaction, and an exit code of '6' means there were both
  changes and failures.

In your specific case:

# puppet apply --detailed-exitcodes --debug --modulepath modules manifests/host.pp
  • Please read my post. I already tried it, and I have yet to see it give anything other than 0 exit code. – l0b0 Oct 31 '14 at 22:04
  • Hi l0b0, I am facing similar issue. Did you get any solution for the issue ? – Praveen Dec 26 '18 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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