Created
May 1, 2012 13:33
-
-
Save someara/2567927 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
bash -c ' | |
( | |
echo "export PS1=\"\\\\H:\\\\w\\\\\\$ \"" >> /etc/profile | |
) | |
echo <%= @config[:chef_node_name] %> > /tmp/chef_node_name | |
PROPERHOSTNAME=`cat /tmp/chef_node_name | cut -d. -f1` | |
PROPERDNSDOMAINNAME=`cat /tmp/chef_node_name | sed s/^$PROPERHOSTNAME.//` | |
IPV4ADDR=`ip addr | grep eth0 | grep "inet " | cut -d " " -f 6 | cut -d \/ -f 1` | |
NETCONF="/etc/sysconfig/network" | |
grep "^HOSTNAME=${PROPERHOSTNAME}$" ${NETCONF} || ( sed -i s/^HOSTNAME.*$// ${NETCONF} && echo "HOSTNAME=${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 | |
) > /etc/hosts | |
hostname $PROPERHOSTNAME | |
yum clean all | |
yum -y install ntp | |
ntpdate -u pool.ntp.org | |
yum -y install libselinux-ruby | |
# end affs | |
<%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%> | |
exists() { | |
if command -v $1 &>/dev/null | |
then | |
return 0 | |
else | |
return 1 | |
fi | |
} | |
install_sh="http://opscode.com/chef/install.sh" | |
version_string="<%= "-v #{knife_config[:bootstrap_version]}" if knife_config[:bootstrap_version] %>" | |
if ! exists /usr/bin/chef-client; then | |
if exists wget; then | |
bash <(wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %> ${install_sh} -O -) ${version_string} | |
else | |
if exists curl; then | |
bash <(curl -L <%= "--proxy=on " if knife_config[:bootstrap_proxy] %> ${install_sh}) ${version_string} | |
fi | |
fi | |
fi | |
mkdir -p /etc/chef | |
( | |
cat <<'EOP' | |
<%= validation_key %> | |
EOP | |
) > /tmp/validation.pem | |
awk NF /tmp/validation.pem > /etc/chef/validation.pem | |
rm /tmp/validation.pem | |
<% if @chef_config[:encrypted_data_bag_secret] -%> | |
( | |
cat <<'EOP' | |
<%= encrypted_data_bag_secret %> | |
EOP | |
) > /tmp/encrypted_data_bag_secret | |
awk NF /tmp/encrypted_data_bag_secret > /etc/chef/encrypted_data_bag_secret | |
rm /tmp/encrypted_data_bag_secret | |
<% end -%> | |
( | |
cat <<'EOP' | |
<%= config_content %> | |
verbose_logging false | |
EOP | |
) > /etc/chef/client.rb | |
( | |
cat <<'EOP' | |
<%= { "run_list" => @run_list }.to_json %> | |
EOP | |
) > /etc/chef/first-boot.json | |
<%= start_chef %>' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment