From 83f756c483d619d0c2262cf42c689956e1dbe396 Mon Sep 17 00:00:00 2001 From: Sergio Oliveira Date: Mon, 25 May 2015 15:12:47 -0300 Subject: [PATCH] Reload node[:fqdn] when /etc/hosts changes --- cookbooks/basics/recipes/default.rb | 10 ++++++++++ 1 file changed, 10 insertions(+), 0 deletions(-) diff --git a/cookbooks/basics/recipes/default.rb b/cookbooks/basics/recipes/default.rb index 7c4c9d0..34c85a1 100644 --- a/cookbooks/basics/recipes/default.rb +++ b/cookbooks/basics/recipes/default.rb @@ -56,7 +56,17 @@ if node['platform'] == 'centos' end end +# reload node[:fqdn] to make sure it reflects the contents of /etc/hosts +# without that the variable :fqdn would not be available on first run +ruby_block 'fqdn:update' do + block do + node.default[:fqdn] = `hostname --fqdn`.strip + end + action :nothing +end + template '/etc/hosts' do owner 'root' mode 0644 + notifies :run, 'ruby_block[fqdn:update]', :immediately end -- libgit2 0.21.2