diff --git a/ansible/main.yml b/ansible/main.yml index 9375cee..fe175eb 100644 --- a/ansible/main.yml +++ b/ansible/main.yml @@ -23,3 +23,5 @@ - lidarr - webtrees - slskd + - name: barassistant + tags: test diff --git a/ansible/roles/barassistant/files/nginx.conf b/ansible/roles/barassistant/files/nginx.conf new file mode 100644 index 0000000..2df22c8 --- /dev/null +++ b/ansible/roles/barassistant/files/nginx.conf @@ -0,0 +1,22 @@ +server { + listen 3000 default_server; + listen [::]:3000 default_server; + server_name _; + + location = /favicon.ico { access_log off; log_not_found off; } + location = /robots.txt { access_log off; log_not_found off; } + + client_max_body_size 100M; + + location /bar/ { + proxy_pass http://bar-assistant:3000/; + } + + location /search/ { + proxy_pass http://meilisearch:7700/; + } + + location / { + proxy_pass http://salt-rim:8080/; + } +} diff --git a/ansible/roles/barassistant/tasks/main.yml b/ansible/roles/barassistant/tasks/main.yml new file mode 100644 index 0000000..25dd3a4 --- /dev/null +++ b/ansible/roles/barassistant/tasks/main.yml @@ -0,0 +1,36 @@ +- name: Create service user + user: + name: "{{ role_name }}" + system: true + register: service_user + become: true + +- name: Create install directory + file: + path: "{{ install_directory }}/{{ role_name }}" + state: directory + owner: "{{ docker_user }}" + mode: "{{ docker_compose_directory_mask }}" + become: true + +- name: Copy docker-compose file to destination + template: + src: docker-compose.yml + dest: "{{ install_directory }}/{{ role_name }}/docker-compose.yml" + owner: "{{ docker_user }}" + mode: "{{ docker_compose_file_mask }}" + validate: docker-compose -f %s config + become: true + +- name: Copy nginx.conf to destination + copy: + src: nginx.conf + dest: "{{ install_directory }}/{{ role_name }}/nginx.conf" + mode: "{{ docker_compose_file_mask }}" + become: true + +- name: Start docker container + community.docker.docker_compose: + project_src: "{{ install_directory }}/{{ role_name }}" + pull: true + remove_orphans: yes diff --git a/ansible/roles/barassistant/templates/docker-compose.yml b/ansible/roles/barassistant/templates/docker-compose.yml new file mode 100644 index 0000000..278d5c3 --- /dev/null +++ b/ansible/roles/barassistant/templates/docker-compose.yml @@ -0,0 +1,59 @@ +version: "{{ docker_compose_version }}" + +networks: + traefik: + external: true + +services: + meilisearch: + image: getmeili/meilisearch:v1.0 + restart: unless-stopped + environment: + MEILI_MASTER_KEY: "{{ meili_master_key }}" + volumes: + - "{{ data_dir }}/barassistant/meilisearch:/meili_data" + + redis: + image: redis + restart: unless-stopped + environment: + ALLOW_EMPTY_PASSWORD: "True" + + bar-assistant: + image: barassistant/server:latest + restart: unless-stopped + depends_on: + - meilisearch + - redis + environment: + APP_URL: "{{ base_url }}/bar" + LOG_CHANNEL: stderr + MEILISEARCH_KEY: "{{ meili_master_key }}" + MEILISEARCH_HOST: http://meilisearch:7700 + REDIS_HOST: redis + ALLOW_REGISTRATION: "True" + volumes: + - "{{ data_dir }}/barassistant/barassistant:/var/www/cocktails/storage/bar-assisant" + + salt-rim: + image: barassistant/salt-rim:latest + restart: unless-stopped + depends_on: + - bar-assistant + environment: + API_URL: "{{ base_url }}/bar" + MEILISEARCH_URL: "{{ base_url }}/search" + BAR_NAME: "COCKTAILING" + DESCRIPTION: Mike's Drinking Time + DEFAULT_LOCALE: "en-US" + + webserver: + image: nginx:alpine + restart: unless-stopped + networks: + - traefik + volumes: + - "./nginx.conf:/etc/nginx/conf.d/default.conf" + labels: + traefik.enable: true + traefik.http.routers.barassistant.rule: "Host(`{{ base_url }}`)" diff --git a/ansible/roles/barassistant/vars/main.yml b/ansible/roles/barassistant/vars/main.yml new file mode 100644 index 0000000..c8818ed --- /dev/null +++ b/ansible/roles/barassistant/vars/main.yml @@ -0,0 +1,14 @@ +meili_master_key: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 66653139646366636164313265353866363563346634333562303133653665336163643830353562 + 3465396463663966613161343533333737316133666333610a326139393538376537373437383233 + 39333664346531643033666130623539666539393163313561616135656331323365636361623063 + 6231313866303462310a363831363561656563646538633637656531306162623836343831623162 + 39383161323239376531663435323332393161653431393836663366623835313764663065383365 + 36363866386636366538393835623563383134383162393866306437623865623338336165363239 + 34306237636231336165376236653135356164653638316465626462366562313535613631633861 + 65643763353836343462336133386631633636626264613664356130306233346263323034646633 + 61303761323165343662383861663234383965303134663664613033653037323432623162363865 + 3362613133326163663764373365353732343030626165616536 + +base_url: "cocktails.{{ personal_domain }}"