-
-
Save felipepodesta/7453667 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Knife invocations supply FQDN as the node name at creation time and this becomes hostname( option -N) | |
#Ensure the hostname of the system is set to knife provided node name | |
file "/etc/hostname" do | |
content node.name | |
notifies :run, resources(:execute => "Configure Hostname"), :immediately | |
end | |
#This sets up script which will run whenever eth0 comes up(after reboot) to update /etc/hosts | |
cookbook_file "/etc/network/if-up.d/update_hosts" do | |
source "update_hosts.sh" | |
owner "root" | |
group "root" | |
mode 0555 | |
backup false | |
end | |
#Execute this script now (firsttime) to set /etc/hosts to have the newly provisioned nodes address/hostname line | |
bash "update_hosts" do | |
user "root" | |
group "root" | |
cwd "/tmp" | |
code <<-EOH | |
export IFACE=eth0 | |
/etc/network/if-up.d/update_hosts | |
EOH | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment