-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Install chef via apt repo on ubuntu #79
Changes from 4 commits
54413d6
34d41ef
5660546
3f28255
ffdd22f
47bc2de
71a87e8
c44d507
4c5876d
7e6dc4a
c5a058f
f2fb176
c0a5de4
3cce7b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,43 +9,6 @@ get_script_dir(){ | |
|
||
chef_extension_root=$(get_script_dir)/../ | ||
|
||
# returns chef-client bebian installer | ||
get_deb_installer(){ | ||
pkg_file="$chef_extension_root/installer/chef-client-latest.deb" | ||
echo "${pkg_file}" | ||
} | ||
|
||
get_rpm_installer(){ | ||
pkg_file="$chef_extension_root/installer/chef-client-latest.rpm" | ||
echo "${pkg_file}" | ||
} | ||
|
||
# install_file TYPE FILENAME | ||
# TYPE is "deb" | ||
install_file() { | ||
echo "Installing Chef $version" | ||
case "$1" in | ||
"deb") | ||
echo "[$(date)] Installing with dpkg...$2" | ||
dpkg -i "$2" | ||
;; | ||
"rpm") | ||
echo "[$(date)] Installing with rpm...$2" | ||
rpm -i "$2" | ||
;; | ||
*) | ||
echo "Unknown filetype: $1" | ||
exit 1 | ||
;; | ||
esac | ||
if test $? -ne 0; then | ||
echo "[$(date)] Chef Client installation failed" | ||
exit 1 | ||
else | ||
echo "[$(date)] Chef Client Package installation succeeded!" | ||
fi | ||
} | ||
|
||
# install azure chef extension gem | ||
install_chef_extension_gem(){ | ||
echo "[$(date)] Installing Azure Chef Extension gem" | ||
|
@@ -88,19 +51,17 @@ curl_check (){ | |
echo "Detected curl..." | ||
else | ||
echo "Installing curl..." | ||
yum install -d0 -e0 -y curl | ||
if [ "$1" == "centos" ]; then | ||
yum install -d0 -e0 -y curl | ||
else | ||
apt-get install -q -y curl | ||
fi | ||
fi | ||
} | ||
|
||
install_from_local_package(){ | ||
# install chef | ||
chef_client_installer=$(get_deb_installer) | ||
installer_type="deb" | ||
install_file $installer_type "$chef_client_installer" | ||
} | ||
|
||
install_from_repo(){ | ||
curl_check | ||
install_from_repo_centos(){ | ||
platform="centos" | ||
curl_check $platform | ||
get_hostname | ||
yum_repo_path=/etc/yum.repos.d/chef_stable.repo | ||
yum_repo_config_url="https://packagecloud.io/install/repositories/chef/stable/config_file.repo?os=el&dist=5&name=${host}" | ||
|
@@ -145,7 +106,74 @@ install_from_repo(){ | |
yum -y install chef | ||
echo "Package Installed successfully ..." | ||
} | ||
|
||
|
||
install_from_repo_ubuntu() { | ||
platform="ubuntu" | ||
curl_check $platform | ||
|
||
# Need to first run apt-get update so that apt-transport-https can be installed | ||
echo -n "Running apt-get update... " | ||
apt-get update | ||
echo "done." | ||
|
||
echo -n "Installing apt-transport-https... " | ||
apt-get install -y apt-transport-https | ||
echo "done." | ||
|
||
apt_config_url="https://packagecloud.io/install/repositories/chef/stable/config_file.list?os=ubuntu&dist=trusty&source=script" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @NimishaS Could please verify this with ubuntu 12 precise distro ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @siddheshwar-more, verified with ubuntu 12, |
||
apt_source_path="/etc/apt/sources.list.d/chef_stable.list" | ||
|
||
echo -n "Installing $apt_source_path..." | ||
|
||
# create an apt config file for this repository | ||
curl -sSf "${apt_config_url}" > $apt_source_path | ||
curl_exit_code=$? | ||
|
||
if [ "$curl_exit_code" = "22" ]; then | ||
echo -n "Unable to download repo config from: " | ||
echo "${apt_config_url}" | ||
echo | ||
echo "Please contact support@packagecloud.io and report this." | ||
[ -e $apt_source_path ] && rm $apt_source_path | ||
exit 1 | ||
elif [ "$curl_exit_code" = "35" ]; then | ||
echo "curl is unable to connect to packagecloud.io over TLS when running: " | ||
echo " curl ${apt_config_url}" | ||
echo "This is usually due to one of two things:" | ||
echo | ||
echo " 1.) Missing CA root certificates (make sure the ca-certificates package is installed)" | ||
echo " 2.) An old version of libssl. Try upgrading libssl on your system to a more recent version" | ||
echo | ||
echo "Contact support@packagecloud.io with information about your system for help." | ||
[ -e $apt_source_path ] && rm $apt_source_path | ||
exit 1 | ||
elif [ "$curl_exit_code" -gt "0" ]; then | ||
echo | ||
echo "Unable to run: " | ||
echo " curl ${apt_config_url}" | ||
echo | ||
echo "Double check your curl installation and try again." | ||
[ -e $apt_source_path ] && rm $apt_source_path | ||
exit 1 | ||
else | ||
echo "done." | ||
fi | ||
|
||
echo -n "Importing packagecloud gpg key... " | ||
# import the gpg key | ||
curl https://packagecloud.io/gpg.key | sudo apt-key add - | ||
echo "done." | ||
|
||
echo -n "Running apt-get update... " | ||
# update apt on this system | ||
apt-get update | ||
echo "done." | ||
|
||
echo "Installing chef-client package" | ||
apt-get install chef | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @NimishaS There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @NimishaS we can refactor this code since we are using same logic for centos to check curl command status There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @siddheshwar-more, added |
||
echo "Package Installed successfully ..." | ||
} | ||
|
||
get_linux_distributor(){ | ||
#### Using python -mplatform command to get distributor name ##### | ||
if python -mplatform | grep centos > /dev/null; then | ||
|
@@ -169,11 +197,11 @@ else | |
case $linux_distributor in | ||
"ubuntu") | ||
echo "Linux Distributor: ${linux_distributor}" | ||
install_from_local_package | ||
install_from_repo_ubuntu | ||
;; | ||
"centos") | ||
echo "Linux Distributor: ${linux_distributor}" | ||
install_from_repo | ||
install_from_repo_centos | ||
;; | ||
*) | ||
echo "No Linux Distributor detected ... exiting..." | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ uninstall_ubuntu_chef_package(){ | |
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @NimishaS The above code is really necessary now ? Since, now we are using apt-get here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed code for status check |
||
if test "$install_status" = "$dpkg_installed" ; then | ||
echo "[$(date)] Uninstalling package $pkg_name ..." | ||
dpkg -P $pkg_name | ||
apt-get purge $pkg_name | ||
check_uninstallation_status | ||
else | ||
echo "No Package found to uninstall!!!" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems indentation is not proper