Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Install Concourse-CI on Ubuntu 18.04

In this post, I will Install Concourse-CI on Ubuntu 18.04 Server. Concourse is an awesome continuous integration solution.

Recently I was looking for an alternative to Jenkins for automating my application testing and deployment.  I came across Concourse-CI and fell in love with it’s simplicity.

I also really liked how it’s pipelines can be checked into version control.

Getting Started

I created a virtual machine with 8 vCPUs, 4 GB of memory, and 40 GB of hard drive space.

First, install a fresh copy of Ubuntu Server 18.04.1.

Next perform all the updates and reboot.

apt update && apt upgrade -y
reboot

To install Concourse-CI on Ubuntu 18.04 we will need to install and configure three components:

  • Postgresql
  • Concourse Web
  • Concourse Worker

We will be configuring the Concourse Web and Concourse Worker as SsytemD services.

Let’s start by installing Postgresql

Install Postgresql

First install the postgresql packages

apt install postgresql postgresql-contrib -y

Next we need to create a postgresql user (they call it a role).

sudo -u postgres createuser -s concourse

Next, we need to create the databases that will be used by Concourse: concourse and atc.

sudo -u postgres createdb --owner=concourse concourse
sudo -u postgres createdb --owner=concourse atc

Now we can install the concourse web service.

Install Concourse Web

The first thing we have to do is download the concourse binary.

Go to the Concourse-CI Downloads Page and right-click the link for Linux concourse AMD-64 and select copy link address (or similar depending on your browser).

Now use wget to download the file.

wget https://github.com/concourse/concourse/releases/download/v4.2.1/concourse_linux_amd64

Rename the file and move it to a better home.

mv concourse_linux_amd64 concourse
mv concourse /usr/bin

Make it executable.

chmod a+x /usr/bin/concourse

Next we need to generate some keys so our worker can talk to our web server.

mkdir -p /etc/concourse
ssh-keygen -t rsa -f /etc/concourse/host_key -N ''
ssh-keygen -t rsa -f /etc/concourse/session_signing_key -N ''
ssh-keygen -t rsa -f /etc/concourse/worker_key -N ''
cp /etc/concourse/worker_key.pub /etc/concourse/authorized_worker_keys

Now we need to create a concourse user that our web server will run as and give it permissions to our /etc/concourse directory.

adduser --system --group concourse
chgrp concourse /etc/concourse/*
chmod g+r /etc/concourse/*

Next, we need to create our SystemD service definition file.

Create /etc/systemd/system/concourse_web.service and add the following contents:

[Unit]
Description=Concourse CI Web
After=postgres.service
 
[Service]
ExecStart=/usr/bin/concourse web  \
  --add-local-user USERNAME:PASSWORD \
  --main-team-local-user USERNAME \
  --session-signing-key /etc/concourse/session_signing_key \
  --tsa-host-key /etc/concourse/host_key \
  --tsa-authorized-keys /etc/concourse/authorized_worker_keys \
  --external-url "http://SERVER_HOSTNAME:8080" \
  --postgres-user=concourse \
  --postgres-password=POSTGRES_PASSWORD
User=concourse
Group=concourse
Type=simple
 
[Install]
WantedBy=default.target

USERNAME is username that you want to use to login to Concourse
PASSWORD is the password you for the above login.
SERVER_HOSTNAME is the hostname of your server.
POSTGRES_PASSWORD is the password you gave the concourse user in postgres.

Save and exit the file.

Now on to configuring the Concourse Worker

Install Concourse Worker

The concourse worker uses the same binary as above.

All we have to do here is create a SystemD service definition.

Create a /etc/systemd/system/concourse_worker.service file and add the following contents.

[Unit]
Description=Concourse CI Worker
After=concourse_web.service
 
[Service]
ExecStart=/usr/bin/concourse worker \
  --work-dir /var/lib/concourse \
  --tsa-host 127.0.0.1:2222 \
  --tsa-public-key /etc/concourse/host_key.pub \
  --tsa-worker-private-key /etc/concourse/worker_key \
  --garden-dns-server 8.8.8.8
 
User=root
Group=root

Type=simple
 
[Install]
WantedBy=default.target

Save and exit the file.

Finishing Up

All that is left is to start our services.

systemctl daemon-reload
systemctl enable concourse_web.service
systemctl enable concourse_worker.service
systemctl start concourse_web.service
systemctl start concourse_worker.service

You should be able to browse to the hostname of your server on port 8080 and see the Concourse UI.

Click on login in the upper-right corner and enter the username and password you specified earlier.

Now you are ready to install the Concouse CLI fly.

First steps with Concourse

The following steps can be performed on your development system.

I am assuming your development system is Ubuntu.  If you are using something different then checkout the concourse home page.

Go back to the Concourse Downloads page and download fly.

wget https://github.com/concourse/concourse/releases/download/v4.2.1/fly_linux_amd64

Rename it and move it to a better place.

mv fly_linux_amd64 fly
mv fly /usr/bin

Login to your concourse server.  In my case the hostname is ci.admintome.lab.

Replace USERNAME and PASSWORD with the username and password you created earlier.

fly -t tutorial login --concourse-url http://ci.admintome.lab:8080 -u USERNAME -p PASSWORD

You should see that it logs in.

logging in to team 'main'


target saved

Create a new file called hello.yaml and add the following contents:

---
platform: linux

image_resource:
  type: docker-image
  source: {repository: busybox}

run:
  path: echo
  args: [hello world]

Save the file and exit.

We just created a task in concourse.

Now run the task using this command.

$ fly -t tutorial execute -c hello.yml 
executing build 6 at http://ci.admintome.lab:8080/builds/6 
initializing
waiting for docker to come up...
Pulling busybox@sha256:2a03a6059f21e150ae84b0973863609494aad70f0a80eaeb64bddd8d92465812...
sha256:2a03a6059f21e150ae84b0973863609494aad70f0a80eaeb64bddd8d92465812: Pulling from library/busybox
90e01955edcd: Pulling fs layer
90e01955edcd: Verifying Checksum
90e01955edcd: Download complete
90e01955edcd: Pull complete
Digest: sha256:2a03a6059f21e150ae84b0973863609494aad70f0a80eaeb64bddd8d92465812
Status: Downloaded newer image for busybox@sha256:2a03a6059f21e150ae84b0973863609494aad70f0a80eaeb64bddd8d92465812

Successfully pulled busybox@sha256:2a03a6059f21e150ae84b0973863609494aad70f0a80eaeb64bddd8d92465812.

running echo hello world
hello world
succeeded

If you go to the link at the beginning of the output you will see the GUI representation of the task.

Congrats you now have a dedicated Concourse-CI server on Ubuntu 18.04.

There is still a ton more to learn so checkout the awesome Concourse Tutorial.

Conclusion

I hope you have enjoyed this article.

If you did then please share and comment below.

The post Install Concourse-CI on Ubuntu 18.04 appeared first on AdminTome Blog.



This post first appeared on AdminTome, please read the originial post: here

Share the post

Install Concourse-CI on Ubuntu 18.04

×

Subscribe to Admintome

Get updates delivered right to your inbox!

Thank you for your subscription

×