- From: AJ Christensen <
>
- To:
- Subject: [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users
- Date: Fri, 1 Aug 2014 06:10:18 +1200
You ignored all of my examples and ran the code at Shell Out code at
compile time. It will be executed before the other LDAP stuff is
actually converged.
Don't be such a support vampire bro.
--AJ
On Fri, Aug 1, 2014 at 5:59 AM, Douglas Garstang
<
>
wrote:
>
AJ,
>
>
Thanks. I'm really not a ruby guy. It will take me considerable time to work
>
out your gist. I tried this. I thought the call to Mixlib::ShellOut would
>
fork a new process and therefore get me the correct result. However,
>
cmd.stdout is empty on the first run, and contains the correct getent passwd
>
reply on the second run, so I assume it's the same issue...
>
>
include_recipe "foo-ldap"
>
>
bag = data_bag("ssh-keys")
>
for item in bag do
>
>
user = data_bag_item('ssh-keys', item)
>
user_name = user['id']
>
>
execute "create_homedir" do
>
command "mkdir /home/#{user_name}"
>
creates "/home/#{user_name}"
>
action :run
>
end
>
>
log "USER_NAME = #{user_name}"
>
cmd = Mixlib::ShellOut.new("getent passwd #{user_name}")
>
cmd.run_command
>
log ">>>>>>>>>>>>>>>>>>>>>>>>>>> NODE_DATA = #{cmd.stdout}"
>
ent_array = cmd.stdout.split(':')
>
user_id = ent_array[2]
>
group_id = ent_array[3]
>
>
execute "homedir_perms" do
>
command "chown #{user_id}.#{group_id} /home/#{user_name}"
>
action :run
>
end
>
>
end
>
>
>
>
On Wed, Jul 30, 2014 at 5:25 PM, AJ Christensen
>
<
>
>
wrote:
>
>
>
> I meant to link to this too re: Mixlib ShellOut:
>
>
>
> https://github.com/opscode/chef/blob/master/lib/chef/mixin/shell_out.rb#L29-L39
>
>
>
> 'git grep shell_out' in the Chef codebase, haha! You'll see all of the
>
> places this is used.
>
>
>
> --aj
>
>
>
> On Thu, Jul 31, 2014 at 12:22 PM, AJ Christensen
>
> <
>
>
> wrote:
>
> > If you 'include Chef::Mixin::ShellOut' in a custom library, you can
>
> > use #shell_out! there.
>
> >
>
> > using the lazy attribute evaluator and the Mixin ShellOut classes'
>
> > shell_out!() functionality, something like this outta' work:
>
> > https://gist.github.com/fujin/f0b7dd38b558001c5913
>
> >
>
> > --aj
>
> >
>
> > On Thu, Jul 31, 2014 at 12:03 PM, Daniel DeLeo
>
> > <
>
>
> > wrote:
>
> >> On Wednesday, July 30, 2014 at 5:00 PM, Douglas Garstang wrote:
>
> >>> AJ,
>
> >>>
>
> >>> Thanks. One more question... shelling out in chef and grabbing the
>
> >>> output... has never been an easy task... best approach?
>
> >>>
>
> >>> I was able to do this just now with the execute resource, I guess
>
> >>> because that forks a new process too. It would be nice though to call
>
> >>> getent
>
> >>> in some fashion, and the parse the output, so that I could be sure
>
> >>> that the
>
> >>> group id I am assigning is the correct one for the user. At the moment
>
> >>> it's
>
> >>> coming out of a data bag.
>
> >>>
>
> >>> Also kinda gross.
>
> >>>
>
> >>> Doug
>
> >> Well, it’ll be a little gross, but I think you’ll have to use a lazy
>
> >> attribute
>
> >> http://docs.getchef.com/resource_common.html#lazy-attribute-evaluation
>
> >>
>
> >> In the code block you give to `lazy`, you can use backticks or %x to
>
> >> run a command that returns the UID.
>
> >>
>
> >>
>
> >> --
>
> >> Daniel DeLeo
>
> >>
>
> >>
>
> >>
>
>
>
>
>
--
>
Regards,
>
>
Douglas Garstang
>
http://www.linkedin.com/in/garstang
>
Email:
>
>
Cell: +1-805-340-5627
- [chef] Re: Re: Re: Re: Chef and LDAP Users, (continued)
- [chef] Re: Re: Re: Re: Chef and LDAP Users, Adam Jacob, 07/30/2014
- [chef] Re: Re: Re: Re: Re: Chef and LDAP Users, Douglas Garstang, 07/30/2014
- [chef] Re: Re: Re: Re: Re: Re: Chef and LDAP Users, AJ Christensen, 07/30/2014
- [chef] Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users, Douglas Garstang, 07/30/2014
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users, AJ Christensen, 07/30/2014
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users, Douglas Garstang, 07/30/2014
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users, Daniel DeLeo, 07/30/2014
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users, AJ Christensen, 07/30/2014
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users, AJ Christensen, 07/30/2014
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users, Douglas Garstang, 07/31/2014
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users, AJ Christensen, 07/31/2014
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users, AJ Christensen, 07/31/2014
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users, Douglas Garstang, 07/31/2014
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users, AJ Christensen, 07/31/2014
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users, AJ Christensen, 07/31/2014
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users, Douglas Garstang, 07/31/2014
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users, AJ Christensen, 07/31/2014
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users, AJ Christensen, 07/31/2014
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users, Douglas Garstang, 07/31/2014
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users, Joe Nuspl, 07/31/2014
- [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Chef and LDAP Users, AJ Christensen, 07/31/2014
Archive powered by MHonArc 2.6.16.