Skip to content

Instantly share code, notes, and snippets.

@hmalphettes
Created March 14, 2012 04:27

Revisions

  1. hmalphettes revised this gist Oct 4, 2012. 1 changed file with 9 additions and 6 deletions.
    15 changes: 9 additions & 6 deletions ubuntu-12.04-gems.erb
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,10 @@
    bash -c '
    echo "boostrap chef on a ubuntu VM. Install ruby via rvm sandbox it for the root user: does not install rvm system wide."
    echo "Example VM already booted: knife bootstrap 192.168.122.165 -x ubuntu -P ubuntu -d ubuntu-12.04-gems --node-name my_node --run-list role[intalio_micro_all] --environment intalio-CF --sudo"
    echo "Example EC2 with knife-ec2: knife bootstrap ec2-122-248-197-139.ap-southeast-1.compute.amazonaws.com -i ~/.ec2/hmalphettes-ap.pem -x ubuntu -d ubuntu-12.04-gems --no-host-key-verify --sudo"
    echo "Example EC2 with knife-ec2: knife bootstrap ec2-122-248-197-139.ap-southeast-1.compute.amazonaws.com -i ~/.ec2/hmalphettes-ap.pem -x ubuntu -d ubuntu-12.04-gems i --run-list \"role[intalio_micro_all]\" --environment intalio-CF --no-host-key-verify --sudo"
    echo "Example EC2 with knife-ec2: knife ec2 server create -I $UBUNTU_AMI -f m1.large -x ubuntu -d ubuntu-12.04-gems -i $EC2_KEYPAIR_PEM \"--run-list role[intalio_micro_all]\" -G http-https-ssh-smtp-vmreg -N ec2-ubuntu-new --region $EC2_REGION --availability-zone ap-southeast-1b --ebs-size $SIZE --no-host-key-verify --environment intalio-CF"
    echo "Example HP Cloud with knife-hp: knife hp server create --flavor 103 --image 5579 --ssh-key intaliohp --groups ssh-http-https-vm-reg -x ubuntu -i ~/.ssh/intaliohp.pem -d ubuntu-12.04-gems --run-list role[intalio_micro_all]\" --environment intalio-CF"

    echo "Example vsphere with knife-vsphere: knife vsphere vm clone NewNode --template Template-Ubuntu-Unclouded --start on --datastore 4c41b761-464a84fe-7f4c-0025b31edf26 --ccpu 2 --cram 6 -x ubuntu -P ubuntu -d ubuntu-12.04-gems --node-name hugues_esx_node --run-list role[intalio_micro_all] --environment intalio-CF --no-host-key-verify"
    echo " https://gist.github.com/1301693"
    echo "Use the 5 quotes to escape the single quotes within the command"
    @@ -39,25 +42,25 @@ if [ ! -f /usr/bin/chef-client ]; then
    echo "Failed to run apt-get update. are you root?"
    exit 1
    fi
    apt-get install -y build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
    apt-get install -y build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
    echo "Using a root only install as documented on http://beginrescueend.com/support/faq/"
    echo "export rvm_prefix=/root" > /root/.rvmrc
    echo "export rvm_path=/root/.rvm" >> /root/.rvmrc
    source /root/.rvmrc
    bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
    sed -i '"'"'s/^.*BASH_VERSION.*ZSH_VERSION.*$/if [ "root" = "${USER}" -a -n "\${BASH_VERSION:-}" -o -n "\${ZSH_VERSION:-}" ] ; then/'"'"' /etc/profile.d/rvm.sh
    sed -i '"'"'s/^.*BASH_VERSION.*ZSH_VERSION.*$/[ "root" = "${USER}" -a -n "\${BASH_VERSION:-}" -o -n "\${ZSH_VERSION:-}" ] \&\&/'"'"' /etc/profile.d/rvm.sh
    source /etc/profile
    which rvm
    if [ "$?" != "0" ]; then
    echo "Failed to install rvm"
    exit 5
    fi
    rvm install 1.9.3-p125 <%= "--proxy #{knife_config[:bootstrap_proxy]}" if knife_config[:bootstrap_proxy] %>
    rvm reinstall 1.9.3 <%= "--proxy #{knife_config[:bootstrap_proxy]}" if knife_config[:bootstrap_proxy] %>
    if [ "$?" != "0" ]; then
    echo "Failed to install ruby-1.9.3-p125"
    echo "Failed to install ruby-1.9.3"
    exit 6
    fi
    rvm use 1.9.3-p125 --default
    rvm use 1.9.3 --default
    fi

    source /etc/profile
  2. hmalphettes revised this gist Apr 17, 2012. 1 changed file with 12 additions and 12 deletions.
    24 changes: 12 additions & 12 deletions ubuntu-12.04-gems.erb
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ if [ -n "$UBUNTU_MIRROR" -a "us" != "$UBUNTU_MIRROR" ]; then
    echo "Failed to touch /etc/apt/sources.list. are you root?"
    exit 1
    fi
    sed -i -e "s/http:\/\/archive\.ubuntu\.com/http:\/\/$UBUNTU_MIRROR.archive.ubuntu.com/g" /etc/apt/sources.list
    sed -i -e "s/http:\/\/archive\.ubuntu\.com/http:\/\/$UBUNTU_MIRROR.archive.ubuntu.com/g" /etc/apt/sources.list
    fi
    <% if knife_config[:bootstrap_proxy] -%>
    (
    @@ -24,22 +24,22 @@ EOP

    if [ ! -f /usr/bin/chef-client ]; then
    curr_lang=`locale | grep LANG= | cut -d'=' -f2`
    if [ -z "$curr_lang" ]; then
    locale-gen
    locale-gen en_US.UTF-8
    update-locale LANG=en_US.UTF-8
    curr_lang=`locale | grep LANG= | cut -d"=" -f2`
    if [ -z "$curr_lang" ] ;then
    echo "Unable to specify a locale with a specific LANG"
    exit 2
    fi
    if [ -z "$curr_lang" ]; then
    locale-gen
    locale-gen en_US.UTF-8
    update-locale LANG=en_US.UTF-8
    curr_lang=`locale | grep LANG= | cut -d"=" -f2`
    if [ -z "$curr_lang" ] ;then
    echo "Unable to specify a locale with a specific LANG"
    exit 2
    fi
    fi
    apt-get update
    apt-get update
    if [ "$?" != "0" ]; then
    echo "Failed to run apt-get update. are you root?"
    exit 1
    fi
    apt-get install -y build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
    apt-get install -y build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
    echo "Using a root only install as documented on http://beginrescueend.com/support/faq/"
    echo "export rvm_prefix=/root" > /root/.rvmrc
    echo "export rvm_path=/root/.rvm" >> /root/.rvmrc
  3. hmalphettes revised this gist Apr 17, 2012. 1 changed file with 20 additions and 7 deletions.
    27 changes: 20 additions & 7 deletions ubuntu-12.04-gems.erb
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,18 @@
    bash -c '
    echo "boostrap chef on a ubuntu VM. Install ruby via rvm sandbox it for the root user: does not install rvm system wide."
    echo "Example local VM: knife bootstrap 192.168.122.165 -x ubuntu -P ubuntu -d ubuntu-12.04-gems --sudo"
    echo "Example local EC2: knife bootstrap ec2-122-248-197-139.ap-southeast-1.compute.amazonaws.com -i ~/.ec2/hmalphettes-ap.pem -x ubuntu -d ubuntu-12.04-gems --sudo"
    echo "Example VM already booted: knife bootstrap 192.168.122.165 -x ubuntu -P ubuntu -d ubuntu-12.04-gems --node-name my_node --run-list role[intalio_micro_all] --environment intalio-CF --sudo"
    echo "Example EC2 with knife-ec2: knife bootstrap ec2-122-248-197-139.ap-southeast-1.compute.amazonaws.com -i ~/.ec2/hmalphettes-ap.pem -x ubuntu -d ubuntu-12.04-gems --no-host-key-verify --sudo"
    echo "Example vsphere with knife-vsphere: knife vsphere vm clone NewNode --template Template-Ubuntu-Unclouded --start on --datastore 4c41b761-464a84fe-7f4c-0025b31edf26 --ccpu 2 --cram 6 -x ubuntu -P ubuntu -d ubuntu-12.04-gems --node-name hugues_esx_node --run-list role[intalio_micro_all] --environment intalio-CF --no-host-key-verify"
    echo " https://gist.github.com/1301693"
    echo "Use the 5 quotes to escape the single quotes within the command"
    UBUNTU_MIRROR=sg
    if [ 'us' != "$UBUNTU_MIRROR" ]; then
    if [ -n "$UBUNTU_MIRROR" -a "us" != "$UBUNTU_MIRROR" ]; then
    touch /etc/apt/sources.list
    if [ "$?" != "0" ]; then
    echo "Failed to touch /etc/apt/sources.list. are you root?"
    exit 1
    fi
    sed -i -e "s/http:\/\/us\./http:\/\/$UBUNTU_MIRROR./g" /etc/apt/sources.list
    sed -i -e "s/http:\/\/archive\.ubuntu\.com/http:\/\/$UBUNTU_MIRROR.archive.ubuntu.com/g" /etc/apt/sources.list
    fi
    <% if knife_config[:bootstrap_proxy] -%>
    (
    @@ -21,12 +23,23 @@ EOP
    <% end -%>

    if [ ! -f /usr/bin/chef-client ]; then
    apt-get update
    curr_lang=`locale | grep LANG= | cut -d'=' -f2`
    if [ -z "$curr_lang" ]; then
    locale-gen
    locale-gen en_US.UTF-8
    update-locale LANG=en_US.UTF-8
    curr_lang=`locale | grep LANG= | cut -d"=" -f2`
    if [ -z "$curr_lang" ] ;then
    echo "Unable to specify a locale with a specific LANG"
    exit 2
    fi
    fi
    apt-get update
    if [ "$?" != "0" ]; then
    echo "Failed to run apt-get update. are you root?"
    exit 1
    fi
    apt-get install -y build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
    apt-get install -y build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
    echo "Using a root only install as documented on http://beginrescueend.com/support/faq/"
    echo "export rvm_prefix=/root" > /root/.rvmrc
    echo "export rvm_path=/root/.rvm" >> /root/.rvmrc
    @@ -159,4 +172,4 @@ cat <<'EOP'
    EOP
    ) > /etc/chef/first-boot.json

    <%= start_chef %>'
    <%= start_chef %>'
  4. hmalphettes revised this gist Mar 21, 2012. 1 changed file with 13 additions and 3 deletions.
    16 changes: 13 additions & 3 deletions ubuntu-12.04-gems.erb
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    bash -c '
    echo "boostrap chef on a ubuntu VM. Install ruby via rvm; sandbox it for the root user: does not install rvm system wide."
    echo "boostrap chef on a ubuntu VM. Install ruby via rvm sandbox it for the root user: does not install rvm system wide."
    echo "Example local VM: knife bootstrap 192.168.122.165 -x ubuntu -P ubuntu -d ubuntu-12.04-gems --sudo"
    echo "Example local EC2: knife bootstrap ec2-122-248-197-139.ap-southeast-1.compute.amazonaws.com -i ~/.ec2/hmalphettes-ap.pem -x ubuntu -d ubuntu-12.04-gems --sudo"
    echo " https://gist.github.com/1301693"
    @@ -32,9 +32,19 @@ if [ ! -f /usr/bin/chef-client ]; then
    echo "export rvm_path=/root/.rvm" >> /root/.rvmrc
    source /root/.rvmrc
    bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
    sed -i '"'"'s/^.*BASH_VERSION.*ZSH_VERSION.*$/if [ "root" = "${USER}" -a -n "\${BASH_VERSION:-}" -o -n "\${ZSH_VERSION:-}" ] ; then/'"'"' /etc/profile.d/rvm.sh
    source /etc/profile
    rvm install 1.9.2 <%= "--proxy #{knife_config[:bootstrap_proxy]}" if knife_config[:bootstrap_proxy] %>
    rvm use 1.9.2 --default
    which rvm
    if [ "$?" != "0" ]; then
    echo "Failed to install rvm"
    exit 5
    fi
    rvm install 1.9.3-p125 <%= "--proxy #{knife_config[:bootstrap_proxy]}" if knife_config[:bootstrap_proxy] %>
    if [ "$?" != "0" ]; then
    echo "Failed to install ruby-1.9.3-p125"
    exit 6
    fi
    rvm use 1.9.3-p125 --default
    fi

    source /etc/profile
  5. hmalphettes revised this gist Mar 14, 2012. 2 changed files with 152 additions and 61 deletions.
    61 changes: 0 additions & 61 deletions ubuntu-11.10-gems.erb
    Original file line number Diff line number Diff line change
    @@ -1,61 +0,0 @@
    bash -c '
    <% if knife_config[:bootstrap_proxy] -%>
    (
    cat <<'EOP'
    <%= "proxy = #{knife_config[:bootstrap_proxy]}" %>
    EOP
    ) > ~/.curlrc
    <% end -%>

    if [ ! -f /usr/bin/chef-client ]; then
    apt-get update
    apt-get install -y build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
    bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
    source /etc/profile
    rvm install 1.9.2 <%= "--proxy #{knife_config[:bootstrap_proxy]}" if knife_config[:bootstrap_proxy] %>
    rvm use 1.9.2 --default
    fi

    source /etc/profile
    gem update --system --no-rdoc --no-ri
    gem update --no-rdoc --no-ri
    gem install ohai --no-rdoc --no-ri --verbose
    gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string %>
    if [ -f /usr/bin/chef-client ]; then
    rm -f /usr/bin/chef-client
    fi
    ln -nfs $(which chef-client) /usr/bin/chef-client

    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 %>
    EOP
    ) > /etc/chef/client.rb

    (
    cat <<'EOP'
    <%= { "run_list" => @run_list }.to_json %>
    EOP
    ) > /etc/chef/first-boot.json

    <%= start_chef %>'
    152 changes: 152 additions & 0 deletions ubuntu-12.04-gems.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,152 @@
    bash -c '
    echo "boostrap chef on a ubuntu VM. Install ruby via rvm; sandbox it for the root user: does not install rvm system wide."
    echo "Example local VM: knife bootstrap 192.168.122.165 -x ubuntu -P ubuntu -d ubuntu-12.04-gems --sudo"
    echo "Example local EC2: knife bootstrap ec2-122-248-197-139.ap-southeast-1.compute.amazonaws.com -i ~/.ec2/hmalphettes-ap.pem -x ubuntu -d ubuntu-12.04-gems --sudo"
    echo " https://gist.github.com/1301693"
    UBUNTU_MIRROR=sg
    if [ 'us' != "$UBUNTU_MIRROR" ]; then
    touch /etc/apt/sources.list
    if [ "$?" != "0" ]; then
    echo "Failed to touch /etc/apt/sources.list. are you root?"
    exit 1
    fi
    sed -i -e "s/http:\/\/us\./http:\/\/$UBUNTU_MIRROR./g" /etc/apt/sources.list
    fi
    <% if knife_config[:bootstrap_proxy] -%>
    (
    cat <<'EOP'
    <%= "proxy = #{knife_config[:bootstrap_proxy]}" %>
    EOP
    ) > ~/.curlrc
    <% end -%>

    if [ ! -f /usr/bin/chef-client ]; then
    apt-get update
    if [ "$?" != "0" ]; then
    echo "Failed to run apt-get update. are you root?"
    exit 1
    fi
    apt-get install -y build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
    echo "Using a root only install as documented on http://beginrescueend.com/support/faq/"
    echo "export rvm_prefix=/root" > /root/.rvmrc
    echo "export rvm_path=/root/.rvm" >> /root/.rvmrc
    source /root/.rvmrc
    bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
    source /etc/profile
    rvm install 1.9.2 <%= "--proxy #{knife_config[:bootstrap_proxy]}" if knife_config[:bootstrap_proxy] %>
    rvm use 1.9.2 --default
    fi

    source /etc/profile
    set +e
    gem update --system --no-rdoc --no-ri
    if [ $? != 0 ]; then
    echo "Retry 1"
    gem update --system --no-rdoc --no-ri
    fi
    if [ $? != 0 ]; then
    echo "Retry 2"
    gem update --system --no-rdoc --no-ri
    fi
    if [ $? != 0 ]; then
    echo "Retry 3"
    gem update --system --no-rdoc --no-ri
    fi

    gem update --no-rdoc --no-ri
    if [ $? != 0 ]; then
    echo "Retry 1"
    gem update --no-rdoc --no-ri
    fi
    if [ $? != 0 ]; then
    echo "Retry 2"
    gem update --no-rdoc --no-ri
    fi
    if [ $? != 0 ]; then
    echo "Retry 3"
    gem update --no-rdoc --no-ri
    fi
    if [ $? != 0 ]; then
    echo "failed to gem update"
    exit 1
    fi

    gem install ohai --no-rdoc --no-ri --verbose
    if [ $? != 0 ]; then
    echo "Retry 1"
    gem install ohai --no-rdoc --no-ri --verbose
    fi
    if [ $? != 0 ]; then
    echo "Retry 2"
    gem install ohai --no-rdoc --no-ri --verbose
    fi
    if [ $? != 0 ]; then
    echo "Retry 3"
    gem install ohai --no-rdoc --no-ri --verbose
    fi
    if [ $? != 0 ]; then
    echo "failed to install ohai"
    exit 1
    fi

    gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string %>
    if [ $? != 0 ]; then
    echo "Retry 1"
    gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string %>
    fi
    if [ $? != 0 ]; then
    echo "Retry 2"
    gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string %>
    fi
    if [ $? != 0 ]; then
    echo "Retry 3"
    gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string %>
    fi
    if [ $? != 0 ]; then
    echo "failed to install chef"
    exit 1
    fi

    if [ -f /usr/bin/chef-client ]; then
    rm -f /usr/bin/chef-client
    fi
    which_chef_client=$(which chef-client)
    if [ -z "$which_chef_client" ]; then
    echo "chef-client cant be found on the path: installation failed"
    exit 1
    fi
    ln -nfs $(which chef-client) /usr/bin/chef-client

    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 %>
    EOP
    ) > /etc/chef/client.rb

    (
    cat <<'EOP'
    <%= { "run_list" => @run_list }.to_json %>
    EOP
    ) > /etc/chef/first-boot.json

    <%= start_chef %>'
  6. Kashif Rasul renamed this gist Oct 15, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ubuntu-11.04-gems.erb → ubuntu-11.10-gems.erb
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ EOP

    if [ ! -f /usr/bin/chef-client ]; then
    apt-get update
    apt-get install -y build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison
    apt-get install -y build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
    bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
    source /etc/profile
    rvm install 1.9.2 <%= "--proxy #{knife_config[:bootstrap_proxy]}" if knife_config[:bootstrap_proxy] %>
  7. Kashif Rasul revised this gist Oct 10, 2011. 2 changed files with 61 additions and 43 deletions.
    43 changes: 0 additions & 43 deletions chef_bootstrap_rvm.erb
    Original file line number Diff line number Diff line change
    @@ -1,43 +0,0 @@
    bash -c '

    if [ ! -f /usr/bin/chef-client ]; then
    apt-get update
    apt-get install -y build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev autoconf libc6-dev
    bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
    (
    cat <<'EOP'
    [[ -s "/usr/local/rvm/scripts/rvm" ]] && source "/usr/local/rvm/scripts/rvm" # This loads RVM into a shell session.
    EOP
    ) > /etc/profile.d/rvm.sh
    source /etc/profile
    rvm install 1.9.2-p180
    rvm use 1.9.2-p180 --default
    fi

    gem install ohai --no-rdoc --no-ri --verbose
    gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string %>
    ln -nfs $(which chef-client) /usr/bin/chef-client

    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

    (
    cat <<'EOP'
    <%= config_content %>
    EOP
    ) > /etc/chef/client.rb

    (
    cat <<'EOP'
    <%= { "run_list" => @run_list }.to_json %>
    EOP
    ) > /etc/chef/first-boot.json

    <%= start_chef %>'
    61 changes: 61 additions & 0 deletions ubuntu-11.04-gems.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,61 @@
    bash -c '
    <% if knife_config[:bootstrap_proxy] -%>
    (
    cat <<'EOP'
    <%= "proxy = #{knife_config[:bootstrap_proxy]}" %>
    EOP
    ) > ~/.curlrc
    <% end -%>

    if [ ! -f /usr/bin/chef-client ]; then
    apt-get update
    apt-get install -y build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison
    bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
    source /etc/profile
    rvm install 1.9.2 <%= "--proxy #{knife_config[:bootstrap_proxy]}" if knife_config[:bootstrap_proxy] %>
    rvm use 1.9.2 --default
    fi

    source /etc/profile
    gem update --system --no-rdoc --no-ri
    gem update --no-rdoc --no-ri
    gem install ohai --no-rdoc --no-ri --verbose
    gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string %>
    if [ -f /usr/bin/chef-client ]; then
    rm -f /usr/bin/chef-client
    fi
    ln -nfs $(which chef-client) /usr/bin/chef-client

    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 %>
    EOP
    ) > /etc/chef/client.rb

    (
    cat <<'EOP'
    <%= { "run_list" => @run_list }.to_json %>
    EOP
    ) > /etc/chef/first-boot.json

    <%= start_chef %>'
  8. @bensie bensie created this gist Jun 11, 2011.
    43 changes: 43 additions & 0 deletions chef_bootstrap_rvm.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    bash -c '

    if [ ! -f /usr/bin/chef-client ]; then
    apt-get update
    apt-get install -y build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev autoconf libc6-dev
    bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
    (
    cat <<'EOP'
    [[ -s "/usr/local/rvm/scripts/rvm" ]] && source "/usr/local/rvm/scripts/rvm" # This loads RVM into a shell session.
    EOP
    ) > /etc/profile.d/rvm.sh
    source /etc/profile
    rvm install 1.9.2-p180
    rvm use 1.9.2-p180 --default
    fi

    gem install ohai --no-rdoc --no-ri --verbose
    gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string %>
    ln -nfs $(which chef-client) /usr/bin/chef-client

    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

    (
    cat <<'EOP'
    <%= config_content %>
    EOP
    ) > /etc/chef/client.rb

    (
    cat <<'EOP'
    <%= { "run_list" => @run_list }.to_json %>
    EOP
    ) > /etc/chef/first-boot.json

    <%= start_chef %>'