AWS CodeDeply Agent installation on RHEL/CentOS 6

Cloud Guy
3 min readSep 25, 2020

As per AWS official documentations, Linux based on RHEL 6 is not fully supported. Upon bit more research, I finally figured that Code Deploy agents are build on Ruby & require ruby 2.0 or above. For RHEL/CentOS 6, the default ruby version is 1.8. So the standard installation procedures mentioned here will not be be applied blindly. Some extra steps would be require to install ruby 2.0 or above on RHEL/CentOS 6 to carry on with Code Deploy agent installation.

Follow the steps to install Ruby 2.0 or above on RHEL/CentOS 6.

# Install a package with repository for your system:
# On RHEL/CentOS 6, install package centos-release-scl available in CentOS repository:
$ sudo yum install centos-release-scl
# On RHEL, enable RHSCL repository for you system:
$ sudo yum-config-manager --enable rhel-server-rhscl-6-rpms
# Install the ruby 2.3. The same repository may support other versions of ruby as well. Please check with rh-ruby24, rh-ruby25 like that
$ sudo yum install rh-ruby23
# Start using software collections:
$ scl enable rh-ruby23 bash

Check the installed version of ruby:

# Check installed version of ruby
$ ruby -v
ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-linux-gnu]
# Check where are the default ruby library is located
$ find / -name libruby.so.2.3
/opt/rh/rh-ruby23/root/usr/lib64/libruby.so.2.3
# Where is the ruby binary located
$ which ruby
/opt/rh/rh-ruby23/root/usr/bin/ruby

Download & run the Code Deploy package from AWS & install:

# Download the installer script from AWS. The URL will vary based on AWS regions
$ wget https://aws-codedeploy-us-east-2.s3.us-east-2.amazonaws.com/latest/install
# Once downloaded change the mode to executable & run
$ chmod +x install
$ ./install auto

You can experience errors while installing the Code Deploy agent (./install auto).

Error #1:

pre hook : 1
Checking the ruby version.
==========================================================================================
AWS CodeDeploy needs Ruby version 2.0 or above to be installed for XXXX under /usr/bin
Please install Ruby 2.x for user XXXX
===================================================================================

As the above error is already giving some hints that the ruby binary is expected to be present at /usr/bin

So we need to copy the required binary into /usr/bin.

# Where is the ruby binary located
$ which ruby
/opt/rh/rh-ruby23/root/usr/bin/ruby
# Create a softlink of the ruby binary into /usr/bin
$ ln -s /opt/rh/rh-ruby23/root/usr/bin/ruby /usr/bin/ruby

Error #2:

$ sudo ./install auto 
ruby: error while loading shared libraries: libruby.so.2.3: cannot open shared object file: No such file or directory

Even though the ruby 2.3 library is available (libruby.so.2.3), still it shows No such file or directory. The reason for this error was that the required ruby library (libruby.so.2.3) is not present in the expected path /lib64

# Check where are the default ruby library is located
$ find / -name libruby.so.2.3
/opt/rh/rh-ruby23/root/usr/lib64/libruby.so.2.3
# Need to copy the libruby.so.2.3 from from the source path into /lib64
$ cp /opt/rh/rh-ruby23/root/usr/lib64/libruby.so.2.3 /lib64/

Now if we try to install, the installation should proceed with success.

$ ./install auto
...
Installed:
codedeploy-agent.noarch 0:1.2.1-1868
Complete!
I, [2020-09-22T07:13:40.080336 #28293] INFO -- : Update check complete.
I, [2020-09-22T07:13:40.080428 #28293] INFO -- : Stopping updater.
# Check the status of the Code Deploy agent
$ service codedeploy-agent status
The AWS CodeDeploy agent is running as PID 28523

--

--