Concourse CI


Concourse CI Install

 

$sudo dnf install postgresql postgresql-server postgresql-contrib  -y 

$sudo postgresql-setup initdb 

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

$ sudo adduser --system --group concourse 
 
$ sudo chown -R concourse:concourse /etc/concourse 
 
$ sudo chmod 600 /etc/concourse/*_environment 

Download concourse and unzip copy the concourse file to /usr/local 

Download fly to /usr/local

Generate keys


concourse generate-key -t rsa -f  /etc/concourse/session_signing_key 
concourse generate-key -t ssh -f  /etc/concourse/tsa_host_key 
concourse generate-key -t ssh -f  /etc/concourse/worker_key 

cp worker_key.pub authorized_worker_keys 

$ vim /etc/concourse/web_environment # add below using vim 

CONCOURSE_SESSION_SIGNING_KEY=/etc/concourse/session_signing_key 
CONCOURSE_TSA_HOST_KEY=/etc/concourse/tsa_host_key 
CONCOURSE_TSA_AUTHORIZED_KEYS=/etc/concourse/authorized_worker_keys 
CONCOURSE_POSTGRES_SOCKET=/var/run/postgresql 
CONCOURSE_ADD_LOCAL_USER=admin:admin
CONCOURSE_MAIN_TEAM_LOCAL_USER=admin 
CONCOURSE_BASIC_AUTH_USERNAME=admin 
CONCOURSE_BASIC_AUTH_PASSWORD=admin 
CONCOURSE_EXTERNAL_URL=http://127.0.0.1:8080 

 
$ vim /etc/concourse/worker_environment # add below using vim 

CONCOURSE_WORK_DIR=/var/lib/concourse 
CONCOURSE_TSA_WORKER_PRIVATE_KEY=/etc/concourse/worker_key 
CONCOURSE_TSA_PUBLIC_KEY=/etc/concourse/tsa_host_key.pub 
CONCOURSE_TSA_HOST=127.0.0.1:2222 
CONCOURSE_GARDEN_DNS_SERVER=8.8.8.8 

Create SystemD unit files for web and worker in /etc/systemd/system/


$ vim /etc/systemd/system/concourse-web.service  
[Unit] 
Description=Concourse CI web process (ATC and TSA) 
After=postgresql.service 
[Service] 
User=concourse 
Restart=on-failure 
EnvironmentFile=/etc/concourse/web_environment 
ExecStart=/usr/local/concourse/bin/concourse web 
[Install] 
WantedBy=multi-user.target 
 
Then the SystemD Unit File for the Worker Service: 
$ vim /etc/systemd/system/concourse-worker.service  
[Unit] 
Description=Concourse CI worker process 
After=concourse-web.service 
[Service] 
User=root 
Restart=on-failure 
EnvironmentFile=/etc/concourse/worker_environment 
ExecStart=/usr/local/concourse/bin/concourse worker 
[Install] 
WantedBy=multi-user.target 
 

Before running Concourse prepare iptables so that it will forward the containers traffic, otherwise the worker will not be able to pull from docker hub


sudo iptables -P FORWARD ACCEPT 
sudo systemctl start concourse.web
sudo systemctl start concourse.worker

Fly commands


fly –t ci login –c http://localhost:8080  -u admin –p admin 
fly -t ci set-pipeline -p test -c hello-world.yml 
fly -t ci unpause-pipeline -p test 
fly -t ci trigger-job --job test/my-job 
fly -t ci trigger-job --job test/my-job –watch 
fly-t ci destroy-pipeline –p test