Deploy Grafana using Ansible-playbook on Ubuntu 22.04 LTS


Grafana is an open-source analytics and visualization platform used to monitor and analyze data from various sources. It provides a flexible and customizable interface for creating and displaying real-time dashboards, graphs, and charts. Grafana supports a wide range of data sources, including databases, time-series databases like Prometheus and InfluxDB, cloud monitoring services, and more.


  • Up and running ubuntu 22.04 LTS machine.
  • Basic knowledge in linux commands.
  • Internet connectivity.
  • Ansible should be installed.

We can use the given link to install Ansible on Ubuntu 22.04 LTS Linux machine.

In this post, We will show you how to deploy Grafana using Ansible-play on ubuntu 22.04 LTS Linux machine.

Step 1: Create an Ansible playbook file

To deploy Grafana using Ansible on Ubuntu 22.04 LTS, you can create an Ansible playbook that installs Grafana and its dependencies. Here’s a simple example playbook to get you started:

To create ansible playbook.

sudo nano deploy_grafana.yml

Paste the following set of tasks.

- name: Deploy Grafana
  hosts: your_target_servers
  become: true

    - name: Update apt package cache
        update_cache: yes

    - name: Install required packages
          - software-properties-common
          - apt-transport-https
          - ca-certificates
          - curl
          - gnupg-agent

    - name: Add Grafana APT GPG key

    - name: Add Grafana APT repository
        repo: deb stable main
        state: present

    - name: Install Grafana
        name: grafana
        state: present

    - name: Start and enable Grafana service
        name: grafana-server
        state: started
        enabled: yes

Replace your_target_servers with the target servers or server group where you want to install Grafana and Save the playbook file.

Step 2: Create an Ansible inventory file

Create an Ansible inventory file (e.g., inventory.ini) with the IP addresses or hostnames of your target servers:

server1 ansible_ssh_host=
server2 ansible_ssh_host=

Replace the IP addresses with your actual server IP addresses.

Step 3: Run the Ansible playbook

We need to execute the following command in order to deploy the Grafana to our target machine.

ansible-playbook -i inventory.ini deploy_grafana.yml

This playbook will update the package cache, install necessary packages, add the Grafana APT GPG key and repository, install Grafana, and start the Grafana service.

Note: This playbook assumes that you have Ansible installed on your local machine and SSH access to the target servers. Additionally, ensure that the servers have internet access to download Grafana and its dependencies during the installation process.


We have successfully deployed Grafana using Ansible Playbook on Ubuntu 22.04 LTS. If you are still having issues, please leave a comment below.


Deploy Grafana using Ansible-playbook on Ubuntu 22.04 LTS

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top