Closed carlnordenfelt closed 5 years ago
I've trudged along a little bit with this and found that installing it from git appears to work on a clean Ubuntu 18.04 instance (AMI ID: ami-0b91bd72)
git clone https://github.com/aws/aws-codedeploy-agent.git
gem install bundler
gem install rake
cd aws-codedeploy-agent
bundle install
rake clean && rake
At least it builds and the tests passes. I haven't actually started the agent because I have no configuration but the error message is promising
bin/codedeploy-agent start
error: The config file /opt/codedeploy-agent/conf/codedeployagent.yml does not exist or is not readable
Hi @carlnordenfelt,
I was able to get aws-codedeploy-agent running on Ubuntu Bionic working using your idea to install the gems using bundler. Here is a snippet of what I used. I haven't had a chance to do a codedeploy release yet, so I can't verify if all the Lifecycle hooks work fine.
# Install aws-codedeploy-agent and required gems
sudo apt-get install -y git
codedeploy_git_url='https://github.com/aws/aws-codedeploy-agent.git'
git clone "$codedeploy_git_url"
sudo gem install bundler
sudo mv aws-codedeploy-agent /opt/codedeploy-agent
cd /opt/codedeploy-agent
bundle install --system
# Setup permissions
sudo chown -R root.root /opt/codedeploy-agent
sudo chmod 644 /opt/codedeploy-agent/conf/codedeployagent.yml
sudo chmod 755 /opt/codedeploy-agent/init.d/codedeploy-agent
sudo chmod 644 /opt/codedeploy-agent/init.d/codedeploy-agent.service
# Create symlink to match ./install setup
sudo mkdir -p /etc/codedeploy-agent
sudo ln -s /opt/codedeploy-agent/conf /etc/codedeploy-agent/conf
# Move init scripts
sudo mv /opt/codedeploy-agent/init.d/codedeploy-agent /etc/init.d/codedeploy-agent
sudo mv /opt/codedeploy-agent/init.d/codedeploy-agent.service \
/lib/systemd/system/codedeploy-agent.service
# Delete RHEL init info since this is for Ubuntu Bionic
sudo sed -i.bak '2,8d' /etc/init.d/codedeploy-agent && \
sudo rm -f /etc/init.d/codedeploy-agent.bak
# Enable init.d scripts to start at boot
sudo /etc/init.d/codedeploy-agent start && echo ''
sudo /usr/sbin/update-rc.d codedeploy-agent defaults
sudo /usr/sbin/update-rc.d codedeploy-agent enable
# Cleanup
files=(.git
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Gemfile.lock
LICENSE
NOTICE
README.md
Rakefile
buildspec-agent-rake.yml
coverage
deployment
features
spec
test)
cd /opt/codedeploy-agent
for f in "${files[@]}";do
sudo rm -rf "$f"
done
installing 2.4 via rvm only partially works, it fails later with
I, [2018-06-05T23:53:19.422673 #14835] INFO -- : Executing `/usr/bin/gdebi -n -o Dpkg::Options::=--force-confdef -o Dkpg::Options::=--force-confold /tmp/codedeploy-agent_1.0-1.1458_all.tmp-20180605-14835-coa00t.deb`...
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading state information... Done
This package is uninstallable
Dependency is not satisfiable: ruby2.0|ruby2.1|ruby2.2|ruby2.3
E, [2018-06-05T23:53:20.638750 #14835] ERROR -- : Error installing /tmp/codedeploy-agent_1.0-1.1458_all.tmp-20180605-14835-coa00t.deb.
@salmonte your script worked perfect without any modifications for my Ubuntu 18.04 in AWS, even confirmed codedeploy was able to deploy to the instance afterward and the lifecycle hooks worked fine for me.
+1 on this request
Would anyone happened that errors are not shown in the deployments?
I've noticed that it only copies folders properly in the "files" section of the appspec.yml file. Files are incorrectly marked as folders, and unreadable.
After 2 days of testing I managed to make it work in a clean installation of Ubuntu 18 with rvm:
(sudo su)
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
\curl -sSL https://get.rvm.io | bash -s stable --ruby=2.3.0
echo 'source /usr/local/rvm/scripts/rvm' >> /etc/profile
echo 'source /usr/local/rvm/scripts/rvm' >> ~/.bashrc
exec $SHELL
ruby -v
gem install bundler
cd /opt
git clone https://github.com/aws/aws-codedeploy-agent.git codedeploy-agent
cd codedeploy-agent
bundle install
rake clean && rake
cp /opt/codedeploy-agent/init.d/codedeploy-agent /etc/init.d/
systemctl daemon-reload
systemctl start codedeploy-agent
systemctl enable codedeploy-agent
Another idea to get codedeploy-agent running on Ubuntu 18.04 (bionic):
# remove ruby 2.5/rake if installed
apt purge libruby ruby rake
# add repositories for xenial and xenial-updates
cat << EOF > /etc/apt/sources.list.d/xenial.list
deb http://archive.ubuntu.com/ubuntu/ xenial main
deb http://archive.ubuntu.com/ubuntu/ xenial-updates main
EOF
# priorise ruby/rake from xenial repository
cat << EOF > /etc/apt/preferences.d/ruby-xenial
Package: ruby
Pin: release v=16.04, l=Ubuntu
Pin-Priority: 1024
Package: rake
Pin: release v=16.04, l=Ubuntu
Pin-Priority: 1024
EOF
# install ruby and dependent packages
apt update
apt install ruby gdebi-core
# download and run codedeploy-agent installer
curl -o /tmp/codedeploy-installer https://aws-codedeploy-eu-west-1.s3.amazonaws.com/latest/install
chmod +x /tmp/codedeploy-installer
/tmp/codedeploy-installer auto
# delete installer script
rm -f /tmp/codedeploy-installer
# create systemd service file and enable it
mv /etc/init.d/codedeploy-agent.service /lib/systemd/system/codedeploy-agent.service
systemctl enable codedeploy-agent.service
This approach ensures that your system is receiving security updates for ruby, and this won't break anything (unless any of your applications require ruby >= 2.4). Also, this uses "official" stable releases of the AWS CodeDeploy agent.
Trying to setup the codedeploy-agent on a new 18.04 image using rodrigodev94's method, and the GPG server is returning connection timed out. Are there options to install it without needing to validate the keys? Or just confirmation that they key agent here isn't failing?
I created fake package (ruby2.3) and modify install script to workaround this issue:
# Ruby 2.5
sudo apt -y install ruby
# Ruby 2.3 (fake)
sudo apt -y install equivs
cd /tmp
equivs-control ruby2.3.control
perl -pi -e 's{^Package.*}{Package: ruby2.3}' ruby2.3.control
equivs-build ruby2.3.control
sudo dpkg -i ruby2.3_1.0_all.deb
# AWS CodeDeploy (us-east-1)
cd /tmp
wget https://aws-codedeploy-us-east-1.s3.amazonaws.com/latest/install
perl -pi -e "s{\\['2.4', '2.3', '2.2', '2.1', '2.0'\\]}{['2.5', '2.4', '2.3', '2.2', '2.1', '2.0']}" install
chmod 755 install
sudo ./install auto
any chance to fix that one ?
Ubuntu 18.04 has released in April. But this agent is not supporting it now. It's too late.
Any news on this?
+1 to the request
+1 it is a shame that AWS supports Ubuntu 18.04LTS officially from their repository and quick launch page, the 18.04 is out for 5 months BUT nobody is there from 10k+ engineers who could fix it.
Hi @rohkat-aws, I just saw dc221297c0219f68c6a3d58f0cdae13117912bff was pushed to master. Does this mean that your internal testing is done and the CD-agent is ready for Ruby 2.5?
Yes its , but the agent needs to released . Will keep the issue open till we dont start releasing it.
When will be released?
#!/bin/bash
apt update
apt install ruby -y
gem install bundler
git clone https://github.com/aws/aws-codedeploy-agent.git /opt/codedeploy-agent
sudo chown -R root.root /opt/codedeploy-agent
sudo chmod 644 /opt/codedeploy-agent/conf/codedeployagent.yml
sudo chmod 755 /opt/codedeploy-agent/init.d/codedeploy-agent
sudo chmod 644 /opt/codedeploy-agent/init.d/codedeploy-agent.service
cd /opt/codedeploy-agent
bundle install --system
rake clean && rake
cp /opt/codedeploy-agent/init.d/codedeploy-agent /etc/init.d/
systemctl daemon-reload
systemctl start codedeploy-agent
systemctl enable codedeploy-agent
I compose the @salmonte and @ghost scripts. This scripts is tested many times. Of course, you can install the ruby with rvm or rbenv.
@vetermanve oops I fixed it up. Thanks 👍
#!/bin/bash apt update apt install ruby -y gem install bundler git clone https://github.com/aws/aws-codedeploy-agent.git /opt/codedeploy-agent sudo chown -R root.root /opt/codedeploy-agent sudo chmod 644 /opt/codedeploy-agent/conf/codedeployagent.yml sudo chmod 755 /opt/codedeploy-agent/init.d/codedeploy-agent sudo chmod 644 /opt/codedeploy-agent/init.d/codedeploy-agent.service cd /opt/codedeploy-agent bundle install --system rake clean && rake cp /opt/codedeploy-agent/init.d/codedeploy-agent /etc/init.d/ systemctl daemon-reload systemctl start codedeploy-agent systemctl enable codedeploy-agent
I compose the @salmonte and @ghost scripts. This scripts is tested many times. Of course, you can install the ruby with rvm or rbenv.
You missed first slash in cd /opt/codedeploy-agent
!
Great work! Thanks!
Hello All,
I had the same issues and after battling for almost 2 days, i finally raised the complaint on AWS support centre. This is what they sent to me that worked effortlessly.
The agent installation failed because the CodeDeploy agent does not support Ruby 2.5 (shipped by Ubuntu 18.04 repositories) [2] yet.
You can still install the CodeDeploy agent on Ubuntu 18.04 by downgrading Ruby to version 2.3 (shipped by Ubuntu 16.04 repositories) [3].
Please follow these steps to downgrade Ruby to version 2.3:
sudo apt purge libruby ruby rake
sudo cat << EOF > /etc/apt/sources.list.d/xenial.list deb http://archive.ubuntu.com/ubuntu/ xenial main deb http://archive.ubuntu.com/ubuntu/ xenial-updates main EOF
sudo cat << EOF > /etc/apt/preferences.d/ruby-xenial Package: ruby Pin: release v=16.04, l=Ubuntu Pin-Priority: 1024
Package: rake Pin: release v=16.04, l=Ubuntu Pin-Priority: 1024 EOF
sudo apt update sudo apt install ruby gdebi-core
You can proceed to the CodeDeploy agent installation following the same documentation [1] after downgrading Ruby.
I hope this helps someone.
Hello All,
I had the same issues and after battling for almost 2 days, i finally raised the complaint on AWS support centre. This is what they sent to me that worked effortlessly.
The agent installation failed because the CodeDeploy agent does not support Ruby 2.5 (shipped by Ubuntu 18.04 repositories) [2] yet.
Workaround
You can still install the CodeDeploy agent on Ubuntu 18.04 by downgrading Ruby to version 2.3 (shipped by Ubuntu 16.04 repositories) [3].
Please follow these steps to downgrade Ruby to version 2.3:
remove ruby 2.5/rake if installed
sudo apt purge libruby ruby rake
add repositories for Ubuntu 16.04
sudo cat << EOF > /etc/apt/sources.list.d/xenial.list deb http://archive.ubuntu.com/ubuntu/ xenial main deb http://archive.ubuntu.com/ubuntu/ xenial-updates main EOF
priorise ruby/rake from Ubuntu 16.04 repository
sudo cat << EOF > /etc/apt/preferences.d/ruby-xenial Package: ruby Pin: release v=16.04, l=Ubuntu Pin-Priority: 1024
Package: rake Pin: release v=16.04, l=Ubuntu Pin-Priority: 1024 EOF
install ruby and dependent packages
sudo apt update sudo apt install ruby gdebi-core
You can proceed to the CodeDeploy agent installation following the same documentation [1] after downgrading Ruby.
I hope this helps someone.
Ensure you specify the path in the right ruby installation once you download the package from the right sim bucket.. mine was - sudo /usr/share/rvm/rubies/ruby-2.3.5/bin/ruby ./install auto
It's kind of funny that support proposes something we added as recommendation in this issue some time ago. However, that may break software that relies on newer Ruby releases - use it with caution.
Thanks @commx Codedeploy is the only ruby dependent solution we intend to run on this server but your advice is well noted.
encountered the same issue, it is sad to see that new shiny product from AWS does not support new Ubuntu LTS
@gregkonushev-okta hey we have already rolled out a fix for this , its already in us-east-1 and being rolled out in other regions too.
@rohkat-aws that's great, which version of codedeploy agent works with ruby 2.5? When will you have rollout on us-east-2?
If you want to beta test the version from us-east-1 on ubuntu 18.04:
sudo apt-get install ruby
wget https://aws-codedeploy-us-east-1.s3.amazonaws.com/latest/install
sudo ruby install auto
Looks like fixed versions are now available on most common regions:
eu-west-1: Setting up codedeploy-agent (1.0-1.1597) ...
us-east-1: Setting up codedeploy-agent (1.0-1.1597) ...
us-east-2: Setting up codedeploy-agent (1.0-1.1597) ...
resolved for a while,after the last agent release
I'm trying to install the aws-codedeploy-agent on Ubuntu 18.04. Ubuntu 18.04 comes with ruby 2.5.1
I followed the advice and create a symlink from ruby2.4 => ruby2.5 and re-ran installation:
At this point I rather desperately created a symlink between ruby2.5 and ruby2.3 without actually expecting it to work and as I suspected, no luck, same error.
Any suggestions other than trying to install ruby2.4 via rvm which I have also tried and failed (don't have the logs from that attempt)?