Last active
August 1, 2022 17:30
-
-
Save aman207/21d35d98635a40ce642164dd3e539150 to your computer and use it in GitHub Desktop.
mealie-next ansible playbook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
remote_user: onionadmin | |
become: true | |
gather_facts: no | |
tasks: | |
- name: install nodejs LTS (v16) repo | |
shell: | |
cmd: 'curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -' | |
creates: /etc/apt/sources.list.d/nodesource.list | |
warn: false | |
- name: add caddy gpg key | |
apt_key: | |
url: https://dl.cloudsmith.io/public/caddy/stable/gpg.key | |
state: present | |
- name: add caddy repo | |
apt_repository: | |
repo: "deb https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main" | |
state: present | |
filename: caddy-stable | |
- name: add caddy-src repo | |
apt_repository: | |
repo: "deb-src https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main" | |
state: present | |
filename: caddy-stable-src | |
- name: add deadsnakes/ppa | |
apt_repository: | |
repo: 'ppa:deadsnakes/ppa' | |
- name: install required packages | |
apt: | |
name: | |
- python3.10 | |
- python3.10-dev | |
- python3.10-venv | |
- nodejs | |
- pip | |
- build-essential | |
- libpq-dev | |
- libwebp-dev | |
- libsasl2-dev | |
- libldap2-dev | |
- libssl-dev | |
- gnupg | |
- gnupg2 | |
- gnupg1 | |
- debian-keyring | |
- debian-archive-keyring | |
- apt-transport-https | |
- caddy | |
- acl | |
- git | |
state: latest | |
update_cache: yes | |
- name: upgrade pip | |
pip: | |
name: pip | |
state: latest | |
- name: install poetry via pip | |
pip: | |
name: poetry==1.1.6 | |
state: latest | |
- name: install yarn | |
npm: | |
name: yarn | |
global: yes | |
state: latest | |
- name: add git safe directory | |
blockinfile: | |
path: /opt/mealie/.git/config | |
block: | | |
[safe] | |
directory = /opt/mealie | |
- name: git clone mealie | |
git: | |
repo: https://github.com/hay-kot/mealie | |
dest: /opt/mealie | |
force: no | |
ignore_errors: yes | |
- name: git clone crfpp | |
git: | |
repo: https://github.com/mealie-recipes/crfpp | |
dest: /opt/crfpp | |
force: no | |
ignore_errors: yes | |
- name: change mode of /opt/crfpp/docker-build.sh | |
file: | |
path: /opt/crfpp/docker-build.sh | |
mode: 0755 | |
- name: make crfpp | |
shell: | |
cmd: /opt/crfpp/docker-build.sh | |
creates: /usr/local/bin/crf_learn | |
warn: no | |
args: | |
chdir: /opt/crfpp | |
- name: download crfpp model | |
get_url: | |
url: https://github.com/mealie-recipes/nlp-model/releases/download/v1.0.0/model.crfmodel | |
dest: /opt/mealie/mealie/services/parser_services/crfpp/model.crfmodel | |
- name: change permissions of /opt/mealie | |
file: | |
path: /opt/mealie | |
state: directory | |
owner: onionsystem | |
group: onionsystem | |
recurse: yes | |
- name: get latest tag | |
shell: | |
cmd: 'git describe --tags `git rev-list --tags --max-count=1`' | |
args: | |
chdir: /opt/mealie | |
register: latest_tag | |
become_user: onionsystem | |
changed_when: false | |
- name: set fact | |
set_fact: mealie_latest="{{ latest_tag.stdout }}" | |
- name: get current checked-out tag | |
command: | |
cmd: 'git describe --tags --abbrev=0 --exact-match' | |
args: | |
chdir: /opt/mealie | |
register: current_tag | |
become_user: onionsystem | |
failed_when: false | |
changed_when: false | |
- name: checkout to tag | |
command: | |
cmd: 'git checkout {{ mealie_latest }}' | |
args: | |
chdir: /opt/mealie | |
when: current_tag.stdout | string not in mealie_latest | |
become_user: onionsystem | |
- name: create /opt/mealie/data | |
file: | |
name: /opt/mealie/data | |
state: directory | |
owner: onionsystem | |
group: onionsystem | |
- name: replace DATA_DIR in mealie/core/config.py | |
replace: | |
path: /opt/mealie/mealie/core/config.py | |
regexp: 'return Path\("\/app\/data"\)' | |
replace: 'return Path("/opt/mealie/data")' | |
become_user: onionsystem | |
- name: install yarn dependencies | |
community.general.yarn: | |
path: /opt/mealie/frontend | |
become_user: onionsystem | |
- name: run yarn build | |
command: | |
cmd: yarn build | |
args: | |
chdir: /opt/mealie/frontend | |
become_user: onionsystem | |
- name: remove /opt/mealie/frontend/node_modules | |
file: | |
path: /opt/mealie/frontend/node_modules | |
state: absent | |
- name: install production yarn dependencies | |
community.general.yarn: | |
path: /opt/mealie/frontend | |
production: yes | |
become_user: onionsystem | |
- name: copy .env files | |
copy: | |
src: templates/mealie-next/opt/mealie/{{ item }} | |
dest: /opt/mealie/{{ item }} | |
owner: onionsystem | |
group: onionsystem | |
with_items: | |
- .env | |
- frontend/.env | |
- name: initalize the database | |
command: | |
cmd: /usr/local/bin/poetry run python mealie/db/init_db.py | |
args: | |
chdir: /opt/mealie | |
become_user: onionsystem | |
register: initdb_output | |
changed_when: not initdb_output.stdout | regex_search("Database exists") | |
- name: copy Caddyfile to /etc/caddy/Caddyfile | |
copy: | |
src: templates/mealie-next/etc/caddy/Caddyfile | |
dest: /etc/caddy/Caddyfile | |
notify: restart caddy | |
- name: start caddy | |
systemd: | |
name: caddy | |
state: started | |
enabled: yes | |
- name: copy service files | |
copy: | |
src: templates/mealie-next/etc/systemd/system/ | |
dest: /etc/systemd/system/ | |
owner: root | |
group: root | |
notify: | |
- restart mealie-api | |
- restart mealie-frontend | |
- name: start and enable mealie-api.service | |
systemd: | |
name: mealie-api.service | |
state: started | |
enabled: yes | |
- name: start and enable mealie-frontend.service | |
systemd: | |
name: mealie-frontend.service | |
state: started | |
enabled: yes | |
- name: copy update-mealie.sh | |
copy: | |
src: templates/mealie-next/home/onionadmin/update-mealie.sh | |
dest: /home/onionadmin/update-mealie.sh | |
owner: onionadmin | |
group: onionadmin | |
mode: 0744 | |
handlers: | |
- name: restart caddy | |
systemd: | |
name: caddy | |
state: restarted | |
- name: restart mealie-api | |
systemd: | |
name: mealie-api.service | |
state: restarted | |
daemon_reload: yes | |
- name: restart mealie-frontend | |
systemd: | |
name: mealie-frontend.service | |
state: restarted | |
daemon_reload: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
auto_https off | |
admin off | |
} | |
:3000 { | |
@apidocs path /docs /openapi.json | |
@static { | |
file | |
path *.ico *.css *.js *.gif *.jpg *.jpeg *.png *.svg *.woff *.woff2 *.webp | |
} | |
encode gzip zstd | |
# Handles Recipe Images / Assets | |
handle_path /api/media/recipes/* { | |
header @static Cache-Control max-age=31536000 | |
root * /opt/mealie/data/recipes/ | |
file_server | |
} | |
# Handles User Images | |
handle_path /api/media/users/* { | |
header @static Cache-Control max-age=31536000 | |
root * /opt/mealie/data/users/ | |
file_server | |
} | |
# Handle Docker Volume Validation File | |
handle_path /api/media/docker/* { | |
root * /opt/mealie/data/docker-validation/ | |
file_server | |
} | |
handle @apidocs { | |
uri strip_suffix / | |
reverse_proxy http://localhost:9000 | |
} | |
handle { | |
uri strip_suffix / | |
reverse_proxy http://localhost:3001 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Mealie API | |
After=network.target | |
Before=mealie-frontend.service | |
[Service] | |
User=onionsystem | |
Group=onionsystem | |
WorkingDirectory=/opt/mealie | |
ExecStart=/usr/local/bin/poetry run gunicorn mealie.app:app -b 0.0.0.0:9000 -k uvicorn.workers.UvicornWorker -c /opt/mealie/gunicorn_conf.py --preload | |
SyslogIdentifier=mealie-api | |
[Install] | |
WantedBy=default.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Mealie Frontend | |
After=network.target | |
After=mealie-api.service | |
[Service] | |
User=onionsystem | |
Group=onionsystem | |
WorkingDirectory=/opt/mealie/frontend | |
ExecStart=/usr/bin/yarn start -p 3001 | |
SyslogIdentifier=mealie-frontend | |
[Install] | |
WantedBy=default.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This file goes in /opt/mealie/ | |
# The Default Group Assigned to All Users | |
DEFAULT_GROUP=Home | |
# The Default Credentials for the Super User | |
DEFAULT_EMAIL=ananonion@gmail.com | |
DEFAULT_PASSWORD=password | |
BASE_URL=https://mealie-next.aman207.net | |
# Determines Production Mode, This will set the directory path to use for data storage | |
PRODUCTION=True | |
# API Port for Python Server | |
API_PORT=9000 | |
# Exposes /docs and /redoc on the server | |
API_DOCS=True | |
# Sets the Database type to use. Note that in order for Postgres URI to be created, you must set DB_ENGINE=postgres | |
DB_ENGINE=sqlite # Optional: 'sqlite', 'postgres' | |
TOKEN_TIME=43800 | |
LANG=en-US | |
TZ=America/Edmonton | |
# NOT USED | |
# SMTP_HOST="" | |
# SMTP_PORT="" | |
# SMTP_FROM_NAME="" | |
# SMTP_AUTH_STRATEGY="" # Options: 'TLS', 'SSL', 'NONE' | |
# SMTP_FROM_EMAIL="" | |
# SMTP_USER="" | |
# SMTP_PASSWORD="" | |
# Configuration for authentication via an external LDAP server | |
LDAP_AUTH_ENABLED=False | |
LDAP_SERVER_URL=None | |
LDAP_BIND_TEMPLATE=None | |
LDAP_ADMIN_FILTER=None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This file goes in /opt/mealie/frontend/ | |
GLOBAL_MIDDLEWARE=null | |
BASE_URL = "" | |
ALLOW_SIGNUP=false | |
# ===================================== | |
# Light Mode Config | |
THEME_LIGHT_PRIMARY=#E58325 | |
THEME_LIGHT_ACCENT=#007A99 | |
THEME_LIGHT_SECONDARY=#973542 | |
THEME_LIGHT_SUCCESS=#43A047 | |
THEME_LIGHT_INFO=#1976D2 | |
THEME_LIGHT_WARNING=#FF6D00 | |
THEME_LIGHT_ERROR=#EF5350 | |
# ===================================== | |
# Light Mode Config | |
THEME_DARK_PRIMARY=#E58325 | |
THEME_DARK_ACCENT=#007A99 | |
THEME_DARK_SECONDARY=#973542 | |
THEME_DARK_SUCCESS=#43A047 | |
THEME_DARK_INFO=#1976D2 | |
THEME_DARK_WARNING=#FF6D00 | |
THEME_DARK_ERROR=#EF5350 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment