--- title: "Deploy Rocket Chat Securely with Ansible" slug: "ansible" description: "Use Ansible to automate secure Rocket Chat deployments. Simplify setup, scale communication, and ensure reliable collaboration across environments." updated: 2026-10-20T14:57:07Z published: 2026-10-20T14:57:07Z canonical: "docs.rocket.chat/ansible" --- > ## 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 Set up an Ansible environment for deploying Rocket.Chat to multiple servers. > [!NOTE] > See the [Rocket.Chat official Ansible role](https://galaxy.ansible.com/RocketChat/Server#readme). ## 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. > [!WARNING] > **To learn more about Ansible installation on different operating systems, see the** [**official installation guide**](https://docs.ansible.com/ansible/latest/installation_guide/index.html)**.** Select the tab for your preferred installation method: **Package manager** 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: ```bash sudo apt install ansible ``` **pip** 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: ```bash 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](http://brew.sh) or [pkgsrc](https://github.com/cmacrae/saveosx), you can install pip using `easy_install`: ```bash 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 > [!WARNING] > Support for other operating systems and distributions may be added in future releases of the [official Rocket.Chat Ansible role](https://galaxy.ansible.com/RocketChat/Server/#readme) To request support for a particular OS, [raise an issue](https://github.com/RocketChat/Rocket.Chat.Ansible/issues) 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: ```bash mkdir ansible cd ansible ``` > [!NOTE] > 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: ```bash 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: ```bash [chat_servers] chat.my.domain ``` To deploy to more than one server, list each of them under the same group: ```bash [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: ```plaintext [chat_servers] chat.my.domain ansible_ssh_pass= talk.my.domain ``` Replace `<root-password>` with the root user's password for that host. > [!CAUTION] > 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](http://galaxy.ansible.com). 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: ```bash 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. **Ansible 1.9** Update `requirements.yml` with the following content: ```bash - src: RocketChat.Server  version: master ``` **Ansible 2.0** Update `requirements.yml` with the following content: ```bash - src: RocketChat.Server  version: v2.2.2 ``` 1. Fetch the Rocket.Chat Ansible role using the `ansible-galaxy` command: ```bash 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: ```bash 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`: ```bash touch rocket_chat.yml ``` > [!WARNING] > 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: ```yaml ---  - 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: ```bash 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.