0
votes

I am trying to use Vagrant to create an Ubuntu VM. My host is Windows7 and my basebox is precise64. If I do the recommended way of adding a user in Puppet like this:

    user { "johnboy":
    ensure => present,
    managehome => true,
    password => '$6$ev8faya2$M2pB3YQRpKUJMnJx6LnsyTbDdi.umsEEZttD01pk8ZSfMGrVmlnjoVhIHyuqYt3.yaG1SZjaoSxB39nNgFKb//',
    groups => ["admin"],
    shell => "/bin/bash";
 }

I log in after vagrant has provisioned my box and the hash is not in /etc/passwd.

If I don't set it with the resource type but use exec and usermod like this

user { "johnboy":
    ensure => present,
    managehome => true,
    groups => ["admin"],
    shell => "/bin/bash";
}

exec { 'set password':
    command => "usermod -p '$6$ev8faya2$M2pB3YQRpKUJMnJx6LnsyTbDdi.umsEEZttD01pk8ZSfMGrVmlnjoVhIHyuqYt3.yaG1SZjaoSxB39nNgFKb//' johnboy",
    require => User[johnboy];
}

I end up with only part of the hash in /etc/passwd

johnboy:.umsEEZttD01pk8ZSfMGrVmlnjoVhIHyuqYt3.yaG1SZjaoSxB39nNgFKb//:16101:0:99999:7:::

Some pages suggest installing ruby-shadow so I tried this:

gem install ruby-shadow

However, the install failed, probably because I don't have Ruby installed. Vagrant was a 100 MB download. Is the gem for managing passwords really not included with that?

How do I get Vagrant/Puppet to provision the password correctly?

1

1 Answers

1
votes

That's because it's stored inside the /etc/shadow file. This is for security reasons as it is only accessible by the root/super user.

Escape the dollar signs in the hash like this and it should work.

exec { 'set password':
    command => "usermod -p '\$6\$ev8faya2\$M2pB3YQRpKUJMnJx6LnsyTbDdi.umsEEZttD01pk8ZSfMGrVmlnjoVhIHyuqYt3.yaG1SZjaoSxB39nNgFKb//' johnboy",
    require => User[johnboy];
}