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'd like to set the default shell to zsh in Puppet. Preferably for the current user because I just run my modules as puppet apply mymodule.pp since I store my configuration that I use across multiple machines in git.

How can I set the default shell using puppet?

share|improve this question
up vote 8 down vote accepted

If you want to set the shell of an existing user, simply do:

user { "theuser":
  ensure => present,
  shell  => "/bin/zsh",

If you want to set the shell of whatever user Puppet is happening to run as, you can make use of the $id fact which returns the name of the current user. This feels a little bit magical to me, and may result in undesired outcomes, like if you're running as the puppet user with a puppet agent run and you end up setting a shell for a user that shouldn't have interactive logins.

That would be done like:

user { $id:
  ensure => present,
  shell  => "/bin/zsh",

Note: the "ensure => present" is optional.

share|improve this answer
Thanks! Unfortunately setting the shell requires superuser privileges and hence I can't use $id as it points to root. I also added the required quotes around the shell variable. – Jason Axelson Apr 10 '12 at 4:19

You can specify user shell when you realize the user, which should be created as a virtual resource. See or search for puppet best practices to get details.

share|improve this answer
What happens if the user already exists? – Martijn Heemels Mar 30 '12 at 20:15
is that exacty the same user? if so, puppet should update the default shell from the recipe. if the same uid but different user, then you have a conflict and you need to remove the user with the uid in the system so that puppet will run. however, – johnshen64 Mar 30 '12 at 22:01

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.