Commit 83f756c483d619d0c2262cf42c689956e1dbe396
1 parent
8897cebd
Exists in
master
and in
89 other branches
Reload node[:fqdn] when /etc/hosts changes
Signed-off-by: Sergio Oliveira <sergio@tracy.com.br> Signed-off-by: Antonio Terceiro <terceiro@softwarelivre.org>
Showing
1 changed file
with
10 additions
and
0 deletions
Show diff stats
cookbooks/basics/recipes/default.rb
| ... | ... | @@ -56,7 +56,17 @@ if node['platform'] == 'centos' |
| 56 | 56 | end |
| 57 | 57 | end |
| 58 | 58 | |
| 59 | +# reload node[:fqdn] to make sure it reflects the contents of /etc/hosts | |
| 60 | +# without that the variable :fqdn would not be available on first run | |
| 61 | +ruby_block 'fqdn:update' do | |
| 62 | + block do | |
| 63 | + node.default[:fqdn] = `hostname --fqdn`.strip | |
| 64 | + end | |
| 65 | + action :nothing | |
| 66 | +end | |
| 67 | + | |
| 59 | 68 | template '/etc/hosts' do |
| 60 | 69 | owner 'root' |
| 61 | 70 | mode 0644 |
| 71 | + notifies :run, 'ruby_block[fqdn:update]', :immediately | |
| 62 | 72 | end | ... | ... |