How to know the developer name who ran the knife cmd?

Ohai!

Is there any api call to know the developer’s name who fired the knife cmd to launch a new instance?


@millisami
~ Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

The node registers itself using a shared validator so that information isn't tracked. Are you using EC2 or vSphere? The accounting of who launched what instances could be handled through that.

On Friday, September 21, 2012 at 1:49 PM, Sachin Sagar Rai wrote:

Ohai!

Is there any api call to know the developer's name who fired the knife cmd to launch a new instance?


@millisami
~ Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

It sounds like all you need is a knife plugin that reads ENV['USER'] and sets a node attribute.

On Sep 21, 2012, at 10:49 PM, Sachin Sagar Rai millisami@gmail.com wrote:

Ohai!

Is there any api call to know the developer's name who fired the knife cmd to launch a new instance?


@millisami
~ Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Sent with Sparrow

how you are launching the instances?
If you are using knife ec2 or similar plugins, you need to build the
tooling using the corresponding IAM id the user is using to spawn the
instance , this also assumes that you have unique IAM account for
individual users. Then you need to correlate this from the instance
creation time. You can do this either from the chef-server log (splunk can
easily detect such patterns) or use the couch db api to grab the node's
etag .

I cant think of any straight forward way to get this info.

I think questions like this is very important as they are a very basic need
from asset management perspective. I am trying to develop something like
this , but for me its easier as i dont we use unique key for every user and
the exact user name and public key is shared across chef, aws keypair,

regards
ranjib
On Sat, Sep 22, 2012 at 2:31 AM, Andrea Campi
andrea.campi@zephirworks.comwrote:

It sounds like all you need is a knife plugin that reads ENV['USER'] and
sets a node attribute.

On Sep 21, 2012, at 10:49 PM, Sachin Sagar Rai millisami@gmail.com
wrote:

Ohai!

Is there any api call to know the developer's name who fired the knife cmd
to launch a new instance?


@millisami
~ Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Sent with Sparrow http://www.sparrowmailapp.com/?sig

Great idea, here’s something I whipped together to get that to work. I modified my bootstrap template to change the first-boot.json stanza to this:

(
cat <<‘EOP’
<%= { “run_list” => @run_list, “bootstrap” => { “client” => Chef::Config[:client_key].split(’/’).last, “time” => Time.now.to_i } }.to_json %>
EOP
) > /etc/chef/first-boot.json

this renders to this:

{“run_list”:[],“bootstrap”:{“client”:“mray.pem”,“time”:1348288293}}

and looks like this:

knife node show ubuntu1-1204.vm -a bootstrap
bootstrap:
client: mray.pem
time: 1348288293

Thanks,
Matt Ray
Senior Technical Evangelist | Opscode Inc.
matt@opscode.com | (512) 731-2218
Twitter, IRC, GitHub: mattray


From: Andrea Campi [andrea.campi@zephirworks.com]
Sent: Friday, September 21, 2012 4:01 PM
To: chef@lists.opscode.com
Cc: chef@lists.opscode.com
Subject: [chef] Re: How to know the developer name who ran the knife cmd?

It sounds like all you need is a knife plugin that reads ENV[‘USER’] and sets a node attribute.

On Sep 21, 2012, at 10:49 PM, Sachin Sagar Rai <millisami@gmail.commailto:millisami@gmail.com> wrote:

Ohai!

Is there any api call to know the developer’s name who fired the knife cmd to launch a new instance?


@millisami
~ Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Sent with Sparrowhttp://www.sparrowmailapp.com/?sig

@matt, liked the idea.

But wondering where to put it coz now the chef-client is installed via omnibus, not the bootstrap template from .chef/bootstrap/file1?

Do I've to first dwnld the shell script file that ships with omnibus and modify it and use it instead of automatically fetched one?


@millisami
~ Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Saturday, September 22, 2012 at 10:20 AM, Matt Ray wrote:

Great idea, here's something I whipped together to get that to work. I modified my bootstrap template to change the first-boot.json stanza to this:

(
cat <<'EOP'
<%= { "run_list" => @run_list, "bootstrap" => { "client" => Chef::Config[:client_key].split('/').last, "time" => Time.now.to_i } }.to_json %>
EOP
) > /etc/chef/first-boot.json

this renders to this:

{"run_list":,"bootstrap":{"client":"mray.pem","time":1348288293}}

and looks like this:

knife node show ubuntu1-1204.vm -a bootstrap
bootstrap:
client: mray.pem
time: 1348288293

Thanks,
Matt Ray
Senior Technical Evangelist | Opscode Inc.
matt@opscode.com (mailto:matt@opscode.com) | (512) 731-2218
Twitter, IRC, GitHub: mattray

From: Andrea Campi [andrea.campi@zephirworks.com (mailto:andrea.campi@zephirworks.com)]
Sent: Friday, September 21, 2012 4:01 PM
To: chef@lists.opscode.com (mailto:chef@lists.opscode.com)
Cc: chef@lists.opscode.com (mailto:chef@lists.opscode.com)
Subject: [chef] Re: How to know the developer name who ran the knife cmd?

It sounds like all you need is a knife plugin that reads ENV['USER'] and sets a node attribute.

On Sep 21, 2012, at 10:49 PM, Sachin Sagar Rai <millisami@gmail.com (mailto:millisami@gmail.com)> wrote:

Ohai!

Is there any api call to know the developer's name who fired the knife cmd to launch a new instance?


@millisami
~ Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

Yes, you’d need to modify your local chef-full.erb and put it in your .chef/bootstrap/ directory for your repo. If it seems worthwhile, I could put it into a pull request and see about getting it merged into the other default bootstraps that come with Chef.

Here’s another update to it:

(
cat <<‘EOP’
<%= { “run_list” => @run_list, “bootstrap” => { “client” => Chef::Config[:client_key].split(’/’).last, “time” => Time.now.to_i , “user” => ENV[‘USER’]} }.to_json %>
EOP
) > /etc/chef/first-boot.json

produces

$ knife node show ubuntu1-1204.vm -a bootstrap
bootstrap:
client: mray.pem
time: 1348323159
user: mray

Thanks,
Matt Ray
Senior Technical Evangelist | Opscode Inc.
matt@opscode.com | (512) 731-2218
Twitter, IRC, GitHub: mattray


From: Sachin Sagar Rai [millisami@gmail.com]
Sent: Saturday, September 22, 2012 6:38 AM
To: chef@lists.opscode.com
Subject: [chef] Re: RE: Re: How to know the developer name who ran the knife cmd?

@matt, liked the idea.

But wondering where to put it coz now the chef-client is installed via omnibus, not the bootstrap template from .chef/bootstrap/file1?

Do I’ve to first dwnld the shell script file that ships with omnibus and modify it and use it instead of automatically fetched one?


@millisami
~ Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Sent with Sparrowhttp://www.sparrowmailapp.com/?sig

On Saturday, September 22, 2012 at 10:20 AM, Matt Ray wrote:

Great idea, here’s something I whipped together to get that to work. I modified my bootstrap template to change the first-boot.json stanza to this:

(
cat <<‘EOP’
<%= { “run_list” => @run_list, “bootstrap” => { “client” => Chef::Config[:client_key].split(’/’).last, “time” => Time.now.to_i } }.to_json %>
EOP
) > /etc/chef/first-boot.json

this renders to this:

{“run_list”:[],“bootstrap”:{“client”:“mray.pem”,“time”:1348288293}}

and looks like this:

knife node show ubuntu1-1204.vm -a bootstrap
bootstrap:
client: mray.pem
time: 1348288293

Thanks,
Matt Ray
Senior Technical Evangelist | Opscode Inc.
matt@opscode.commailto:matt@opscode.com | (512) 731-2218
Twitter, IRC, GitHub: mattray


From: Andrea Campi [andrea.campi@zephirworks.commailto:andrea.campi@zephirworks.com]
Sent: Friday, September 21, 2012 4:01 PM
To: chef@lists.opscode.commailto:chef@lists.opscode.com
Cc: chef@lists.opscode.commailto:chef@lists.opscode.com
Subject: [chef] Re: How to know the developer name who ran the knife cmd?

It sounds like all you need is a knife plugin that reads ENV[‘USER’] and sets a node attribute.

On Sep 21, 2012, at 10:49 PM, Sachin Sagar Rai <millisami@gmail.commailto:millisami@gmail.com> wrote:

Ohai!

Is there any api call to know the developer’s name who fired the knife cmd to launch a new instance?


@millisami
~ Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Sent with Sparrowhttp://www.sparrowmailapp.com/?sig

http://tickets.opscode.com/browse/CHEF-3479 has the fix in a pull request for Chef 11.

Thanks,
Matt Ray
Senior Technical Evangelist | Opscode Inc.
matt@opscode.com | (512) 731-2218
Twitter, IRC, GitHub: mattray


From: Matt Ray [matt@opscode.com]
Sent: Saturday, September 22, 2012 9:15 AM
To: chef@lists.opscode.com
Subject: [chef] RE: Re: RE: Re: How to know the developer name who ran the knife cmd?

Yes, you’d need to modify your local chef-full.erb and put it in your .chef/bootstrap/ directory for your repo. If it seems worthwhile, I could put it into a pull request and see about getting it merged into the other default bootstraps that come with Chef.

Here’s another update to it:

(
cat <<‘EOP’
<%= { “run_list” => @run_list, “bootstrap” => { “client” => Chef::Config[:client_key].split(’/’).last, “time” => Time.now.to_i , “user” => ENV[‘USER’]} }.to_json %>
EOP
) > /etc/chef/first-boot.json

produces

$ knife node show ubuntu1-1204.vm -a bootstrap
bootstrap:
client: mray.pem
time: 1348323159
user: mray

Thanks,
Matt Ray
Senior Technical Evangelist | Opscode Inc.
matt@opscode.com | (512) 731-2218
Twitter, IRC, GitHub: mattray


From: Sachin Sagar Rai [millisami@gmail.com]
Sent: Saturday, September 22, 2012 6:38 AM
To: chef@lists.opscode.com
Subject: [chef] Re: RE: Re: How to know the developer name who ran the knife cmd?

@matt, liked the idea.

But wondering where to put it coz now the chef-client is installed via omnibus, not the bootstrap template from .chef/bootstrap/file1?

Do I’ve to first dwnld the shell script file that ships with omnibus and modify it and use it instead of automatically fetched one?


@millisami
~ Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Sent with Sparrowhttp://www.sparrowmailapp.com/?sig

On Saturday, September 22, 2012 at 10:20 AM, Matt Ray wrote:

Great idea, here’s something I whipped together to get that to work. I modified my bootstrap template to change the first-boot.json stanza to this:

(
cat <<‘EOP’
<%= { “run_list” => @run_list, “bootstrap” => { “client” => Chef::Config[:client_key].split(’/’).last, “time” => Time.now.to_i } }.to_json %>
EOP
) > /etc/chef/first-boot.json

this renders to this:

{“run_list”:[],“bootstrap”:{“client”:“mray.pem”,“time”:1348288293}}

and looks like this:

knife node show ubuntu1-1204.vm -a bootstrap
bootstrap:
client: mray.pem
time: 1348288293

Thanks,
Matt Ray
Senior Technical Evangelist | Opscode Inc.
matt@opscode.commailto:matt@opscode.com | (512) 731-2218
Twitter, IRC, GitHub: mattray


From: Andrea Campi [andrea.campi@zephirworks.commailto:andrea.campi@zephirworks.com]
Sent: Friday, September 21, 2012 4:01 PM
To: chef@lists.opscode.commailto:chef@lists.opscode.com
Cc: chef@lists.opscode.commailto:chef@lists.opscode.com
Subject: [chef] Re: How to know the developer name who ran the knife cmd?

It sounds like all you need is a knife plugin that reads ENV[‘USER’] and sets a node attribute.

On Sep 21, 2012, at 10:49 PM, Sachin Sagar Rai <millisami@gmail.commailto:millisami@gmail.com> wrote:

Ohai!

Is there any api call to know the developer’s name who fired the knife cmd to launch a new instance?


@millisami
~ Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Sent with Sparrowhttp://www.sparrowmailapp.com/?sig