Documentation Index

Fetch the complete documentation index at: https://docs.rocket.chat/llms.txt

Use this file to discover all available pages before exploring further.

Ansible

Prev Next

Set up an Ansible environment for deploying Rocket.Chat to multiple servers.

See the Rocket.Chat official Ansible role.

Installation

Ansible works on a push model: your control node pushes configuration and ad hoc tasks to your systems over SSH, with no client software running on the systems you're deploying to. In other words, it's fast, efficient, secure, scalable, and highly portable. To control remote systems, you only need to install Ansible on your control node. Your desktop can serve as the control node you deploy from.

To learn more about Ansible installation on different operating systems, see the official installation guide.

Select the tab for your preferred installation method:

If you're using a UNIX-like operating system, such as Linux or BSD, Ansible is likely available in your official package repositories. Use your package manager to check for the package and install it. For example, on Debian-based systems:

sudo apt install ansible

Ansible is written in Python, so it's also available for installation via pip, Python's package manager. If you have pip installed, run the following command:

sudo pip install ansible

If you don't have pip, check whether you can install it through your system's package manager. If you're on macOS and not using Homebrew or pkgsrc, you can install pip using easy_install:

sudo easy_install pip
sudo pip install ansible

Set up the deployment environment

With Ansible installed on your control node, you can now prepare the environment for deploying Rocket.Chat.

Prerequisites

Before you begin, verify the following:

  • You can access the target server via SSH as the root user.

  • The target server has Python installed and runs one of the following operating systems:

    • EL 7 (RHEL/CentOS)

    • Debian 8 (Jessie) LTS

    • Ubuntu 18.04 LTS

    • Ubuntu 19.04

Support for other operating systems and distributions may be added in future releases of the official Rocket.Chat Ansible role  To request support for a particular OS, raise an issue  in the repository.

Inventory set-up

The inventory file is a plain text file listing the systems you want Ansible to connect to and control. It can contain single hosts, host groups, groups of groups, and variables set for each host or group. To create your inventory:

  1. Create a directory for your Ansible files and navigate to it. The directory can live anywhere on your system, for example, in your home directory or wherever you keep your code and Git repositories:

    mkdir ansible
    cd ansible

    We recommend naming the directory ansible and the inventory file inventory so that your setup matches the commands used in this guide.

  2. Create the inventory file in that directory:

    touch inventory

  3. Open the file and add your servers under a group. The [chat_servers] line defines a group named chat_servers. Any hostnames, FQDNs, or IP addresses listed under it become members of that group. Add the hostname or FQDN of the server you want to deploy Rocket.Chat to:

    [chat_servers]
    chat.my.domain


    To deploy to more than one server, list each of them under the same group:

    [chat_servers]
    chat.my.domain
    talk.my.domain

  4. Configure SSH authentication. We recommend authenticating SSH connections to your servers using SSH key pairs. If you can't use key pairs, you can temporarily provide the root user's password in the inventory file using the ansible_ssh_pass variable:

    [chat_servers]
    chat.my.domain ansible_ssh_pass=<root-password>
    talk.my.domain


    Replace <root-password> with the root user's password for that host.

    Storing a password in plain text in the inventory file is insecure. Use this method only temporarily, and switch to SSH key pairs as soon as possible.

Download the Rocket.Chat Ansible role

Ansible shares and reuses roles through Galaxy. You can download the roles you need with the ansible-galaxy command-line tool, which was installed together with Ansible. To download the Rocket.Chat role:

  1. In your ansible directory, create a roles directory:

    ansible $ mkdir roles

  2. Create a roles/requirements.yml file. This file tells ansible-galaxy how to fetch the role, and its contents depend on the version of Ansible you're running.

    Your title goes here

    Your content goes here

    Update requirements.yml with the following content:

    - src: RocketChat.Server
      version: master

    Update requirements.yml with the following content:

    - src: RocketChat.Server
      version: v2.2.2

  1. Fetch the Rocket.Chat Ansible role using the ansible-galaxy command:

    ansible-galaxy install -p roles/ -r roles/requirements.yml


    This command installs the roles defined in requirements.yml. The RocketChat.Server role is now available in your roles directory. You can verify it:

    ls roles
    RocketChat.Server

Create a playbook for the Rocket.Chat Ansible role

Ansible roles are built from a collection of "plays", that is, tasks or actions to run. To use a role, create a playbook that tells Ansible to run the role on your systems. To create the playbook,

  1. In your ansible directory, create a playbook file named rocket_chat.yml:

    touch rocket_chat.yml

    The .yml extension denotes a YAML document, the format used to express most things in Ansible.

  2. Open the file and add the following content:

    ---
    
      - name: Apply the RocketChat.Server role to all chat_servers
        hosts: chat_servers
    
        roles:
          - RocketChat.Server

This playbook applies the RocketChat.Server role to every host in the chat_servers group you defined in your inventory file.

Deploy Rocket.Chat using Ansible

  1. Run the playbook with the ansible-playbook command:

    ansible-playbook -i inventory rocket_chat.yml

    This command runs the rocket_chat.yml playbook against the hosts listed in your inventory file.

  2. When the deployment completes, go to your server's address, for example, https://chat.my.domain. The Rocket.Chat login screen appears, confirming a successful deployment.