Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified ansible/deploy.sh
100755 → 100644
Empty file.
9 changes: 9 additions & 0 deletions ansible/env.j2
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,12 @@ SERVICE_ACCOUNT_FILE="{{ service_account_file }}"
{% if django_debug %}
DJANGO_DEBUG="{{ django_debug }}"
{% endif %}

# Redis Configuration
{% if redis_url %}
REDIS_URL="{{ redis_url }}"
{% endif %}
Comment thread
ishaan-arora-1 marked this conversation as resolved.

# Cookie security overrides (for staging without HTTPS)
CSRF_COOKIE_SECURE="{{ csrf_cookie_secure }}"
SESSION_COOKIE_SECURE="{{ session_cookie_secure }}"
Comment thread
ishaan-arora-1 marked this conversation as resolved.
4 changes: 4 additions & 0 deletions ansible/nginx-http.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ http {

location / {
proxy_pass http://127.0.0.1:{{ app_port }};
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
Comment thread
ishaan-arora-1 marked this conversation as resolved.
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down
8 changes: 8 additions & 0 deletions ansible/nginx.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ http {

location / {
proxy_pass http://127.0.0.1:{{ app_port }};
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
Comment thread
ishaan-arora-1 marked this conversation as resolved.
proxy_set_header Host {{ domain_name | default('alphaonelabs.com') }};
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down Expand Up @@ -120,6 +124,10 @@ http {

location / {
proxy_pass http://127.0.0.1:{{ app_port }};
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
Comment thread
ishaan-arora-1 marked this conversation as resolved.
proxy_set_header Host {{ domain_name | default('alphaonelabs.com') }};
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down
14 changes: 12 additions & 2 deletions ansible/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- postgresql
- postgresql-contrib
- libpq-dev
- redis-server

tasks:
- name: Install base packages (non-interactive, synchronous)
Expand Down Expand Up @@ -114,6 +115,9 @@
git_branch: "{{ env_vars.GIT_BRANCH | default(git_branch) }}"
allowed_hosts: "{{ env_vars.ALLOWED_HOSTS | default('localhost,127.0.0.1') }}"
csrf_trusted_origins: "{{ env_vars.CSRF_TRUSTED_ORIGINS | default('localhost,127.0.0.1') }}"
redis_url: "{{ env_vars.REDIS_URL | default('redis://localhost:6379') }}"
csrf_cookie_secure: "{{ env_vars.CSRF_COOKIE_SECURE | default('False') }}"
session_cookie_secure: "{{ env_vars.SESSION_COOKIE_SECURE | default('False') }}"

- name: Ensure application user exists
user: { name: "{{ vps_user }}", system: true, create_home: true, shell: /bin/bash }
Expand Down Expand Up @@ -185,15 +189,21 @@
notify: restart app

- name: Allow ports
ufw:
community.general.ufw:
Comment thread
ishaan-arora-1 marked this conversation as resolved.
rule: allow
port: "{{ item }}"
loop: [22, 80, 443]

- name: Enable firewall (now that everything is ready)
ufw:
community.general.ufw:
Comment thread
ishaan-arora-1 marked this conversation as resolved.
state: enabled

- name: Ensure Redis service is enabled and running
service:
Comment thread
ishaan-arora-1 marked this conversation as resolved.
name: redis-server
state: started
enabled: yes
Comment thread
ishaan-arora-1 marked this conversation as resolved.

handlers:
- name: restart nginx
service: {name: nginx, state: restarted, enabled: yes}
Expand Down