Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions nas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@
tags:
- cloudflare_ddns

- role: couchdb
tags:
- couchdb

- role: code-server
tags:
- code-server
Expand Down
22 changes: 22 additions & 0 deletions roles/couchdb/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
couchdb_enabled: false
couchdb_available_externally: false

# Data directory for config and data directories
couchdb_data_directory: "{{ docker_home }}/couchdb"

# CouchDB local admin user
couchdb_admin_user: "admin"
couchdb_admin_password: "changeme"

# network
couchdb_hostname: "couchdb"
couchdb_port: "5984"

# specs
couchdb_memory: 1024MB

# docker
couchdb_container_name: "couchdb"
couchdb_image_name: "couchdb"
couchdb_image_version: "latest"
6 changes: 6 additions & 0 deletions roles/couchdb/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
couchdb_enabled: true
10 changes: 10 additions & 0 deletions roles/couchdb/molecule/default/side_effect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Stop
hosts: all
become: true
tasks:
- name: "Include {{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }} role"
ansible.builtin.include_role:
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
vars:
couchdb_enabled: false
18 changes: 18 additions & 0 deletions roles/couchdb/molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Get container state
community.docker.docker_container_info:
name: "{{ couchdb_container_name }}"
register: result

- name: Check CouchDB is running
ansible.builtin.assert:
that:
- result.container['State']['Status'] == "running"
- result.container['State']['Restarting'] == false
18 changes: 18 additions & 0 deletions roles/couchdb/molecule/default/verify_stopped.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Stop and remove CouchDB
community.docker.docker_container:
name: "{{ couchdb_container_name }}"
state: absent
register: result

- name: Check CouchDB is stopped
ansible.builtin.assert:
that:
- not result.changed
42 changes: 42 additions & 0 deletions roles/couchdb/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
- name: Start CouchDB
block:
- name: Create CouchDB Directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
with_items:
- "{{ couchdb_data_directory }}/config"
- "{{ couchdb_data_directory }}/data"

- name: CouchDB Container
community.docker.docker_container:
name: "{{ couchdb_container_name }}"
image: "{{ couchdb_image_name }}:{{ couchdb_image_version }}"
pull: true
env:
COUCHDB_USER: "{{ couchdb_admin_user }}"
COUCHDB_PASSWORD: "{{ couchdb_admin_password }}"
ports:
- "{{ couchdb_port }}:5984"
volumes:
- "{{ couchdb_data_directory }}/config:/opt/couchdb/etc/local.d"
- "{{ couchdb_data_directory }}/data:/opt/couchdb/data"
restart_policy: unless-stopped
memory: "{{ couchdb_memory }}"
labels:
traefik.enable: "{{ couchdb_available_externally | string }}"
traefik.http.routers.couchdb.rule: "Host(`{{ couchdb_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.couchdb.tls.certresolver: "letsencrypt"
traefik.http.routers.couchdb.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.couchdb.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.couchdb.loadbalancer.server.port: "5984"
when: couchdb_enabled is true

- name: Stop CouchDB
block:
- name: Stop CouchDB
community.docker.docker_container:
name: "{{ couchdb_container_name }}"
state: absent
when: couchdb_enabled is false
26 changes: 26 additions & 0 deletions website/docs/applications/other/couchdb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: "CouchDB"
---

Homepage: [https://couchdb.apache.org/](https://couchdb.apache.org/)

Apache CouchDB is an open-source, document-oriented NoSQL database, implemented in Erlang.

CouchDB uses multiple formats and protocols to store, transfer, and process its data. It uses JSON to store data, JavaScript as its query language using MapReduce, and HTTP for an API.

## Usage

Set `couchdb_enabled: true` in your `inventories/<your_inventory>/group_vars/nas.yml` file.

Tread carefully.

The CouchDB API can be found at [http://ansible_nas_host_or_ip:5984](http://ansible_nas_host_or_ip:5984). Its web interface, Fauxton, is located at [http://ansible_nas_host_or_ip:5984/_utils](http://ansible_nas_host_or_ip:5984/_utils)

You must specify the default adminstrator username and password, but all other configuration -- **including authentication and authorization** -- is left to either files in the `config` directory or subsequent API calls. Read more about setup and configuration on the [Apache CouchDB documentation](https://docs.couchdb.org/en/stable/index.html) site.

| Parameter | Default |
| --- | --- |
| `couchdb_admin_user` | `admin` |
| `couchdb_admin_password` | `changeme` |

The contents of the `config` directory are mounted to the container's `local.d` directory; see the [Configuration files](https://docs.couchdb.org/en/stable/config/intro.html#configuration-files) documentation.
Loading