Skip to content

Commit

Permalink
feat: added AoCaaS to sad-server
Browse files Browse the repository at this point in the history
  • Loading branch information
leuke-naam committed Dec 9, 2024
1 parent 3cd4f8e commit 1abc1d4
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ansible/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
tags: "mongoose"
- role: "chroma"
tags: "chroma"
- role: "aocaas"
tags: "aocaas"
# We only want to deploy the crazy88 role when specifically requested
- role: "crazy88bot"
tags: ["never", "crazy88bot"]
Expand Down
4 changes: 4 additions & 0 deletions ansible/roles/aocaas/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- name: Restart AoCaaS
ansible.builtin.service:
name: aocaas
state: restarted
42 changes: 42 additions & 0 deletions ansible/roles/aocaas/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
- name: Create user for AoCaaS
ansible.builtin.user:
name: aosaas
home: /var/www/aocaas
shell: /usr/sbin/nologin
system: true
state: present

- name: Download and extract the AoCaaS binary
ansible.builtin.get_url:
# Fix this later
url: https://github.com/svsticky/AoCaaS/actions/runs/12240600267/artifacts/2295080056
dest: /var/www/aocaas/bin/artifact.zip
owner: aocaas
group: aocaas
mode: '775'
notify: restart aocaas

- name: Extract the AoCaaS binary
ansible.builtin.unarchive:
src: /var/www/aocaas/bin/artifact.zip
dest: /var/www/aocaas/
notify: restart aocaas

- name: Copy nginx configuration
ansible.builtin.template:
src: aocaas.conf.j2
dest: /etc/nginx/sites-enabled/aocaas.{{ canonical_hostname }}.conf
notify: reload nginx

- name: Template systemd service file
ansible.builtin.template:
src: aocaas.service.j2
dest: /etc/systemd/system/aocaas.service
notify: restart aocaas

- name: Run `aocaas` service
ansible.builtin.systemd:
unit: aocaas.service
state: started
enabled: true
daemon-reload: true
21 changes: 21 additions & 0 deletions ansible/roles/aocaas/templates/aocaas.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# {{ ansible_managed }}

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;

server_name aoc.{{ canonical_hostname }};

ssl_certificate /etc/letsencrypt/live/aocaas.{{ canonical_hostname }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/aocaas.{{ canonical_hostname }}/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/aocaas.{{ canonical_hostname }}/chain.pem;

include includes/security-headers.conf;

location /{
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_intercept_errors on;
proxy_pass http://localhost:3456; // !
}
}
16 changes: 16 additions & 0 deletions ansible/roles/aocaas/templates/aocaas.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# {{ ansible_managed }}

[Unit]
Description=Run AoCaaS
OnFailure=failure-notificator@%n.service

[Service]
Type=simple
User=aocaas
Group=aocaas
Restart=always
WorkingDirectory=/var/www/aocaas
ExecStart=/var/www/aocaas/bin/aocaas

[Install]
WantedBy=multi-user.target

0 comments on commit 1abc1d4

Please sign in to comment.