Skip to content

Instantly share code, notes, and snippets.

@perpetual-hydrofoil
Last active June 16, 2016 10:02
Show Gist options
  • Save perpetual-hydrofoil/4736449 to your computer and use it in GitHub Desktop.
Save perpetual-hydrofoil/4736449 to your computer and use it in GitHub Desktop.
Install Cloud Init on RHEL
#! /bin/bash
set -e
# Build and install cloud-init on RHEL 6 AMIs
# (Please note: RHEL5 not supported because python 2.4 is too old for even boto)
# This will have undefined behavior on non-RHEL6 systems but should work on CentOS 6.
# Ubuntu and Amazon already have cloud-init.
# temporary build directory
cd /tmp
# Ensure lsb_release is available on the system
sudo yum -y install redhat-lsb
# not all systems (i.e., Amazon) have lsb_release installed
R=$(lsb_release -rs | cut -f1 -d.)
r=$(lsb_release -rs | cut -f2 -d.)
# download pip from EPEL
# optional if EPEL mirrors already configured-- highly recommended!
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/$R/x86_64/epel-release-$R-$r.noarch.rpm
wget http://dl.fedoraproject.org/pub/epel/$R/x86_64/python-pip-0.8-1.el$R.noarch.rpm
# install needed rhel rpms and pip, bzr is available in epel
yum install -y bzr rpm-build python-devel python-simplejson python-pip*rpm make python-setuptools python-cheetah
# Pull in python deps. Note non-default epel filename for pip
# Please note, this list contains deps that should be installed on the target system
# with pip since we're removing the dependency checks from the RPM below
pip-python install --upgrade virtualenv argparse boto requests paste prettytable oauth configobj pylint nose mocker pysaml
# optional, use standard pip name
ln -s /usr/bin/pip-python /usr/bin/pip
# download a temporary copy of cloud-init
bzr branch lp:cloud-init
cd cloud-init
# simple hack to switching configobj to simplejson and work around broken
# dep checks which rely on deps being installed via RPM, using pip instead
# because RHEL5 doesn't support some of the packages
mv Requires Requires.old
echo "simplejson" > Requires
sed -i "s/configobj/simplejson/g" packages/brpm
# make the RPM packages:
# Wrote out redhat package '/tmp/cloud-init/cloud-init-0.7.2-bzr780.el6.noarch.rpm'
# Wrote out redhat package '/tmp/cloud-init/cloud-init-0.7.2-bzr780.el6.src.rpm'
make rpm
# deps already installed via pip (prettytable, oauth not available in EPEL5)
# optional clean-up
sudo yum remove bzr python-cheetah
# If your build system is separate from your AMI image, be sure to:
# 1) install the python packages shown above using pip (or yum)
# 2) create the appropriate config files in /etc/cloud/ based on the templates
# in /tmp/cloud-init/doc/. (The defaults are for ubuntu, but that's not
# appropriate on a RHEL platform.) Warning, the defaults will replace your
# SSH server keys, opening a huge man-in-the-middle attack!)
# 3) rpm -i cloud-init-*.noarch.rpm
@perpetual-hydrofoil
Copy link
Author

This version is probably better updated.. https://github.com/jamiesonbecker/cloudinit-rhel

@perpetual-hydrofoil
Copy link
Author

Please note: the references within the code to RHEL5 and EPEL5 were from earlier attempts to hack it into RHEL5. There are two methods if you want to try that:

  1. Make it work with Python 2.6 from EPEL (which means overriding /usr/bin/python, and/or move the entire system to python 2.6 including copying all modules in site-packages over to the new version or basic system tools such as yum will break.

  2. Backport Cloud Init, and ALL of its dependencies, to Python 2.4. This is nearly impossible since all recent versions of boto rely on Python 2.6 or later as well as all of the deps (like PyYAML and five or six others.)

So backporting to Python 2.4 is next to impossible.

@perpetual-hydrofoil
Copy link
Author

Upgrading a language like Python that is integral to the entire packaging system, anaconda, etc, would be unsupportable by Red Hat.

As noted in the article (http://jamiesonbecker.com/installing-cloudinit-on-rhel/ ), RHEL5 is very old -- late 2006. No new versions of software will be introduced for it. It almost pre-dates EC2 itself. The version of Python in it is obviously even older. Amazon is making huge investments in all of the latest toolsets -- boto, cloudinit, cloudformation, etc, but not on RHEL5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment