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!
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:
As reading the documentation, there is no info (or i can’t find that), to do that. The first attempt, was to write
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.
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.
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:
I define node[‘munin’][‘server_role’] in that file. In fact, I went as far as to print out the entire node object:
And it shows:
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