This guide provides a complete Ansible playbook to install Linux-Dash using Docker with proper configuration for server monitoring dashboard with real-time metrics.
Current Linux-Dash version: Latest (Docker image)
Create a file named linux-dash.yml:
---
- name: Install and Configure Linux-Dash
hosts: linux-dash
become: true
vars:
linux_dash_version: "latest"
linux_dash_port: 8080
linux_dash_data_dir: "/opt/linux-dash/data"
tasks:
- name: Create Linux-Dash directories
file:
path: "{{ item }}"
state: directory
owner: root
group: root
mode: '0755'
loop:
- "{{ linux_dash_data_dir }}"
- name: Create Docker Compose file
copy:
dest: "{{ linux_dash_data_dir }}/docker-compose.yml"
owner: root
group: root
mode: '0644'
content: |
version: '3.8'
services:
linux-dash:
image: leonstafford/linux-dash:{{ linux_dash_version }}
container_name: linux-dash
restart: unless-stopped
ports:
- "{{ linux_dash_port }}:80"
volumes:
- /:/host:ro
environment:
- HOST_ROOT=/host
privileged: true
networks:
- linux_dash_net
networks:
linux_dash_net:
driver: bridge
- name: Start Linux-Dash container
community.docker.docker_compose:
project_src: "{{ linux_dash_data_dir }}"
state: present
build: false
pull: true
- name: Wait for Linux-Dash to start
wait_for:
port: "{{ linux_dash_port }}"
delay: 5
timeout: 120
- name: Configure firewall (UFW)
ufw:
rule: allow
port: "{{ linux_dash_port }}"
proto: tcp
comment: "Linux-Dash web interface"
when: ansible_os_family == "Debian"
failed_when: false
- name: Configure firewall (firewalld)
firewalld:
port: "{{ linux_dash_port }}/tcp"
permanent: true
immediate: true
state: enabled
when: ansible_os_family == "RedHat"
failed_when: false
- name: Verify Linux-Dash is running
uri:
url: "http://localhost:{{ linux_dash_port }}/"
method: GET
status_code: 200
register: health_check
retries: 3
delay: 5
until: health_check.status == 200
- name: Display Linux-Dash status
debug:
msg: |
Linux-Dash {{ linux_dash_version }} installed successfully!
Web Interface: http://{{ ansible_default_ipv4.address | default(ansible_host) }}:{{ linux_dash_port }}
Data directory: {{ linux_dash_data_dir }}
---
linux-dash:
hosts:
linux-dash-server:
ansible_host: 192.168.1.125
ansible_user: ansible
ansible_become: true
# Test connectivity
ansible all -i inventory.yml -m ping
# Run the Linux-Dash playbook
ansible-playbook -i inventory.yml linux-dash.yml
# Check container status
ssh linux-dash-server "docker ps | grep linux-dash"
# View container logs
ssh linux-dash-server "docker logs linux-dash"
# Test web interface
curl http://linux-dash-server:8080/
# Access web UI
# http://linux-dash-server:8080
# Check container logs
docker logs linux-dash
# Check container status
docker ps -a | grep linux-dash
# Check host mount
docker exec linux-dash ls -la /host
# Check host filesystem access
docker exec linux-dash cat /host/proc/loadavg
# Verify privileged mode
docker inspect linux-dash | grep Privileged
# Restart container
docker-compose -f /opt/linux-dash/data/docker-compose.yml restart
Beyond this playbook, we offer:
Contact our automation team: office@linux-server-admin.com