Ver código fonte

[wger] Fix role so it runs well

Colin Powell 2 anos atrás
pai
commit
b1b95352c6

+ 4 - 0
lab/ansible/hosts

@@ -45,6 +45,7 @@ tor1.local
 unbound1.local
 vrobbler1.local
 weewx1.local
+wger0.local
 zerobin1.local
 
 [physical]
@@ -147,6 +148,9 @@ pg1-master.local
 [fakemail]
 mailhog0.local
 
+[fit]
+wger0.local
+
 [wx]
 weewx1.local
 

+ 6 - 0
lab/ansible/playbook.yml

@@ -182,6 +182,12 @@
     - role: maloja
     - role: multi-scrobbler
 
+- hosts: fit
+  roles:
+    - role: immortal
+    - role: nginx
+    - role: wger
+
 - hosts: test
   roles:
     - role: direnv

+ 4 - 4
lab/ansible/roles/unbound/files/service.zones

@@ -38,7 +38,7 @@ local-data: "logstash.service   IN      A       192.168.1.191"
 local-data: "excalidraw.service IN      A       192.168.1.202"
 local-data: "ntfy.service       IN      A       192.168.1.204"
 local-data: "metabase.service   IN      A       192.168.1.228"
-local-data: "wger.service       IN      A       192.168.1.115"
+local-data: "wger.service       IN      A       192.168.1.160"
 local-data: "links.service      IN      A       192.168.1.147"
 local-data: "printer.service	IN	    A   	192.168.1.146"
 local-data: "matrix.service     IN      A       192.168.1.106"
@@ -49,6 +49,6 @@ local-data: "mongodb.service    IN      A       192.168.1.131"
 local-data: "prosody.service    IN      A       192.168.1.151"
 local-data: "scrobbler.service  IN      A       192.168.1.156"
 local-data: "calibre.service 	IN      A       192.168.1.113"
-local-data: "devpi.service	IN	A	192.168.1.161"
-local-data: "vrobbler.service	IN	A	192.168.1.123"
-local-data: "fittrackee.service IN	A	192.168.1.234"
+local-data: "devpi.service	    IN   	A    	192.168.1.161"
+local-data: "vrobbler.service	IN   	A   	192.168.1.123"
+local-data: "fittrackee.service IN   	A   	192.168.1.234"

+ 4 - 1
lab/ansible/roles/wger/files/nginx-location.conf

@@ -1,5 +1,8 @@
 location /static {
-         alias /usr/local/src/wger/static;
+         alias /usr/local/www/wger/static;
+}
+location /media {
+         alias /usr/local/www/wger/media;
 }
 location / {
          proxy_pass http://127.0.0.1:8005;

+ 100 - 0
lab/ansible/roles/wger/tasks/main.yml

@@ -0,0 +1,100 @@
+---
+- name: Dependencies installed
+  community.general.pkgng:
+    name: py39-pip,py39-lxml,py39-gunicorn,bash,yarn-node18,git-tiny,npm-node18,rust
+    state: latest
+
+- name: Source folder exists
+  file:
+    path: /usr/local/src
+    owner: root
+    mode: 0755
+    state: directory
+
+- name: Wger source @ master
+  git:
+    repo: "https://github.com/wger-project/wger.git"
+    dest: /usr/local/src/wger
+    update: yes
+    force: yes
+  tags:
+    - update
+
+- name: Wger requirements up to date
+  pip:
+    requirements: /usr/local/src/wger/requirements.txt
+    executable: pip
+
+- name: sass installed
+  shell:
+    cmd: npm install -g sass
+  tags:
+    - update
+
+- name: Wger UI built
+  shell:
+    cmd: yarn && yarn install
+    chdir: /usr/local/src/wger/
+  tags:
+    - update
+
+- name: Wger UI built
+  shell:
+    cmd: yarn build:css:sass
+    chdir: /usr/local/src/wger/
+  tags:
+    - update
+
+- name: Media directory exists
+  file:
+    path: /usr/local/www/wger/static/
+    mode: 0755
+    state: directory
+
+- name: Static directory exists
+  file:
+    path: /usr/local/www/wger/media
+    mode: 0755
+    state: directory
+
+- name: Wger conf file installed
+  template:
+    src: settings.py.j2
+    dest: /usr/local/src/wger/settings.py
+    owner: root
+    mode: 0644
+
+- name: Wger db migrated
+  shell:
+    cmd: python3.9 manage.py migrate
+    chdir: /usr/local/src/wger/
+  tags:
+    - update
+
+- name: Wger static files collected
+  shell:
+    cmd: python3.9 manage.py collectstatic --noinput
+    chdir: /usr/local/src/wger/
+  tags:
+    - update
+
+- name: Wger permissions updated
+  shell:
+    cmd: python3.9 manage.py loaddata groups.json categories.json
+    chdir: /usr/local/src/wger/
+  tags:
+    - update
+
+- name: Wger nginx file installed
+  copy:
+    src: nginx-location.conf
+    dest: /usr/local/etc/nginx/locations/wger.conf
+    mode: 0644
+  notify: Nginx restarted
+
+- name: Wger immortal file installed
+  copy:
+    src: immortal-wger.yml
+    dest: /usr/local/etc/immortal/wger.yml
+    mode: 0644
+  notify: Immortal restarted

+ 6 - 6
lab/ansible/roles/wger/templates/settings.py.j2

@@ -28,7 +28,7 @@ DATABASES = {
 }  # yapf: disable
 
 # Timezone for this installation. Consult settings_global.py for more information
-TIME_ZONE = 'America/New_York'
+TIME_ZONE = 'US/Eastern'
 
 # Make this unique, and don't share it with anybody.
 SECRET_KEY = '{{wger_secret_key}}'
@@ -41,19 +41,19 @@ NOCAPTCHA = True
 # The site's URL (e.g. http://www.my-local-gym.com or http://localhost:8000)
 # This is needed for uploaded files and images (exercise images, etc.) to be
 # properly served.
-SITE_URL = 'http://localhost:8000'
+SITE_URL = 'https://fit.unbl.ink'
 
 # Path to uploaded files
 # Absolute filesystem path to the directory that will hold user-uploaded files.
-MEDIA_ROOT = '/usr/local/src/wger/media'
+MEDIA_ROOT = '/usr/local/www/wger/media/'
 MEDIA_URL = '/media/'
 
-STATIC_ROOT = '/usr/local/src/wger/static/'
+STATIC_ROOT = '/usr/local/www/wger/static/'
 STATIC_URL = '/static/'
-COMPRESS_URL = '/usr/local/src/wger/static/compress/'
+COMPRESS_URL = '/usr/local/www/wger/static/compress/'
 
 # Allow all hosts to access the application. Change if used in production.
-ALLOWED_HOSTS = '*'
+ALLOWED_HOSTS = ['*']
 
 # This might be a good idea if you setup redis
 #SESSION_ENGINE = "django.contrib.sessions.backends.cache"