Chef

Kumolus SOE Configurations users the user-data field to execute a script on first boot as the root user.

The “user-data script” runs late in the start up process, so services like networking and other system services are functional.

These scripts allow us to automate the process of bootstrapping a common set of scripts across multiple servers or environments.

The script below allows us to call a script from S3 (or github) and execute. This allows us to provide complex scripts above the 2000 character limit if required.

#!/bin/bash
wget https://abc.amazonaws.com/scripts/chef/myapp.sh -P /home/user
chmod 770 /home/user/myapp.sh
bash /home/user/myapp.sh
######End of script#######

Chef Solo

A sample Chef Solo "myapp.sh" script that would install git, and clone repos would like the following:

#!/bin/bash
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install git
sudo adduser --disabled-password --gecos "" appuser
sudo echo "appuser ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

#####Clone the repos
env="$select_env"
path="/home/appuser/";
git_path="https://github.com/appuser/";
git_array=("web" "api" "chef" "node-api" "appuser" "guides" "dashboard");
git_path_array=( "${git_array[@]}" )
total=${#git_array[*]}
for (( i=0; i<=$(( $total -1 )); i++ ))
do
echo "\n$path${git_array[$i]}\n";

echo $git_path${git_path_array[$i]}".git";
cd /home/appuser/ && git clone $git_path${git_path_array[$i]}".git";
done
echo -e '\n Complete';

########
sudo chown -R appuser:appuser /home/appuser/
######Install and configure Chef

curl https://www.opscode.com/chef/install.sh
sudo chef-solo -c /home/appuser/chef/solo.rb -j /home/appuser/chef/dna.json >> /home/ubuntu/cheflog
#######End of script#######

Chef Server

A sample Chef Server "myapp.sh" script that would install git, and clone repos and would like the following:

#!/bin/bash
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install git
sudo adduser --disabled-password --gecos "" appuser
sudo echo "appuser ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

##Server Installation script
#!/bin/bash
sudo apt-get update
sudo apt-get upgrade
cd ~ && wget https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chef-server_11.0.10-1.ubuntu.12.04_amd64.deb
sudo dpkg -i chef-server*
sudo chef-server-ctl reconfigure
##Chef server installation done
##End of script

knife configure --initial
echo 'export PATH="/opt/chef/embedded/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
knife bootstrap $node_domain_or_IP -x $username -P $password -N $name_for_node --sudo

results matching ""

    No results matching ""