Created
November 12, 2010 03:40
-
-
Save someara/673693 to your computer and use it in GitHub Desktop.
chef hostname
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
bash -c ' | |
echo <%= @config[:chef_node_name] %> > /tmp/chef_node_name | |
cat /tmp/chef_node_name | cut -d. -f1 > /tmp/proper_hostname | |
cat /tmp/chef_node_name | cut -d. -f2 | tr -d "\n" > /tmp/proper_dnsdomainname | |
echo -n "." >> /tmp/proper_dnsdomainname | |
cat /tmp/chef_node_name | cut -d. -f3 >> /tmp/proper_dnsdomainname | |
IPV4ADDR=`ip addr | grep eth0 | grep "inet " | cut -d " " -f 6 | cut -d \/ -f 1` | |
PROPERHOSTNAME=`cat /tmp/proper_hostname` | |
PROPERDNSDOMAINNAME=`cat /tmp/proper_dnsdomainname` | |
NETCONF="/etc/hostname" | |
echo "${PROPERHOSTNAME}" > ${NETCONF} | |
( | |
cat <<EOF | |
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 | |
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 | |
${IPV4ADDR} ${PROPERHOSTNAME}.${PROPERDNSDOMAINNAME} ${PROPERHOSTNAME} | |
EOF | |
) > /tmp/hosts | |
sudo mv /tmp/hosts /etc/hosts | |
sudo hostname $PROPERHOSTNAME | |
( | |
echo "export PS1=\"\\\\H:\\\\w\\\\\\$ \"" >> /etc/profile | |
) | |
sudo apt-get -y install wget | |
( | |
echo "deb http://apt.opscode.com/ lucid main" | sudo tee /etc/apt/sources.list.d/opscode.list | |
wget -qO - http://apt.opscode.com/[email protected] | sudo apt-key add - | |
sudo apt-get update | |
) | |
echo "chef chef/chef_server_url string <%= Chef::Config[:chef_server_url] %>" | debconf-set-selections | |
sudo apt-get install -y chef | |
( | |
cat <<'EOP' | |
<%= IO.read(Chef::Config[:validation_key]) %> | |
EOP | |
) > /tmp/validation.pem | |
awk NF /tmp/validation.pem > /etc/chef/validation.pem | |
rm /tmp/validation.pem | |
( | |
cat <<'EOP' | |
log_level :info | |
log_location STDOUT | |
chef_server_url "<%= Chef::Config[:chef_server_url] %>" | |
validation_client_name "<%= Chef::Config[:validation_client_name] %>" | |
<% if @config[:chef_node_name] == nil %> | |
# Using default node name" | |
<% else %> | |
node_name "<%= @config[:chef_node_name] %>" | |
<% end %> | |
EOP | |
) > /etc/chef/client.rb | |
( | |
cat <<'EOP' | |
<%= { "run_list" => @run_list }.to_json %> | |
EOP | |
) > /etc/chef/first-boot.json | |
/usr/bin/chef-client -j /etc/chef/first-boot.json | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist was a hack from long ago.
Something like this is better -
https://github.com/someara/fqdn-cookbook
-s