popularity question answers views user  
4
Cannot get updated ipaddress for EC2 instance started after stopped

I’m developing a recipe targeting to get the update IP address for an EC2 instance as it’s just started. To achieve this, I make chef-client a system service which located under /etc/init.d/chef-client (this is default when ec2 instance is bootstrapped) and assign the run_list to the node. However, as a result I found that node[‘ipaddress’] still gets its old address rather than the new one. The reason might because chef node retrieved the value from chef server directly which still have old value. And if I run chef-client on the node again, node[‘ipaddress’] can get the updated ip value.

My question is 1. How to get updated ipaddress for the first time when the chef-client gets started as a system service. 2. If node[‘ipaddress’] get value from chef-server then how to get ip address from ohai run? I ask this because I observe that ohai always output correct value. 3. Is there any way to delay chef-client execution as a system service?

Greatly appreciate your comments!

more →
1 1.0k  
1
How to add attributes per node?

I wan’t to setup virtual interfaces, but only on a host, so i wan’t to put somewhere something like this:

set["virtual_interfaces"] = {"eth0:1" => "80.1.2.3"}

As reading the documentation, there is no info (or i can’t find that), to do that. The first attempt, was to write

cookbooks/virtual_interfaces/attributes/my.machine-with-virtual-interfaces.com.rb

with the config, but opposite than the feel of documentation made on me… it doesn’t work.

Then i tried “knief node edit”, but i don’t want to set up each node this way, and want to save the node conf in the git chef-repo.

The other way was to use data_bags, but the problem there is… why i wan’t attributes, if i have to load it all from data_bags.

So I can’t find the way to set specific attribute to a single node.

more →
1 902  
0
Cannot Find Node Attribute

I am trying to install Munin through hosted Chef on a Vagrant VM. When installing the Munin Client, it performs a search for the Munin Servers.

munin_servers = search(:node, "role:#{node['munin']['server_role']} AND chef_environment:#{node.chef_environment}")

However, this search is failing, with a 400 “Bad Request”. I did a quick check, and node[‘munin’][‘server_role’] is nil.

But how can that be? It defines what it is in the Cookbooks attribute file. It sets it to “Monitoring”. I wanted to change that, so in the my Role I have:

{
  "name": "munin-node",
  "description": "",
  "json_class": "Chef::Role",
  "default_attributes": {
    "munin": {
      "server_role": "munin-server"
    }
  },
  "override_attributes": {
  },
  "chef_type": "role",
  "run_list": [
    "recipe[munin::client]"
  ],
  "env_run_lists": {
  }
}

I define node[‘munin’][‘server_role’] in that file. In fact, I went as far as to print out the entire node object:

node.each do |k, v|
  puts "Key: #{k} and V: #{v}"
end

And it shows:

Key: munin and V: {"sysadmin_email"=>"ethan@cloudmine.me", "server_role"=>"munin-server", "server_auth_method"=>"htpasswd", "web_server"=>"apache", "web_server_port"=>8080, "basedir"=>"/etc/munin", "plugin_dir"=>"/usr/share/munin/plugins", "docroot"=>"/var/www/munin", "dbdir"=>"/var/lib/munin", "root"=>{"group"=>"root"}, "plugins"=>"/etc/munin/plugins", "tmpldir"=>"/etc/munin/templates", "max_graph_jobs"=>"6", "max_cgi_graph_jobs"=>"6", "max_processes"=>nil}

I see it! I see my server_role has been defined! It’s right here! So why is it nil when I access it? What is happening?

Chef Workstation Version: 10.24.0 Chef-Client Version: 10.24.0 Ruby Version: 1.9.3

more →
0 83