[chef] Re: How to pass hash password from ruby-block to user resource


Chronological Thread 
  • From: Noah Kantrowitz < >
  • To:
  • Subject: [chef] Re: How to pass hash password from ruby-block to user resource
  • Date: Tue, 30 Sep 2014 13:29:28 -0700

Please don't cross-post to SO and the ML at the same time. Means twice as 
many people will spend the time to answer you when either one would be just 
fine.

--Noah

On Sep 30, 2014, at 12:08 PM, 
< >
 
< >
 wrote:

> 
> Hi All,
> 
> I am trying to implement a cookbook which would create users by reading
> passwords from attributes file ( non hash password ex: 
>  )
> 
> And for this, my cookbook is as follows :
> 
> 1. Contains of attributes file ( attributes/attr.rb )
> 
> default['my']['instance']['users']=[{uid:
> 1004,user_name:'m1',homedir:'/home/m1',password:' '},{uid:
> 1003,user_name:'m2',homedir:'/home/m2',password:' '},{uid:
>  1002,
> user_name:'m3',homedir:'/home/m3',password:' '}]
> 
> 2. Recipe : 
> 
> password_hash=''
> node['my']['instance']['users'].each do |each_user|
>    ruby_block "Generating hash password" do
>       block do
>           require 'digest/sha2'
>           password=each_user['password']
>           salt=rand(36**8).to_s(36)
>           shadow_hash=password.crypt("$6$" + salt)
>           password_hash=shadow_hash
>       end
>    end
> 
>    user each_user['user_name'] do
>       password "#{password_hash}"
>       home each_user['homedir']
>       system true
>       action :create
>       manage_home true
>       uid each_user['uid']
>    end
> end
> 
> 
> After execution of the cookbook, respective users are created appropriately 
> but
> passwords are set blank.
> 
> Looks like the variable which I am trying to access in the password 
> attribute
> of user resource is not correct.
> 
> Please let me how can I resolve this.
> 
> Note : In my case, I dont want to use databags
> 
> Thanks,
> Pratik

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail




Archive powered by MHonArc 2.6.16.

§