Browse Source

[mathesar] Add mathear confgs

Colin Powell 3 years ago
parent
commit
0d0d1aec2f

+ 17 - 0
ansible/roles/mathesar/files/nginx-location.conf

@@ -0,0 +1,17 @@
+location /ui {
+    proxy_pass http://localhost:3000;
+    proxy_set_header X-Forwarded-Proto $scheme;
+    proxy_set_header X-Forwarded-Port 443;
+    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    proxy_set_header Host $host;
+    proxy_redirect off;
+}
+
+location / {
+    proxy_pass http://localhost:8000;
+    proxy_set_header X-Forwarded-Proto $scheme;
+    proxy_set_header X-Forwarded-Port 443;
+    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    proxy_set_header Host $host;
+    proxy_redirect off;
+}

+ 108 - 0
ansible/roles/mathesar/tasks/main.yml

@@ -0,0 +1,108 @@
+---
+- name: Dependencies installed
+  # We install xmlsec and cairocffi using pkg because python-Levenshtein is tricky to install on FreeBSD
+  community.general.pkgng:
+    name: git,py37-pip,vim-console,tmux,fish,direnv,postgresql12-client,py37-sqlite3
+    state: latest
+
+- name: Root shell is fish
+  ansible.builtin.user: name=root shell=/usr/local/bin/fish
+
+- name: Nginx location file installed
+  copy:
+    src: nginx-location.conf
+    dest: /usr/local/etc/nginx/locations/mathesar.conf
+    mode: 0644
+  notify: Nginx restarted
+
+- name: Source folder exists
+  file:
+    path: /usr/local/src
+    mode: 0755
+    state: directory
+
+- name: Create python bin link for yarn
+  file:
+    src: /usr/local/bin/python3.7
+    dest: /usr/bin/python
+    owner: root
+    state: link
+
+- name: 15Five source deployed
+  git:
+    repo: "https://github.com/centerofci/mathesar"
+    dest: /usr/local/src/mathesar
+    accept_hostkey: yes
+    update: yes
+  ignore_errors: true
+  tags:
+    - deploy
+
+- name: Syncthing ignore file installed
+  copy:
+    src: stignore
+    dest: /usr/local/src/fifteen5/.stignore
+    mode: 0775
+
+- name: Syncthing running as root
+  shell:
+    cmd: 'sed -i -e ''/^: ${syncthing_user/s/"syncthing"/"root"/'' /usr/local/etc/rc.d/syncthing'
+    warn: false
+  notify: Syncthing restarted
+
+- name: Environment file installed
+  template:
+    src: envrc.j2
+    dest: /usr/local/src/mathesar/.envrc
+    mode: 0600
+  tags:
+    - deploy
+
+- name: Allow environment file
+  shell:
+    cmd: direnv allow
+    chdir: /usr/local/src/mathesar
+  tags:
+    - deploy
+
+- name: Requirements up to date
+  pip:
+    requirements: /usr/local/src/mathesar/requirements.txt
+    executable: pip
+  tags:
+    - deploy
+
+- name: Migrations up to date
+  command: bash -lc "direnv exec /usr/local/src/mathesar /usr/local/bin/python3.7 /usr/local/src/mathesar/manage.py migrate"
+  tags:
+    - deploy
+
+- name: Install base tables
+  command: bash -lc "direnv exec /usr/local/src/mathesar /usr/local/bin/python3.7 /usr/local/src/mathesar/install.py"
+  tags:
+    - deploy
+
+- name: Frontend files generated and copied
+  command: bash -lc "direnv exec /usr/local/src/mathesar/usr/local/bin/npm install"
+  args:
+    chdir: "/usr/local/src/mathesar"
+  tags:
+    - deploy
+    - never
+
+- name: API supervisor file installed
+  copy:
+    src: mathesar-api-supervisor.conf
+    dest: /usr/local/etc/supervisor/conf.d/mathesar-api.conf
+    owner: root
+    mode: 0644
+  notify: Supervisor restarted
+
+- name: UI supervisor file installed
+  copy:
+    src: mathesar-ui-supervisor.conf
+    dest: /usr/local/etc/supervisor/conf.d/mathesar-ui.conf
+    owner: root
+    mode: 0644
+  notify: Supervisor restarted
+

+ 8 - 0
ansible/roles/mathesar/templates/mathesar-api-supervisor.conf

@@ -0,0 +1,8 @@
+[program:mathesar-api]
+command=/usr/local/bin/bash -lc "direnv exec /usr/local/src/mathesar python manage.py runserver 0.0.0.0:8000"
+directory=/usr/local/src/mathesar
+autostart=true
+autorestart=true
+stdout_logfile=/var/log/supervisor-mathesar-api.log
+stderr_logfile=/var/log/supervisor-mathesar-api.err.log
+stopsignal=QUIT

+ 8 - 0
ansible/roles/mathesar/templates/mathesar-ui-supervisor.conf

@@ -0,0 +1,8 @@
+[program:mathesar-ui]
+command=/usr/local/bin/bash -lc "direnv exec /usr/local/src/mathesar/mathesar_ui npm run dev"
+directory=/usr/local/src/mathesar/mathesar_ui
+autostart=true
+autorestart=true
+stdout_logfile=/var/log/supervisor-mathesar-ui.log
+stderr_logfile=/var/log/supervisor-mathesar-ui.err.log
+stopsignal=QUIT