How to get non-zero exit code when configuration cannot be applied?

asked 2014-11-03 08:33:21 -0600

l0b0 gravatar image

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'],
  }
}

Reposted from unix.stackexchange.com.

edit retag flag offensive close merge delete

Comments

1

https://tickets.puppetlabs.com/browse/PUP-1161 is the issue with the workaround, for what it's worth.

domcleal gravatar imagedomcleal ( 2014-11-03 11:58:00 -0600 )edit

Thanks! The bug was reported over ten months ago though, so I'm not too hopeful.

l0b0 gravatar imagel0b0 ( 2014-11-03 12:10:36 -0600 )edit