Bootstrapping all nodes at a time

How can i bootstrap all my 100 servers i.e 25 rhel, 25 Ubuntu, 25 CentOS ,25 windows at time to deploys different webpackges and to run chef- client on them

Check out our blog post on this topic: https://blog.chef.io/2017/07/24/bootstrapping-nodes-in-bulk/

Hi Sudheer,

This is what i am using to bootstarp , i have created two seperate input CSV files for Windows and Linux( any flavor)

example : BootStrapwindowsFile.csv
examample: BootStrapLinuxFile.csv

The format inside the Linux CSV file should be "IPaddress, key.pem and hostanme"
for windows Ipaddress Password and Hostname

After segregating both the files try to run the script below
#########################################################################

export PATH=$PATH:/usr/local/bin/:/usr/bin

Safety feature: exit script if error is returned, or if variables not set.

Exit if a pipeline results in an error.

set -ue
set -o pipefail

Variable Declartions

bootstrapNodeFileName="/opt/chef-ws/bootstrapNodeFileLinux.csv"

Set Logging Options

logfileName="/opt/chef-ws/bootstrapNodeLinuxLog_$(date +%Y%m%d).log"
logfileMaxLines=“500000”

Function Declarations

Function: Setup logfile and redirect stdout/stderr.

logSetup() {
# Check if logfile exists
( [ -e “$logfileName” ] || touch “$logfileName” ) && [ ! -w “$logfileName” ] && echo “ERROR: Cannot write to $logfileName. Check permissions or sudo access.” && exit 1

tmplog=$(tail -n $logfileMaxLines $logfileName 2>/dev/null) && echo "${tmplog}" > $logfileName
exec > >(tee -a $logfileName)
exec 2>&1

}

Function: Log an event.

log() {
echo “[(date +"%Y-%m-%d"+"%T")]: *”
}

Function: Bootstrap all Windows servers provided in the file

bootstrapLinux() {
while read ipAddress keyFile nodeName;do
log "IP Address is: $ipAddress"
log "Keyfile is: $keyFile"
log “NodeName is: $nodeName”

# Bootstrap the node
printf 'Y\nY' | sudo knife bootstrap $ipAddress -i /opt/chef-ws/.chef/$keyFile -x ec2-user --run-list 'recipe[os-version]' --sudo -N $nodeName

log "Bootstrap has been completed for Node: $nodeName"

done < $bootstrapNodeFileName
}

SCRIPT COMMANDS

logSetup
bootstrapLinux
##############################################################

Ususally the above script reads the inputs given in the CSV file and bootstarps the node with recipe or coobook the given in the run _list

Thanks
Prash