[chef] RE:


Chronological Thread 
  • From: Kevin Keane Subscription < >
  • To: < >
  • Subject: [chef] RE:
  • Date: Wed, 6 Aug 2014 00:21:21 -0700
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=sendgrid.info; h=subject:from:to:mime-version:content-type:in-reply-to:references:sender; q=dns; s=smtpapi; b=US1Q8R+NNTkIEg7YHde6/48IMdRgJwYXlFpXBPeu+ZkO 1zHTBYUGMdJTIkZqh05xD7Lu/OoBMX8qYgq1BDC+bR3z+Er4H+VJebSk8nWiAezw alGMRiLXaqxpSxdgcN4MGBHw2sTRQqqUnLq4WyqyaGslhksOpF4MMhekUwYAivM=

When you say “user” are you talking about somebody sitting at the client computer, or are you talking about the administrator who manages the cookbooks etc. on the chef server?

 

On the chef server, there are several ways to do what you want: you can override the attribute using roles, or put it in a data bag, or set the attributes using knife.

 

If you want a user on the client machine to do this – chef is probably not the right tool for you. The whole point of chef is that it runs unattended (and many people run it automatically every 30 minutes, so even if you *could* prompt a user, that would happen twice every hour).

 

You could probably rig something using a “flag” file – the user creates a particular file in a particular location, and then your chef recipe checks if that file exists, and adjusts the attributes as needed.

 

A better option is probably for the user to talk to an administrator, and update the attributes on the chef server.

 

From: Indra k [mailto:
Sent: Wednesday, August 6, 2014 12:02 AM
To:
Subject: [chef]

 

Hi,

 

  How to prompt in chef attributes  ?

  I need to ask from a user whether they need to keep the default value which i described in attribute file or they need to override with their new value and get and process in that value itself.

  I  used get.chomp in ruby_block
#!/usr/bin/ruby
require 'rubygems'
ruby_block "Transfer bits" do
  puts node['trans']['host']
  block do
   HOST = node['trans']['host']
   puts HOST
  
  
   puts "User need to override"
   ip1 = gets.chomp
   if ip1 == "y" || ip1 == "Y"
      puts "Enter ur ip"
      ip2 = gets.chomp
      puts ip2
    else
        puts HOST
end
end
end

Like this but it shows:
Errno::ENOENT
172.16.1.121
172.16.1.121 -------------
172.16.1.121
172.16.1.121 No such file or directory - -o
172.16.1.121
172.16.1.121
172.16.1.121
172.16.1.121
172.16.1.121 Cookbook Trace:
172.16.1.121
172.16.1.121 ---------------
172.16.1.121
172.16.1.121 /var/chef/cache/cookbooks/trans/recipes/default.rb:166:in `gets'
172.16.1.121
172.16.1.121 /var/chef/cache/cookbooks/trans/recipes/default.rb:166:in `gets'
172.16.1.121
172.16.1.121 /var/chef/cache/cookbooks/trans/recipes/default.rb:166:in `block (2 levels) in from_file'
172.16.1.121
172.16.1.121
172.16.1.121
172.16.1.121



Thanks,

Indra K

 



  • [chef], Indra k, 08/06/2014
    • [chef] RE:, Kevin Keane Subscription, 08/06/2014
    • [chef] Re:, Bryan McLellan, 08/07/2014
    • <Possible follow-up(s)>
    • [chef], Indra k, 08/06/2014

Archive powered by MHonArc 2.6.16.

§