- From: "Moser, Kevin" <
>
- To: "
" <
>
- Subject: [chef] Re: RE: Re: RE: Re: Re: Use template or cookbook_file resources to put something in a user's home directory?
- Date: Tue, 7 Jan 2014 18:16:24 +0000
- Accept-language: en-US
When you are creating that user, are you setting the home directory on the
"user" resource? If so, is that coming out of an attribute? You would
probably just want to reference that attribute then since on first run you
know that would be there.
If not, then yeah, you would have to do some sort of notified (by the user
resource) ruby_block to update/create your cookbook_file resource on the
fly.
The resource collection is fully populated (that means all recipes in the
run list get compiled) before any convergence happens.
Another thing you could do is on your user resource force it to run at
compile so that you know it runs before the rest of your compile. This
just means that if your compile fails after it then the user already got
created so if that is problematic you wouldn't want to do that.
user "blah" do
end.run_action(:create)
On 1/7/14 9:52 AM, "Stephen Corbesero"
<
>
wrote:
>
It worked, but I wonder if compile time is too soon.
>
>
If this is part of the first run of a chef-client, that user would not
>
exist at the beginning of the run.
>
>
Do all the recipes get compiled before any of them start executing?
>
>
>
--
>
Stephen Corbesero, Performance Engineer
>
>
>
-----Original Message-----
>
From: Moser, Kevin
>
[mailto:
>
Sent: Tuesday, January 07, 2014 11:35 AM
>
To:
>
>
Subject: [chef] Re: RE: Re: Re: Use template or cookbook_file resources
>
to put something in a user's home directory?
>
>
Yup, you should be able to, assuming at the time of compile that the user
>
exists. As this code would get executed at compile time.
>
>
On 1/7/14 8:32 AM, "Stephen Corbesero"
>
<
>
>
wrote:
>
>
>Can I put that in the name of a resource?
>
>
>
>For example,
>
>
>
>cookbook_file "#{Dir.home(someuser)}/xyzzy" do
>
> ...
>
>End
>
>
>
>
>
>--
>
>Stephen Corbesero, Performance Engineer
>
>
>
>-----Original Message-----
>
>From: Moser, Kevin
>
>[mailto:
>
>Sent: Tuesday, January 07, 2014 11:27 AM
>
>To:
>
>
>
>Subject: [chef] Re: Re: Use template or cookbook_file resources to put
>
>something in a user's home directory?
>
>
>
>Dir.home will give you the current users home directory.
>
>
>
>
>
>Dir.home(user) will give you the home directory of the user specified
>
>
>
>
>
>On 1/7/14 8:24 AM, "Julian C. Dunn"
>
><
>
>
> wrote:
>
>
>
>>On Tue, Jan 7, 2014 at 11:08 AM, Stephen Corbesero
>
>><
>
>
>> wrote:
>
>>
>
>>> Is there any way to use the template and cookbook_file resources to
>
>>>put files in or under a user¹s home directory without hardcoding the
>
>>>directory as ³/home/username²?
>
>>>
>
>>> Is there some way to get the chef-client to interpret ~username like
>
>>> the shell does?
>
>>
>
>>I think File.expand_path should do it?
>
>>
>
>>irb(main):002:0> File.expand_path('~juliandunn') => "/Users/juliandunn"
>
>>
>
>>- Julian
>
>>
>
>>--
>
>>[ Julian C. Dunn
>
>><
>
>
>> * Sorry, I'm ]
>
>>[ WWW: http://www.aquezada.com/staff/julian * only Web 1.0 ]
>
>>[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
>
>>[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]
>
>
>
Archive powered by MHonArc 2.6.16.