Added code for xCAT chef intergration on Ubuntu
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@15855 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		
							
								
								
									
										57
									
								
								xCAT/postscripts/config_chef_client
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										57
									
								
								xCAT/postscripts/config_chef_client
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,57 @@ | ||||
| #!/bin/sh  | ||||
| # IBM(c) 2013 EPL license http://www.eclipse.org/legal/epl-v10.html | ||||
|  | ||||
|  | ||||
| #------------------------------------------------------------------------------- | ||||
| #=head1  config_chef_client | ||||
| #=head2  This command configures the chef client on a xCAT node. | ||||
| #        It is used by install_chef_client on Ubuntu and chef kit on RH.  | ||||
| #=cut | ||||
| #------------------------------------------------------------------------------- | ||||
|  | ||||
| echo "Configuring chef client....." | ||||
| #the chef server can be passed as an argument or as an environmental variable | ||||
| #the default is $SITEMASTER | ||||
| ARGNUM=$#; | ||||
| if [ $ARGNUM -gt 1 ]; then | ||||
|     if [ $1 = "-s" ]; then | ||||
|         chef_server=$2 | ||||
|     fi | ||||
| fi | ||||
|  | ||||
| if [ -z "$chef_server" ]; then | ||||
|     if [ -n "$CHEFSERVER" ]; then | ||||
|         chef_server=$CHEFSERVER | ||||
|     fi | ||||
|     if [ -z "$chef_server" ]; then | ||||
|         chef_server=$SITEMASTER | ||||
|     fi | ||||
| fi | ||||
|  | ||||
|  | ||||
| mkdir -p /etc/chef | ||||
|  | ||||
| # copy the validator.pem to chef client | ||||
| scp root@$chef_server:/etc/chef-server/chef-validator.pem /etc/chef/validation.pem | ||||
|  | ||||
|  | ||||
| # Add the info to /etc/chef/client.rb | ||||
| echo -e "log_level        :auto | ||||
| log_location     STDOUT | ||||
| chef_server_url  'https://$chef_server' | ||||
| validation_client_name 'chef-validator'" > /etc/chef/client.rb | ||||
|  | ||||
| node=`hostname` | ||||
|  | ||||
| # run the command on the client to register the client on the chef-server | ||||
| /opt/chef/bin/chef-client | ||||
|  | ||||
| if [ $? -ne 0 ] | ||||
| then | ||||
|     errmsg="Failed to run /opt/chef/bin/chef-client on $node" | ||||
|     logger -t xcat -p local4.err $errmsg | ||||
|     echo $errmsg | ||||
|     exit 1 | ||||
| fi | ||||
|  | ||||
| exit 0; | ||||
							
								
								
									
										27
									
								
								xCAT/postscripts/config_chef_server
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										27
									
								
								xCAT/postscripts/config_chef_server
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| #!/bin/sh -vx  | ||||
| # IBM(c) 2013 EPL license http://www.eclipse.org/legal/epl-v10.html | ||||
|  | ||||
|  | ||||
| #------------------------------------------------------------------------------- | ||||
| #=head1  configure_chef_server | ||||
| #=head2  This command configures the chef server on a xCAT node. | ||||
| #        It is used by install_chef_client on Ubuntu and chef kit on RH. | ||||
| #        It also can be used postscripts on diskless | ||||
| #    usage:   | ||||
| #      1. configure the chef server using updatenode | ||||
| #            updatenode <noderange> -P "config_chef_server" | ||||
| #      2. configure chef server during os provisioning | ||||
| #            chef <noderange> -p postscripts=config_chef_server | ||||
| #=cut | ||||
| #------------------------------------------------------------------------------- | ||||
|  | ||||
| sudo chef-server-ctl reconfigure | ||||
| if [ $? -ne 0 ] | ||||
| then | ||||
|     errmsg="Failed to run chef-server-ctl reconfigure on $node" | ||||
|     logger -t xcat -p local4.err $errmsg | ||||
|     echo $errmsg | ||||
|     exit 1 | ||||
| fi | ||||
|  | ||||
| exit 0; | ||||
							
								
								
									
										105
									
								
								xCAT/postscripts/config_chef_workstation
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										105
									
								
								xCAT/postscripts/config_chef_workstation
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,105 @@ | ||||
| #!/bin/sh  | ||||
| # IBM(c) 2013 EPL license http://www.eclipse.org/legal/epl-v10.html | ||||
|  | ||||
|  | ||||
| #------------------------------------------------------------------------------- | ||||
| #=head1  config_chef_workstation | ||||
| #=head2  This command configures the chef workstation on a xCAT node. | ||||
| #        It is used by install_chef_workstation on Ubuntu and chef kit on RH. | ||||
| #=cut | ||||
| #------------------------------------------------------------------------------- | ||||
|  | ||||
| node=`hostname` | ||||
|  | ||||
| # Who is the chef server? | ||||
| # -s takes precedence | ||||
| # then site.chefserver | ||||
| # then site.master | ||||
| ARGNUM=$#; | ||||
| if [ $ARGNUM -gt 1 ]; then | ||||
|     if [ $1 = "-s" ]; then | ||||
|         chefserver=$2 | ||||
|     fi | ||||
| fi | ||||
|  | ||||
| if [ -z "$chefserver" ] | ||||
| then | ||||
|     if [ -n "$CHEFSERVER" ] | ||||
|     then | ||||
|         chefserver=$CHEFSERVER | ||||
|     fi | ||||
|     if [ -z "$chefserver" ] | ||||
|     then | ||||
|         chefserver=$SITEMASTER | ||||
|     fi | ||||
| fi | ||||
|  | ||||
| if [ -z "$chefserver" ] | ||||
| then | ||||
|     # No chef server defined, using localhost is the only choice | ||||
|     uselocalhost=1 | ||||
| fi | ||||
|  | ||||
| localip=`getent hosts \`hostname\` | awk '{print $1}'` | ||||
| serverip=`getent hosts $chefserver | awk '{print $1}'` | ||||
|  | ||||
| if [ "$localip" = "$serverip" ] | ||||
| then | ||||
|     uselocalhost=1 | ||||
| fi | ||||
|  | ||||
| # check if the current node is also a chef master | ||||
| # if yes, use this node as the chef server | ||||
| if [ -f /etc/chef-server/admin.pem ]; then | ||||
|     uselocalhost=1 | ||||
| fi | ||||
|  | ||||
| homedir=$HOME | ||||
| # In prereboot, the HOME is /tmp | ||||
| # assume root | ||||
| if [ "$homedir" = "/tmp" ] || [ -z "$homedir" ] | ||||
| then | ||||
|     homedir=/root | ||||
| fi | ||||
| # Reconfigure the ~/.chef | ||||
| rm -rf $homedir/.chef.bak >/dev/null 2>&1 | ||||
| mv $homedir/.chef $homedir/.chef.bak >/dev/null 2>&1 | ||||
| mkdir $homedir/.chef | ||||
|  | ||||
| if [ $uselocalhost = 1  ] | ||||
| then | ||||
|     chefserver=$localip | ||||
|     client_key='/etc/chef-server/admin.pem' | ||||
|     validation_key='/etc/chef-server/chef-validator.pem' | ||||
| else | ||||
|     # Remote chef-server | ||||
|     scp $chefserver:/etc/chef-server/admin.pem $homedir/.chef 2>&1 1>/dev/null | ||||
|     scp $chefserver:/etc/chef-server/chef-validator.pem $homedir/.chef 2>&1 1>/dev/null | ||||
|     if [ ! -e "$homedir/.chef/admin.pem" ] || [ ! -e "$homedir/.chef/chef-validator.pem" ] | ||||
|     then | ||||
|         errmsg="Could not get the chef keys from chef server $chefserver" | ||||
|         logger -t xcat -p local4.err $errmsg | ||||
|         echo $errmsg | ||||
|         exit 1 | ||||
|     fi | ||||
| fi | ||||
|  | ||||
| echo -e "log_level                :info | ||||
| log_location             STDOUT | ||||
| node_name                'admin' | ||||
| client_key               '$client_key' | ||||
| validation_client_name   'chef-validator' | ||||
| validation_key           '$validation_key' | ||||
| chef_server_url          'https://$chefserver'" > $homedir/.chef/knife.rb | ||||
|  | ||||
| # Verify the configuration | ||||
| knife client list | ||||
| if [ $? -ne 0 ] | ||||
| then | ||||
|     errmsg="Failed to onfigure chef worktation on $node" | ||||
|     logger -t xcat -p local4.err $errmsg | ||||
|     echo $errmsg | ||||
|     exit 1 | ||||
| fi | ||||
| knife cookbook list | ||||
| exit 0 | ||||
							
								
								
									
										125
									
								
								xCAT/postscripts/install_chef_client
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										125
									
								
								xCAT/postscripts/install_chef_client
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,125 @@ | ||||
| #!/bin/sh -vx | ||||
| # IBM(c) 2013 EPL license http://www.eclipse.org/legal/epl-v10.html | ||||
| ##################################################### | ||||
| #=head1  install_chef_client | ||||
| #=head2  This command installs the chef client on a xCAT node(only for Ubuntu). It is used as | ||||
| # a postscript on Ubuntu only. | ||||
| #    usage: | ||||
| #      1. Setup the chef client using updatenode | ||||
| #            updatenode <noderange> -P "install_chef_client" | ||||
| #      2. Setup chef client during os provisioning | ||||
| #            chef <noderange> -p postscripts=install_chef_client | ||||
| #      3. Download chef client RPM from non-default repository | ||||
| #            updatenode <noderange> -P "install_chef_client -r http://mn/install/chef/chef_11.4.0-1.ubuntu.11.04_amd64.deb -s chefservername" | ||||
| #=cut | ||||
| ##################################################### | ||||
|  | ||||
| cat /etc/*release | grep "Ubuntu" > /dev/null | ||||
| if [ $? != 0 ]; then | ||||
|     echo "chef script only runs on ubuntu currently." | ||||
|     exit 1 | ||||
| fi | ||||
|  | ||||
| os="ubuntu" | ||||
|  | ||||
| #if [ $ARCH != "x86_64" ]; then | ||||
| #    echo "chef script only runs on x86_64 currently." | ||||
| #    exit -1; | ||||
| #fi | ||||
|  | ||||
| # For the URL to download chef: | ||||
| # -r flag takes precedence | ||||
| # then the environment variable CHEF_URL | ||||
| # then the default internet location | ||||
| ARGNUM=$#; | ||||
| if [ $ARGNUM -gt 1 ]; then | ||||
|     if [ $1 = "-r" ]; then | ||||
|         chefurl=$2 | ||||
|     fi | ||||
|     if [ $1 = "-s" ]; then | ||||
|         chefserver=$2 | ||||
|     fi | ||||
|     if [ $ARGNUM -gt 3 ]; then | ||||
|         if [ $3 = "-r" ]; then | ||||
|             chefurl=$4 | ||||
|         fi | ||||
|         if [ $3 = "-s" ]; then | ||||
|             chefserver=$4 | ||||
|         fi | ||||
|     fi | ||||
|  | ||||
| fi | ||||
|  | ||||
| if [ -z "$chefserver" ] | ||||
| then | ||||
|     if [ -n "$CHEFSERVER" ] | ||||
|     then | ||||
|         chefserver=$CHEFSERVER | ||||
|     fi | ||||
|     if [ -z "$chefserver" ] | ||||
|     then | ||||
|         chefserver=$SITEMASTER | ||||
|     fi | ||||
| fi | ||||
|  | ||||
|  | ||||
|  | ||||
| if [ "$chefurl" == "" ]; then | ||||
|     if [ "$CHEF_URL" != "" ]; then | ||||
|         chefurl=$CHEF_URL | ||||
|     else | ||||
|        arch=`uname -i` | ||||
|        osmv=`cat /etc/*release | grep DISTRIB_RELEASE |cut -d= -f2` | ||||
|        #https://www.opscode.com/chef/download?v=latest&prerelease=false&p=ubuntu&pv=12.04&m=x86_64 | ||||
|        chefurl="https://www.opscode.com/chef/download?v=latest&prerelease=false&p=$os&pv=$osmv&m=$arch"; | ||||
|     fi | ||||
| fi | ||||
|  | ||||
| if [ "$os" == "ubuntu" ]; then | ||||
|     #remove the old chef-server and the configuration files | ||||
|     apt-get -y autoremove --purge chef | ||||
|     rm -rf /etc/chef | ||||
|     rm -rf /root/.chef | ||||
|  | ||||
|     #add the internet Ubuntu repositories | ||||
|     #urelease="precise" #default release name | ||||
|     urelease=`cat /etc/lsb-release |grep DISTRIB_CODENAME |cut -d= -f2` | ||||
|  | ||||
|      | ||||
|     hostname=`hostname -f` | ||||
|     ##hostname="10.1.0.82" | ||||
|  | ||||
|     #add the public source | ||||
|     ubuntusource="deb http://us.archive.ubuntu.com/ubuntu/ $urelease main\n | ||||
| deb http://us.archive.ubuntu.com/ubuntu/ ${urelease}-updates main\n | ||||
| deb http://us.archive.ubuntu.com/ubuntu/ $urelease universe\n | ||||
| deb http://us.archive.ubuntu.com/ubuntu/ ${urelease}-updates universe\n | ||||
| " | ||||
|     echo -e $ubuntusource >> /etc/apt/sources.list | ||||
|  | ||||
|     # download the chef-server deb packages | ||||
|     #wget https://opscode-omnitruck-release.s3.amazonaws.com/ubuntu/12.04/x86_64/chef-server_11.0.6-1.ubuntu.12.04_amd64.deb | ||||
|     rm -rf /tmp/chef.deb  | ||||
|     wget -N --waitretry=10 --random-wait -T 60  $chefurl   -O /tmp/chef.deb | ||||
|     rc=$? | ||||
|     if [ $rc -eq 0 ] && [ -f /tmp/chef.deb ]; then | ||||
|         # install it | ||||
|         dpkg -i /tmp/chef.deb | ||||
|     else  | ||||
|         echo "Cannot download $chef" | ||||
|         exit 1 | ||||
|     fi    | ||||
|  | ||||
|     apt-get -y update | ||||
|  | ||||
|     # install rake git | ||||
|     apt-get install -y rake git | ||||
|  | ||||
| fi | ||||
|  | ||||
| #configure the chef configuration file | ||||
| result=`dirname $0` | ||||
| ${result}/config_chef_client -s $chefserver  | ||||
|  | ||||
|  | ||||
|  | ||||
							
								
								
									
										97
									
								
								xCAT/postscripts/install_chef_server
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										97
									
								
								xCAT/postscripts/install_chef_server
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,97 @@ | ||||
| #!/bin/sh -vx | ||||
| # IBM(c) 2013 EPL license http://www.eclipse.org/legal/epl-v10.html | ||||
| ##################################################### | ||||
| #=head1  install_chef_server | ||||
| #=head2  This command installs the chef server on a xCAT node(only for Ubuntu). It is used as | ||||
| # a postscript on Ubuntu only. | ||||
| #    usage: | ||||
| #      1. Setup the chef server using updatenode | ||||
| #            updatenode <noderange> -P "install_chef_server" | ||||
| #      2. Setup chef server during os provisioning | ||||
| #            chef <noderange> -p postscripts=install_chef_server | ||||
| #            nodeset xxx | ||||
| #      3. Download chef server RPM from non-default repository | ||||
| #            updatenode <noderange> -P "install_chef_server -r http://mn/install/chef/chef-server_11.0.4-1.ubuntu.12.04_amd64.deb" | ||||
| #=cut | ||||
| ##################################################### | ||||
|  | ||||
| cat /etc/*release | grep "Ubuntu" > /dev/null | ||||
| if [ $? != 0 ]; then | ||||
|     echo "chef script only runs on ubuntu currently." | ||||
|     exit 1 | ||||
| fi | ||||
|  | ||||
| os="ubuntu" | ||||
|  | ||||
| #if [ $ARCH != "x86_64" ]; then | ||||
| #    echo "chef script only runs on x86_64 currently." | ||||
| #    exit -1; | ||||
| #fi | ||||
|  | ||||
| # For the URL to download chef-server: | ||||
| # -r flag takes precedence | ||||
| # then the environment variable CHEF_SERVER_URL | ||||
| # then the default internet location | ||||
| ARGNUM=$#; | ||||
| if [ $ARGNUM -gt 1 ]; then | ||||
|     if [ $1 = "-r" ]; then | ||||
|         chefserverurl=$2 | ||||
|     fi | ||||
| else | ||||
|     if [ "$CHEF_SERVER_URL" != "" ]; then | ||||
|         chefserverurl=$CHEF_SERVER_URL | ||||
|     else | ||||
|        arch=`uname -i` | ||||
|        osmv=`cat /etc/*release | grep DISTRIB_RELEASE |cut -d= -f2` | ||||
|        #https://www.opscode.com/chef/download-server?v=latest&prerelease=false&p=ubuntu&pv=12.04&m=x86_64 | ||||
|        chefserverurl="https://www.opscode.com/chef/download-server?v=latest&prerelease=false&p=$os&pv=$osmv&m=$arch"; | ||||
|     fi | ||||
| fi | ||||
|  | ||||
| if [ "$os" == "ubuntu" ]; then | ||||
|     #remove the old chef-server and the configuration files | ||||
|     apt-get -y autoremove --purge chef-server | ||||
|     rm -rf /etc/chef-server | ||||
|     rm -rf /etc/chef | ||||
|     rm -rf /root/.chef | ||||
|  | ||||
|     #add the internet Ubuntu repositories | ||||
|     #urelease="precise" #default release name | ||||
|     urelease=`cat /etc/lsb-release |grep DISTRIB_CODENAME |cut -d= -f2` | ||||
|  | ||||
|      | ||||
|     hostname=`hostname -f` | ||||
|     ##hostname="10.1.0.82" | ||||
|  | ||||
|     #add the public source | ||||
|     ubuntusource="deb http://us.archive.ubuntu.com/ubuntu/ $urelease main\n | ||||
| deb http://us.archive.ubuntu.com/ubuntu/ ${urelease}-updates main\n | ||||
| deb http://us.archive.ubuntu.com/ubuntu/ $urelease universe\n | ||||
| deb http://us.archive.ubuntu.com/ubuntu/ ${urelease}-updates universe\n | ||||
| " | ||||
|     echo -e $ubuntusource >> /etc/apt/sources.list | ||||
|  | ||||
|     # download the chef-server deb packages | ||||
|     #wget https://opscode-omnitruck-release.s3.amazonaws.com/ubuntu/12.04/x86_64/chef-server_11.0.6-1.ubuntu.12.04_amd64.deb | ||||
|     rm -rf /tmp/chef-server*  | ||||
|     wget -N --waitretry=10 --random-wait -T 60  $chefserverurl   -O /tmp/chef-server.deb | ||||
|     rc=$? | ||||
|     if [ $rc -eq 0 ] && [ -f /tmp/chef-server.deb ]; then | ||||
|         # install it | ||||
|         dpkg -i /tmp/chef-server.deb | ||||
|     else  | ||||
|         echo "Cannot download $chefserverurl" | ||||
|         exit 1 | ||||
|     fi    | ||||
|  | ||||
|     apt-get -y update | ||||
|  | ||||
|     # install rake git | ||||
|     apt-get install -y rake git | ||||
|  | ||||
| fi | ||||
|  | ||||
| #configure the chef server | ||||
| result=`dirname $0` | ||||
| ${result}/config_chef_server | ||||
|  | ||||
							
								
								
									
										143
									
								
								xCAT/postscripts/install_chef_workstation
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										143
									
								
								xCAT/postscripts/install_chef_workstation
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,143 @@ | ||||
| #!/bin/sh -vx | ||||
| # IBM(c) 2013 EPL license http://www.eclipse.org/legal/epl-v10.html | ||||
| ##################################################### | ||||
| #=head1  install_chef_client | ||||
| #=head2  This command installs the chef client on a xCAT node(only for Ubuntu). It is used as | ||||
| # a postscript on Ubuntu only. | ||||
| #    usage: | ||||
| #      1. Setup the chef client using updatenode | ||||
| #            updatenode <noderange> -P "install_chef_client" | ||||
| #      2. Setup chef client during os provisioning | ||||
| #            chef <noderange> -p postscripts=install_chef_client | ||||
| #      3. Download chef deb from non-default repository | ||||
| #            updatenode <noderange> -P "install_chef_workstation -r http://mn/install/chef/chef_11.4.0-1.ubuntu.11.04_amd64.deb -s chefservername" | ||||
| #=cut | ||||
| ##################################################### | ||||
|  | ||||
| cat /etc/*release | grep "Ubuntu" > /dev/null | ||||
| if [ $? != 0 ]; then | ||||
|     echo "chef script only runs on ubuntu currently." | ||||
|     exit 1 | ||||
| fi | ||||
|  | ||||
| os="ubuntu" | ||||
|  | ||||
| #if [ $ARCH != "x86_64" ]; then | ||||
| #    echo "chef script only runs on x86_64 currently." | ||||
| #    exit -1; | ||||
| #fi | ||||
|  | ||||
| # For the URL to download chef: | ||||
| # -r flag takes precedence | ||||
| # then the environment variable CHEF_URL | ||||
| # then the default internet location | ||||
| ARGNUM=$#; | ||||
|  | ||||
| if [ $ARGNUM -gt 1 ]; then | ||||
|     if [ $1 = "-r" ]; then | ||||
|         chefurl=$2 | ||||
|     fi | ||||
|     if [ $1 = "-s" ]; then | ||||
|         chefserver=$2 | ||||
|     fi | ||||
|     if [ $ARGNUM -gt 3 ]; then | ||||
|         if [ $3 = "-r" ]; then | ||||
|             chefurl=$4 | ||||
|         fi | ||||
|         if [ $3 = "-s" ]; then | ||||
|             chefserver=$4 | ||||
|         fi | ||||
|     fi | ||||
|  | ||||
| fi | ||||
|  | ||||
| if [ -z "$chefserver" ] | ||||
| then | ||||
|     if [ -n "$CHEFSERVER" ] | ||||
|     then | ||||
|         chefserver=$CHEFSERVER | ||||
|     fi | ||||
|     if [ -z "$chefserver" ] | ||||
|     then | ||||
|         chefserver=$SITEMASTER | ||||
|     fi | ||||
| fi | ||||
|  | ||||
| if [ -z "$chefserver" ]; then | ||||
|     if [ -f /etc/chef-server/admin.pem -a -f /etc/chef-server/chef-validator.pem ]; then | ||||
|         echo "the current node is also a chef server"  | ||||
|         if [ -f /opt/chef-server/embedded/bin/knife ]; then | ||||
|             if [ ! -f /usr/bin/knife ]; then | ||||
|                 ln -s  /opt/chef-server/embedded/bin/knife /usr/bin/knife              | ||||
|             fi | ||||
|         fi | ||||
|    fi | ||||
|      | ||||
|    if [ -f /usr/bin/knife ]; then | ||||
|         #configure the chef configuration file | ||||
|         result=`dirname $0` | ||||
|         ${result}/config_chef_workstation  | ||||
|         exit 0; | ||||
|    fi  | ||||
|  | ||||
| fi | ||||
|  | ||||
| if [ $chefurl != "" ]; then | ||||
|     if [ "$CHEF_URL" != "" ]; then | ||||
|         chefurl=$CHEF_URL | ||||
|     else | ||||
|        arch=`uname -i` | ||||
|        osmv=`cat /etc/*release | grep DISTRIB_RELEASE |cut -d= -f2` | ||||
|        #https://www.opscode.com/chef/download?v=latest&prerelease=false&p=ubuntu&pv=12.04&m=x86_64 | ||||
|        chefurl="https://www.opscode.com/chef/download?v=latest&prerelease=false&p=$os&pv=$osmv&m=$arch"; | ||||
|     fi | ||||
| fi | ||||
|  | ||||
| if [ $os == "ubuntu" ]; then | ||||
|     #remove the old chef-server and the configuration files | ||||
|     apt-get -y autoremove --purge chef | ||||
|     rm -rf /etc/chef | ||||
|     rm -rf /root/.chef | ||||
|  | ||||
|     #add the internet Ubuntu repositories | ||||
|     #urelease="precise" #default release name | ||||
|     urelease=`cat /etc/lsb-release |grep DISTRIB_CODENAME |cut -d= -f2` | ||||
|  | ||||
|      | ||||
|     hostname=`hostname -f` | ||||
|     ##hostname="10.1.0.82" | ||||
|  | ||||
|     #add the public source | ||||
|     ubuntusource="deb http://us.archive.ubuntu.com/ubuntu/ $urelease main\n | ||||
| deb http://us.archive.ubuntu.com/ubuntu/ ${urelease}-updates main\n | ||||
| deb http://us.archive.ubuntu.com/ubuntu/ $urelease universe\n | ||||
| deb http://us.archive.ubuntu.com/ubuntu/ ${urelease}-updates universe\n | ||||
| " | ||||
|     echo -e $ubuntusource >> /etc/apt/sources.list | ||||
|  | ||||
|     # download the chef-server deb packages | ||||
|     #wget https://opscode-omnitruck-release.s3.amazonaws.com/ubuntu/12.04/x86_64/chef-server_11.0.6-1.ubuntu.12.04_amd64.deb | ||||
|     rm -rf /tmp/chef.deb  | ||||
|     wget -N --waitretry=10 --random-wait -T 60  $chefurl   -O /tmp/chef.deb | ||||
|     rc=$? | ||||
|     if [ $rc -eq 0 ] && [ -f /tmp/chef.deb ]; then | ||||
|         # install it | ||||
|         dpkg -i /tmp/chef.deb | ||||
|     else  | ||||
|         echo "Cannot download $chefurl" | ||||
|         exit 1 | ||||
|     fi    | ||||
|  | ||||
|     apt-get -y update | ||||
|  | ||||
|     # install rake git | ||||
|     apt-get install -y rake git | ||||
|  | ||||
| fi | ||||
|  | ||||
| #configure the knife configuration file | ||||
| result=`dirname $0` | ||||
| ${result}/config_chef_workstation -s $chefserver | ||||
|  | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user