diff --git a/group_vars/all.yml b/group_vars/all.yml index dcbb36b..c6a4e2d 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -37,4 +37,16 @@ npm_letsencrypt_dir: "/opt/npm/letsencrypt" heimdall_base_dir: "/opt/heimdall" heimdall_config_dir: "/opt/heimdall/config" -heimdall_port: "45131" \ No newline at end of file +heimdall_port: "45131" + +# Bookstack variables +bookstack_base_dir: "/mnt/bookstack" +bookstack_config_dir: "/mnt/bookstack/config" +bookstack_uploads_dir: "/mnt/bookstack/uploads" +bookstack_db_dir: "/mnt/bookstack/db" +bookstack_port: "45131" + +# Mealie variables +mealie_base_dir: "/mnt/mealie" +mealie_data_dir: "/mnt/mealie/data" +mealie_port: "45132" \ No newline at end of file diff --git a/olimp-deploy.yml b/olimp-deploy.yml index 7688e49..3f9f58f 100644 --- a/olimp-deploy.yml +++ b/olimp-deploy.yml @@ -8,6 +8,12 @@ - hosts: gateway roles: - - { role: docker, tags: [deploy_docker] } - - { role: npm, tags: [deploy_npm] } - - { role: heimdall, tags: [deploy_heimdall] } \ No newline at end of file + - { role: docker, tags: deploy_docker } + - { role: npm, tags: deploy_npm } + - { role: heimdall, tags: deploy_heimdall } + +- hosts: data + roles: + - { role: docker, tags: deploy_docker } + - { role: mealie, tags: deploy_mealie } + - { role: bookstack, tags: deploy_bookstack } \ No newline at end of file diff --git a/roles/bookstack/tasks/main.yml b/roles/bookstack/tasks/main.yml new file mode 100644 index 0000000..8892b72 --- /dev/null +++ b/roles/bookstack/tasks/main.yml @@ -0,0 +1,48 @@ +--- +- name: Create Bookstack directory structure + file: + path: "{{ item }}" + state: directory + mode: 0755 + loop: + - "{{ bookstack_base_dir }}" + - "{{ bookstack_config_dir }}" + - "{{ bookstack_uploads_dir }}" + - "{{ bookstack_db_dir }}" + when: not item.stat.exists + +- name: Check if Bookstack directories exist + assert: + that: + - item.stat.exists + fail_msg: "Directory {{ item.path }} does not exist. Please create it manually." + loop: + - { path: "{{ bookstack_config_dir }}" } + - { path: "{{ bookstack_uploads_dir }}" } + - { path: "{{ bookstack_db_dir }}" } + +- name: Deploy Bookstack docker-compose.yml + template: + src: docker-compose.yml.j2 + dest: "{{ bookstack_base_dir }}/docker-compose.yml" + mode: 0644 + +- name: Start Bookstack services + shell: | + cd {{ bookstack_base_dir }} + docker compose up -d + args: + executable: /bin/bash + +- name: Wait for services to start + pause: + seconds: 15 + +- name: Check Bookstack container status + shell: docker ps --filter name=bookstack-mnemo + register: bookstack_status + changed_when: false + +- name: Show Bookstack status + debug: + var: bookstack_status.stdout \ No newline at end of file diff --git a/roles/bookstack/templates/docker-compose.yml.j2 b/roles/bookstack/templates/docker-compose.yml.j2 new file mode 100644 index 0000000..7dbad84 --- /dev/null +++ b/roles/bookstack/templates/docker-compose.yml.j2 @@ -0,0 +1,36 @@ +version: "3" +services: + bookstack: + image: lscr.io/linuxserver/bookstack:latest + container_name: bookstack-mnemo + environment: + - PUID=1000 + - PGID=1000 + - APP_KEY=base64:eI791ap0I3AbP0Y8Q5Tn4sTZxTUOdWLid2r6pBjfXus= + - APP_URL=https://mnemo.zailon.ru + - DB_HOST=bookstack_db + - DB_USERNAME=bookstack + - DB_PASSWORD=12qwaszx + - DB_DATABASE=bookstackapp + volumes: + - {{ bookstack_config_dir }}:/config + - {{ bookstack_uploads_dir }}:/data + ports: + - "{{ bookstack_port }}:80" + restart: unless-stopped + depends_on: + - bookstack_db + + bookstack_db: + image: lscr.io/linuxserver/mariadb:latest + container_name: bookstack-mnemo-db + environment: + - PUID=1000 + - PGID=1000 + - MYSQL_ROOT_PASSWORD=13qeadZC + - MYSQL_DATABASE=bookstackapp + - MYSQL_USER=bookstack + - MYSQL_PASSWORD=12qwaszx + volumes: + - {{ bookstack_db_dir }}:/config + restart: unless-stopped \ No newline at end of file diff --git a/roles/mealie/tasks/main.yml b/roles/mealie/tasks/main.yml new file mode 100644 index 0000000..e2f3230 --- /dev/null +++ b/roles/mealie/tasks/main.yml @@ -0,0 +1,44 @@ +--- +- name: Create Mealie directory structure + file: + path: "{{ item }}" + state: directory + mode: 0755 + loop: + - "{{ mealie_base_dir }}" + - "{{ mealie_data_dir }}" + when: not item.stat.exists + +- name: Check if Mealie data directory exists + assert: + that: + - item.stat.exists + fail_msg: "Directory {{ item.path }} does not exist. Please create it manually." + loop: + - { path: "{{ mealie_data_dir }}" } + +- name: Deploy Mealie docker-compose.yml + template: + src: docker-compose.yml.j2 + dest: "{{ mealie_base_dir }}/docker-compose.yml" + mode: 0644 + +- name: Start Mealie container + shell: | + cd {{ mealie_base_dir }} + docker compose up -d + args: + executable: /bin/bash + +- name: Wait for Mealie to start + pause: + seconds: 15 + +- name: Check Mealie container status + shell: docker ps --filter name=mealie + register: mealie_status + changed_when: false + +- name: Show Mealie status + debug: + var: mealie_status.stdout \ No newline at end of file diff --git a/roles/mealie/templates/docker-compose.yml.j2 b/roles/mealie/templates/docker-compose.yml.j2 new file mode 100644 index 0000000..ef2fc0f --- /dev/null +++ b/roles/mealie/templates/docker-compose.yml.j2 @@ -0,0 +1,15 @@ +version: '3.8' +services: + mealie: + image: hkotel/mealie:latest + container_name: mealie + restart: unless-stopped + ports: + - "{{ mealie_port }}:80" + volumes: + - {{ mealie_data_dir }}:/app/data + environment: + - PUID=1000 + - PGID=1000 + - TZ={{ timezone }} + - ALLOW_SIGNUP=true \ No newline at end of file