Skip to content

Commit d45fd3e

Browse files
authored
Merge pull request #2 from 33Fraise33/feature/add-dawarich-role
Feature/add dawarich role
2 parents d35e191 + 5643e37 commit d45fd3e

24 files changed

Lines changed: 555 additions & 4 deletions

File tree

.ansible-lint

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
profile: production
3+
skip_list:
4+
- fqcn[action-core]
5+
- jinja[spacing]
6+
- name[missing]
7+
- no-handler
8+
- package-latest
9+
- var-naming[no-role-prefix]
10+
- yaml
11+
exclude_paths:
12+
- .ansible/
13+
- .venv/

.github/workflows/ansible.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: Ansible validation
3+
4+
on:
5+
pull_request: true
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
validate:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.x'
18+
- name: Install Ansible tooling
19+
run: python -m pip install --requirement requirements.txt molecule molecule-docker
20+
- name: Install Ansible collections
21+
run: ansible-galaxy collection install --requirements-file requirements.yml
22+
- name: Lint YAML
23+
run: yamllint .
24+
- name: Lint Ansible
25+
run: ansible-lint
26+
- name: Syntax check Dawarich playbook
27+
run: ansible-playbook --syntax-check playbooks/dawarich.yml
28+
- name: Test Dawarich role
29+
env:
30+
ANSIBLE_ALLOW_BROKEN_CONDITIONALS: 'true'
31+
run: molecule test --scenario-name dawarich

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
*.pem
22
.venv/
33
.ansible
4+
__pycache__/
5+
*.py[cod]

.yamllint

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
extends: relaxed
3+
rules:
4+
comments:
5+
min-spaces-from-content: 1
6+
empty-lines:
7+
level: warning
8+
line-length: disable
9+
new-line-at-end-of-file:
10+
level: warning
11+
new-lines: disable
12+
octal-values:
13+
forbid-explicit-octal: true
14+
forbid-implicit-octal: true
15+
trailing-spaces:
16+
level: warning

AGENTS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@
2626
- New roles use the Galaxy layout: `defaults/main.yml`, `tasks/main.yml`, `handlers/main.yml`, `templates/`, `meta/main.yml`, and `README.md`. Put configurable image tags and ports in `defaults`; use `tasks/main.yml` to compose task files.
2727
- Use `community.docker` modules for Docker containers, networks, and volumes instead of raw Docker shell commands. Make tasks idempotent and declare container state, restart policy, and other intended configuration explicitly.
2828
- Keep secrets, passwords, and API keys in variables for Vault or CI injection, never literals. Generate container config with `.j2` templates and bind-mount it into the container.
29+
- Prefer sane non-critical defaults with Jinja's `default` modifier instead of populating `defaults/main.yml` broadly. Only define critical variables in `defaults/main.yml`; values such as a database name or role-specific username may safely default to the role name, but passwords and other secrets must always be provided explicitly.
30+
- Prefer application image versions in this order: first, use a major version tag such as `v3` where possible and configure WUD to update within that major version, preventing beta or other incompatible releases; second, use the `latest` tag without setting WUD configuration on the container; third, use a fixed image version tag only when explicitly requested by the owner.
2931

3032
## Testing And CI
3133

3234
- New roles must include Molecule scaffolding using the Docker driver (`molecule init scenario -d docker`). Its scenario must converge the role, verify idempotency, and assert that the managed container is running and correctly configured.
35+
- Molecule scenarios must pause after convergence so the agent can inspect the deployed containers' logs for runtime errors and warnings. A container being running or reporting healthy is not sufficient; investigate and address warnings as well as failures before considering the scenario successful.
36+
- Where possible, Molecule scenarios must include basic application-level tests in addition to idempotency and container configuration checks.
37+
- During local Molecule debugging, temporarily override container `state: healthy` with `state: started` so convergence returns quickly and container logs can be inspected before adapting the role. Restore health-state assertions before merging.
3338
- Run `yamllint` and `ansible-lint` for changed Ansible and YAML files; use two-space YAML indentation and no trailing whitespace.
3439
- CI changes must lint modified roles, run `ansible-playbook --syntax-check` for playbooks using the modified role, and run `molecule test` in an ephemeral environment. Require a green pipeline before merging to `master`.
3540
- Since no CI configuration exists, add the required pipeline configuration as part of feature work that introduces or changes a role.

molecule/dawarich/cleanup.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
- name: Cleanup Dawarich test dependencies
3+
hosts: localhost
4+
gather_facts: false
5+
tasks:
6+
- name: Remove Dawarich test containers
7+
community.docker.docker_container:
8+
name: "{{ item }}"
9+
state: absent
10+
loop:
11+
- dawarich_app
12+
- dawarich_db
13+
- dawarich_sidekiq
14+
- valkey
15+
16+
- name: Remove Dawarich test network
17+
community.docker.docker_network:
18+
name: molecule-services
19+
state: absent
20+
21+
- name: Remove Dawarich test volumes
22+
community.docker.docker_volume:
23+
name: "{{ item }}"
24+
state: absent
25+
loop:
26+
- data_dawarich_db
27+
- data_dawarich_shared
28+
- data_dawarich_public
29+
- data_dawarich_watched
30+
- data_dawarich_storage

molecule/dawarich/converge.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
- name: Converge Dawarich role
3+
hosts: all
4+
gather_facts: false
5+
vars:
6+
dawarich_database_password: molecule-dawarich-password
7+
dawarich_secret_key_base: molecule-dawarich-secret-key
8+
authelia_oidc_clients:
9+
dawarich:
10+
client_id: dawarich
11+
client_secret: molecule-dawarich-client-secret
12+
dawarich_container_state: "{{ lookup('env', 'DAWARICH_CONTAINER_STATE') | default('healthy', true) }}"
13+
dawarich_postgres_image: imresamu/postgis
14+
dawarich_services_network: molecule-services
15+
dawarich_dns_servers: []
16+
roles:
17+
- role: dawarich

molecule/dawarich/molecule.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
driver:
3+
name: docker
4+
5+
scenario:
6+
test_sequence:
7+
- destroy
8+
- syntax
9+
- create
10+
- prepare
11+
- converge
12+
- idempotence
13+
- verify
14+
- cleanup
15+
- destroy
16+
17+
platforms:
18+
- name: dawarich-instance
19+
image: geerlingguy/docker-debian12-ansible:latest
20+
pre_build_image: true
21+
privileged: true
22+
volumes:
23+
- /var/run/docker.sock:/var/run/docker.sock
24+
25+
provisioner:
26+
name: ansible
27+
playbooks:
28+
prepare: prepare.yml
29+
inventory:
30+
host_vars:
31+
dawarich-instance:
32+
ansible_python_interpreter: /usr/bin/python3
33+
34+
verifier:
35+
name: ansible

molecule/dawarich/prepare.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
- name: Prepare Dawarich dependencies
3+
hosts: all
4+
gather_facts: false
5+
become: true
6+
vars:
7+
molecule_services_network: molecule-services
8+
tasks:
9+
- name: Install Docker SDK dependencies
10+
ansible.builtin.apt:
11+
name:
12+
- python3-docker
13+
- python3-requests
14+
state: present
15+
update_cache: true
16+
17+
- name: Create shared services network
18+
community.docker.docker_network:
19+
name: "{{ molecule_services_network }}"
20+
21+
- name: Start shared Valkey
22+
community.docker.docker_container:
23+
name: valkey
24+
image: ghcr.io/valkey-io/valkey:alpine
25+
networks:
26+
- name: "{{ molecule_services_network }}"
27+
state: started

molecule/dawarich/verify.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
- name: Verify Dawarich deployment
3+
hosts: all
4+
gather_facts: false
5+
vars:
6+
dawarich_container_state: "{{ lookup('env', 'DAWARICH_CONTAINER_STATE') | default('healthy', true) }}"
7+
tasks:
8+
- name: Inspect Dawarich containers
9+
community.docker.docker_container_info:
10+
name: "{{ item }}"
11+
loop:
12+
- dawarich_db
13+
- dawarich_app
14+
- dawarich_sidekiq
15+
register: dawarich_containers
16+
17+
- name: Assert Dawarich containers are running
18+
ansible.builtin.assert:
19+
that:
20+
- item.container.State.Status == 'running'
21+
- >-
22+
dawarich_container_state == 'started' or
23+
item.container.State.Health.Status == 'healthy'
24+
loop: "{{ dawarich_containers.results }}"
25+
26+
- name: Inspect shared Valkey
27+
community.docker.docker_container_info:
28+
name: valkey
29+
register: valkey_container
30+
31+
- name: Assert shared Valkey is running
32+
ansible.builtin.assert:
33+
that: valkey_container.container.State.Status == 'running'

0 commit comments

Comments
 (0)