Re: [Puppet Users] Problem during setting password for user, using puppet provisioner of Vagrant

304 views
Skip to first unread message

Brian Gupta

unread,
Jul 2, 2012, 3:24:15 PM7/2/12
to puppet...@googlegroups.com
On Mon, Jul 2, 2012 at 11:10 AM, nikosd23 <niko...@gmail.com> wrote:
> Hi,
>
> I am trying to set the password for a user that I have created using the
> puppet provisioner of Vagrant for a Linux version 2.6.32-71.el6.x86_64 Red
> Hat 4.4.4-13 box.
>
> I have tried both approaches:
>
> Approach1
> user { "test":
>     ensure   => present,
>     shell    => "/bin/bash",
>     password => "encrypted_password_generated_by_passwd_command",
>     managehome => true,
> }

This is the approach I would take, but you need libshadow-ruby
installed for it to work.

>
> Approach2
> exec { "create-test-password":
>     onlyif => "/bin/egrep '^test:' /etc/passwd",
>     command => '/usr/sbin/usermod -p
> $6$BlODgWJe$eQ.xkRSzkXpMudl831q78I8lh4hHLVGVKds.6hpcPe348uoqWXmlf6PC1s4TfmPhYrPHo6dbdbmNkz2UxewfS1
> test',
>     require => User["test"],
> }
>
> The first approach fills in the /etc/shadow file with an entry !! concerning
> the hashed password of the specific user,
>
> The second approach fills in a part of the above hashed password the
> /etc/shadow file entry., ie. for the above example:
>
> test:.xkRSzkXpMudl831q78I8lh4hHLVGVKds.6hpcPe348uoqWXmlf6PC1s4TfmPhYrPHo6dbdbmNkz2UxewfS1:15523:0:99999:7:::
>
> Is there something I am missing? Is there any other approach that I should
> use?
>
> My puppet version is 2.7.1 ( and my Vagrant version is 1.0.3 although I dont
> know if this relates with my problem) .
>
> Thanks in advance.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/tYRgMXG0SxQJ.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.

jcbollinger

unread,
Jul 3, 2012, 3:56:28 PM7/3/12
to puppet...@googlegroups.com


On Monday, July 2, 2012 2:24:15 PM UTC-5, Brian Gupta wrote:
On Mon, Jul 2, 2012 at 11:10 AM, nikosd23 <niko...@gmail.com> wrote:
> Hi,
>
> I am trying to set the password for a user that I have created using the
> puppet provisioner of Vagrant for a Linux version 2.6.32-71.el6.x86_64 Red
> Hat 4.4.4-13 box.
>
> I have tried both approaches:
>
> Approach1
> user { "test":
>     ensure   => present,
>     shell    => "/bin/bash",
>     password => "encrypted_password_generated_by_passwd_command",
>     managehome => true,
> }

This is the approach I would take, but you need libshadow-ruby
installed for it to work.

Also, it's a good idea to use single quotes around the password hash instead of double quotes.  Password hashes have an unfortunate tendency to include '$' characters, which Puppet will tend to try to interpret as a variable reference except when the string is single-quoted.

In fact, it's a good idea to always use single quotes in your Puppet manifests except where you specifically want variable interpolation.


John

Reply all
Reply to author
Forward
0 new messages