Added nats

This commit is contained in:
tanshu committed 2026-08-29 12:31:09 +00:00
1 parent 399f5c7a6a
commit fabe4bfcfb
3 files changed
+66

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
---
- hosts: clair
become: true
vars_files:
- vars/default.yml
tasks:
- name: Pull default nats image
docker_image:
name: "{{ container_image }}"
source: pull
force_source: yes
- name: Ensure NATS data directory exists
file:
path: "{{ data_location }}"
state: directory
mode: 0755
- name: Create nats container with JetStream enabled
docker_container:
name: "{{ container_name }}"
image: "{{ container_image }}"
state: started
restart_policy: "unless-stopped"
command: "--jetstream --store_dir /data --http_port 8222"
volumes:
- "{{ data_location }}:/data"
published_ports:
- "127.0.0.1:4222:4222"
- "127.0.0.1:8222:8222"
+31
View File
@@ -0,0 +1,31 @@
# NATS with JetStream
This playbook will set up a NATS server with JetStream enabled using Docker.
## Settings
- `container_name`: name of the NATS container.
- `container_image`: image to use for the NATS container.
- `data_location`: host path for persistent data directory (default: `/var/lib/nats`).
## Running this Playbook
### 1. Customize Options
```shell
nano vars/default.yml
```
```yml
#vars/default.yml
---
container_name: nats
container_image: nats:latest
data_location: /var/lib/nats
```
### 2. Run the Playbook
```command
ansible-playbook -l [target] -i [inventory file] -u [remote user] playbook.yml
```
+4
View File
@@ -0,0 +1,4 @@
---
container_name: nats
container_image: nats:latest
data_location: /var/lib/nats