How to Install Rundeck on Ubuntu 20.04

Rundeck is a free open-source software for automation services. It gives self-service access to the processes and tools they need to get their job done. Using Rundeck you can create automation workflows from existing tools or scripts. It provides a web console, CLI tools, and a Web API to run automation tasks.

In this tutorial, we learn how to install the Rundeck community on Ubuntu 20.04.

Pre-requisites

  • A Ubuntu 20.04 instance with atleast 2 CPU
  • 4 GB RAM
  • 20 GB hard disk
  • Java 8 or later
  • A database - MySQL/MariaDB, Oracle or PostgrSQL
  • Log Store for logs that is either the default file system or a S3 compatible object store
  • Ports 4440 (http) and 4443 (https) opened

Step 1: Install Java on Ubuntu

Rundeck requires Java 8 or Java 11 to function properly. If not installed by default install Java using the following commands.

First, update the cache of the repository

$ sudo apt update

Now to install Java 11, run the following command:

$ sudo apt install openjdk-11-jre-headless

You can verify the version:

java -version

Step 2: Install MySQL on Ubuntu

Rundeck supports MySQL, PostgreSQL, Oracle, and MS SQL Server to store its data. In our case, we are going to use MySQL.

To install MySQL on Ubuntu run the following command:

$ sudo apt install mysql-server

Then enable the MySQL service on the startup, type:

$ sudo systemctl enable mysql-server

Now access to the database:

$ mysql -u root -p

Create the Rundeck database and user:

mysql> CREATE DATABASE rundeckdb;
Query OK, 1 row affected (0.00 sec)

mysql> CREATE USER 'rundeck_user'@'localhost' IDENTIFIED BY 'PASSWORD';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'rundeck_user'@'localhost' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
bye

Step 3: Install Rundeck on Ubuntu 20.04

Here we are going to install the Rundeck community version. You can either download the deb package file directly from the website by filling the form or from the official repository.

Here I am going to install from the official repository which always ensures to have the latest version.

To do that, we will first import the repo signing key.

$ curl -L https://packages.rundeck.com/pagerduty/rundeck/gpgkey | sudo apt-key add -

Then let's add the sources list file of Rundeck /etc/apt/sources.list.d/rundeck.list

$ sudo vim /etc/apt/sources.list.d/rundeck.list
deb https://packages.rundeck.com/pagerduty/rundeck/any/ any main
deb-src https://packages.rundeck.com/pagerduty/rundeck/any/ any main

Update the cache of the repository

$ sudo apt update

Now, install Rundeck using apt command, type:

$ sudo apt install rundeck

We need now to tell Rundeck how to connect the database. We will edit its configuration file with some updates. Make sure to replace the lines that are already existing with the good values matching your configuration

$ sudo vim /etc/rundeck/rundeck-config.properties
grails.serverURL=http://YOUR_SERVER_IP:4440
dataSource.driverClassName = org.mariadb.jdbc.Driver
dataSource.url = jdbc:mysql://localhost/rundeckdb?autoReconnect=true&useSSL=false
dataSource.username = rundeck_user
dataSource.password = PASSWORD

If you have installed another database, then some configurations should change.

Now enable the service at the startup

$ sudo systemctl enable rundeckd.service 

Then, start Rundeck service:

$ sudo systemctl start rundeckd.service 

You can check the status

$ sudo systemctl status rundeckd.service 
● rundeckd.service - LSB: rundeck job automation console
     Loaded: loaded (/etc/init.d/rundeckd; generated)
     Active: active (running) since Sat 2021-11-06 01:05:34 UTC; 2s ago
       Docs: man:systemd-sysv-generator(8)
    Process: 229955 ExecStart=/etc/init.d/rundeckd start (code=exited, status=0/SUCCESS)
   Main PID: 229976 (java)
      Tasks: 12 (limit: 2279)
     Memory: 114.7M
     CGroup: /system.slice/rundeckd.service
             └─229976 java -Drundeck.jaaslogin=true -Djava.security.auth.login.config=/etc/rundeck/jaas-loginmodule.conf -Dloginmodule.name=RDpropertyfilelogin -Drdeck.config=/etc/rundeck -Drundeck.server.configDir=/etc/rundeck -D>

Nov 06 01:05:34 li663-64 systemd[1]: Starting LSB: rundeck job automation console...
Nov 06 01:05:34 li663-64 rundeckd[229955]:  * Starting rundeckd
Nov 06 01:05:34 li663-64 rundeckd[229955]:    ...done.
Nov 06 01:05:34 li663-64 systemd[1]: Started LSB: rundeck job automation console.

We should first change the default password of the admin user as the default one is still admin

$ sudo vim /etc/rundeck/realm.properties
admin:NEW_ADMIN_PASSWORD,user,admin,architect,deploy,build

At this point, if you want to check that everything is working, you can try to access Rundeck with the IP and port 4440 but you will need to open it on the firewall before.

As we will use Nginx, we will need to edit some other configurations files in other to modify the URL of Rundeck. We will need to indicate the URL that Nginx will use to access Rundeck. We will first edit the /etc/rundeck/framework.properties configuration file

$ sudo vim /etc/rundeck/framework.properties
framework.server.url = http://rundeck.domain.com

Then we will re-edit the /etc/rundeck/rundeck-config.properties configuration file. It's the one we used to indicate the IP address of the server and the default port but now will put the domain name.

$ sudo vim /etc/rundeck/rundeck-config.properties
grails.serverURL=http://rundeck.websitefortesting.com

Step 4: SSL Terminated Proxy

Here we will use Nginx as a reverse proxy for SSL Termination. This helps Rundeck with SSL/HTTPS support.

Nginx is available in the apt repository, you can simply install using the following command:

$ sudo apt install nginx

Now you need to copy the certificate of your Rundeck domain.

$ sudo cp rundeck.domain.com.crt /etc/nginx/certs/rundeck.domain.com.crt

You need also to copy the key

$ sudo cp rundeck.domain.com.key /etc/nginx/certs/rundeck.domain.com.key

Let's remove the default configuration file to avoid any conflict

$ sudo rm /etc/nginx/sites-enabled/default

Now let's create the configuration file of Rundeck.

$ sudo vim /etc/nginx/sites-available/rundeck.conf
server {
         server_name rundeck.domain.com;
         listen 80 ;
         access_log /var/log/nginx/rundeck.log;
         return 301 https://$host$request_uri;
 }
 server {
         server_name rundeck.domain.com;
         listen 443 ssl http2 ;
         access_log /var/log/nginx/rundeck.log;
         
                     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
         ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
         ssl_prefer_server_ciphers on;
         ssl_certificate /etc/nginx/certs/rundeck.domain.com.crt;
         ssl_certificate_key /etc/nginx/certs/rundeck.domain.com.key;
         add_header Strict-Transport-Security "max-age=31536000";
         
                     location / {
                 proxy_pass http://localhost:4440;
                 proxy_set_header X-Forwarded-Host $host:$server_port;
                 proxy_set_header X-Forwarded-Server $host;
                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         }
 }

Now let's enable the configuration file

$ sudo ln -s /etc/nginx/sites-available/rundeck.conf /etc/nginx/sites-enabled/rundeck.conf

Check the Nginx configuration

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Step 5: Access Rundeck Interface

Now you can go to your browser and access Rundeck with the URL http://rundeck.domain.com

For Rundeck web interface access, the username is admin and the password is the one we edited previously NEW_ADMIN_PASSWORD.

Rundeck login screen

Now you have access to your Rundeck

Rundeck dashboard

You can create a new project to start with your configuration.

Conclusion

In this tutorial, we learned how to install Rundeck community edition on your Ubuntu 20.04 server. You can make some configurations and create a new project in order to start using your Rundeck

Leave a Comment